staff.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. <?php
  2. Doo::loadCore ( 'db/DooModel' );
  3. class staff extends DooModel {
  4. public $sid;
  5. public $username;
  6. public $passwork;
  7. public $staffManage;
  8. public $isadmin;
  9. public $cid;
  10. public $othercid;
  11. public $category;
  12. public $othercategory;
  13. public $gender;
  14. public $qq;
  15. public $phone;
  16. public $telephone;
  17. public $email;
  18. public $birthday;
  19. public $position;
  20. public $avatar;
  21. public $appDate;
  22. public $hiredate;
  23. public $hireBiasDate;
  24. public $wxid;
  25. public $wecat;
  26. public $nature;
  27. public $remittanceName;
  28. public $bankName;
  29. public $bankNumber;
  30. public $coupletNumber;
  31. public $remittanceBankType;
  32. public $living;
  33. public $nativePlace;
  34. public $emergencyContacts;
  35. public $did;
  36. public $didName;
  37. public $jobNumber;
  38. public $baseWage;
  39. public $postWage;
  40. public $achievementBonus;
  41. public $pendingApprovals;
  42. public $processApprovals;
  43. public $processCC;
  44. public $InductionDate;
  45. public $pendStatus;
  46. public $updateDate;
  47. public $probationaryDate;
  48. public $regularsDate;
  49. public $qualifications;
  50. public $marriage;
  51. public $salaryCard;
  52. public $salaryBank;
  53. public $pendingApprovalsLeave;
  54. public $processApprovalsLeave;
  55. public $processLeaveCC;
  56. public $staffManageLeave;
  57. public $dimissionDate;
  58. public $dimissionReason;
  59. public $seniorityFormula;
  60. public $practiceDate;
  61. public $cldAccess;
  62. public $IDcards;
  63. public $IDcardsImgA;
  64. public $certificate;
  65. public $diploma;
  66. public $professionalTitle;
  67. public $IDcardsImgB;
  68. public $nation;
  69. public $graduateInstitutions;
  70. public $major;
  71. public $education;
  72. public $graduationTime;
  73. public $registeredResidence;
  74. public $householdRegistrationType;
  75. public $IDcardsValidity;
  76. public $positionId;
  77. public $_table = 'CLD_staff';
  78. public $_primarykey = 'sid';
  79. public $_fields = array (
  80. 'nation',
  81. 'graduateInstitutions',
  82. 'major',
  83. 'education',
  84. 'graduationTime',
  85. 'registeredResidence',
  86. 'householdRegistrationType',
  87. 'IDcardsValidity',
  88. 'IDcards',
  89. 'IDcardsImgA',
  90. 'IDcardsImgB',
  91. 'certificate',
  92. 'diploma',
  93. 'professionalTitle',
  94. 'sid',
  95. 'username',
  96. 'staffManage',
  97. 'birthday',
  98. 'position',
  99. 'passwork',
  100. 'isadmin',
  101. 'cid',
  102. 'othercid',
  103. 'appDate',
  104. 'category',
  105. 'othercategory',
  106. 'gender',
  107. 'qq',
  108. 'phone',
  109. 'telephone',
  110. 'email',
  111. 'avatar',
  112. 'hiredate',
  113. 'hireBiasDate',
  114. 'wxid',
  115. 'nature',
  116. 'remittanceName',
  117. 'bankName',
  118. 'bankNumber',
  119. 'remittanceBankType',
  120. 'coupletNumber',
  121. 'did',
  122. 'jobNumber',
  123. 'baseWage',
  124. 'postWage',
  125. 'achievementBonus',
  126. 'pendingApprovals',
  127. 'processApprovals',
  128. 'processCC',
  129. 'pendingApprovalsLeave',
  130. 'processApprovalsLeave',
  131. 'processLeaveCC',
  132. 'staffManageLeave',
  133. 'InductionDate',
  134. 'pendStatus',
  135. 'wecat',
  136. 'updateDate',
  137. 'dimissionReason',
  138. 'salaryCard',
  139. 'salaryBank',
  140. 'qualifications',
  141. 'marriage',
  142. 'living',
  143. 'nativePlace',
  144. 'emergencyContacts',
  145. 'practiceDate',
  146. 'probationaryDate',
  147. 'regularsDate',
  148. 'dimissionDate',
  149. 'seniorityFormula',
  150. 'cldAccess',
  151. 'didName',
  152. 'positionId'
  153. );
  154. public function checkUser($uid, $passwork) {
  155. return $this->find ( array (
  156. 'select' => 'position,birthday,sid,username,isadmin,cid,othercid,category,othercategory,gender,qq,phone,telephone,email,avatar,hiredate,nature',
  157. 'where' => "username= '" . $uid . "' and passwork = '" . md5 ( $passwork ) . "' and nature!=4",
  158. 'asArray' => TRUE
  159. ) );
  160. }
  161. public function getStaffByName($username = '') {
  162. $detail=$this->getOne ( array (
  163. 'asc' => 'sid',
  164. 'where' => "username= '" . $username . "'",
  165. 'asArray' => TRUE
  166. ) );
  167. Doo::loadClass ( 'XDeode' );
  168. $XDeode = new XDeode ( 5 );
  169. if (!empty($detail))
  170. $detail['sidKey'] = $XDeode->encode ( $detail ['sid'] );
  171. return $detail;
  172. }
  173. /**
  174. * @return string
  175. */
  176. public function getStaff($admin=false) {
  177. Doo::loadClass ( 'XDeode' );
  178. $XDeode = new XDeode ( 5 );
  179. Doo::loadModel ( 'department' );
  180. $department = new department ();
  181. $condition = array (
  182. 'desc' => 'jobNumber',
  183. 'asArray' => TRUE
  184. );
  185. if ($admin)
  186. $condition += array (
  187. 'where' => "username != 'admin' and nature !=4",
  188. );
  189. $list = $this->find ( $condition);
  190. foreach ( $list as $key => $value ) {
  191. $list [$key] ['departmentName'] ='';
  192. if($value['departmentID']!=0){
  193. $list [$key] ['departmentName'] =$department->getDepartmentByDid($value['departmentID']);
  194. }
  195. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  196. $list [$key] ['cidKey'] = $XDeode->encode ( $value ['cid'] );
  197. $list [$key] ['didKey'] = '';
  198. if (!empty($value ['departmentID']))
  199. $list [$key] ['didKey'] = $XDeode->encode ( $value ['departmentID'] );
  200. }
  201. return $list;
  202. }
  203. /**
  204. * 根据条件获得查询内容
  205. * @param string $con
  206. * @return string
  207. */
  208. public function getStaffByCondition($con=''){
  209. if ( empty ( $con ))
  210. return array ();
  211. Doo::loadClass ( 'XDeode' );
  212. $XDeode = new XDeode ( 5 );
  213. Doo::loadModel ( 'department' );
  214. $department = new department ();
  215. $list = $this->find ( array (
  216. 'where' => $con,
  217. 'desc' => 'jobNumber',
  218. 'asArray' => TRUE
  219. ) );
  220. foreach ( $list as $key => $value ) {
  221. $list [$key] ['departmentName'] ='';
  222. if($value['departmentID']!=0){
  223. $list [$key] ['departmentName'] =$department->getDepartmentByDid($value['departmentID']);
  224. }
  225. $list [$key] ['didArray']=array();
  226. if (!empty($value['did']))
  227. $list [$key] ['didArray']=explode(',', $value['did']);
  228. $list [$key] ['cldAccessArray'] = json_decode($value['cldAccess']);
  229. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  230. $list [$key] ['cidKey'] = $XDeode->encode ( $value ['cid'] );
  231. $list [$key] ['didKey'] = '';
  232. if (!empty($value ['departmentID']))
  233. $list [$key] ['didKey'] = $XDeode->encode ( $value ['departmentID'] );
  234. }
  235. return $list;
  236. }
  237. public function getStaffInCid($cid = '') {
  238. if (empty ( $cid ))
  239. return array ();
  240. $list = $this->find ( array (
  241. 'asc' => 'sid',
  242. 'where' => "cid in(" . $cid . ")",
  243. 'asArray' => TRUE
  244. ) );
  245. Doo::loadClass ( 'XDeode' );
  246. $XDeode = new XDeode ( 5 );
  247. foreach ( $list as $key => $value ) {
  248. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  249. }
  250. return $list;
  251. }
  252. /**
  253. * 获得单位下所有的员工
  254. * @param number $pid
  255. */
  256. public function getStaffByPositionId($pid=0){
  257. $list = $this->find ( array (
  258. 'where' => "positionId= '" . $pid . "' and username!='admin'",
  259. 'asArray' => TRUE
  260. ) );
  261. // Doo::loadClass ( 'XDeode' );
  262. // $XDeode = new XDeode ( 5 );
  263. // foreach ( $list as $key => $value ) {
  264. // $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  265. // }
  266. return $list;
  267. }
  268. public function getStaffByCid($cid = 0) {
  269. $list = $this->find ( array (
  270. 'asc' => 'sid',
  271. 'where' => "cid= '" . $cid . "' and nature !=4 ",
  272. 'asArray' => TRUE
  273. ) );
  274. Doo::loadClass ( 'XDeode' );
  275. $XDeode = new XDeode ( 5 );
  276. foreach ( $list as $key => $value ) {
  277. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  278. }
  279. return $list;
  280. }
  281. /**
  282. * 获得审批中员工
  283. */
  284. public function getStaffByApplied($sid=0){
  285. $list = $this->find ( array (
  286. 'asc' => 'sid',
  287. 'where' => "(pendStatus= '2' or pendStatus='3' or pendStatus='5') and (pendingApprovals ='" . $sid . "' or pendingApprovalsLeave='" . $sid . "')",
  288. 'asArray' => TRUE
  289. ) );
  290. Doo::loadClass ( 'XDeode' );
  291. $XDeode = new XDeode ( 5 );
  292. foreach ( $list as $key => $value ) {
  293. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  294. }
  295. return $list;
  296. }
  297. /**
  298. * 获得最近审批通过的员工
  299. * @return string
  300. */
  301. public function getStaffByApprovals(){
  302. $list = $this->find ( array (
  303. 'asc' => 'InductionDate',
  304. 'where' => "username!= 'admin' and pendStatus=0 and InductionDate!=0",
  305. 'limit' => 10,
  306. 'asArray' => TRUE
  307. ) );
  308. Doo::loadClass ( 'XDeode' );
  309. $XDeode = new XDeode ( 5 );
  310. foreach ( $list as $key => $value ) {
  311. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  312. }
  313. return $list;
  314. }
  315. /**
  316. * 获得最近更新的员工
  317. */
  318. public function getStaffByUpdateDate(){
  319. $list = $this->find ( array (
  320. 'asc' => 'updateDate',
  321. 'where' => "username!= 'admin'",
  322. 'limit' => 10,
  323. 'asArray' => TRUE
  324. ) );
  325. Doo::loadClass ( 'XDeode' );
  326. $XDeode = new XDeode ( 5 );
  327. foreach ( $list as $key => $value ) {
  328. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  329. }
  330. return $list;
  331. }
  332. public function getUserById($sid = 0) {
  333. $list =$this->find ( array (
  334. 'asc' => 'sid',
  335. 'where' => "sid= '" . $sid . "'",
  336. 'asArray' => TRUE
  337. ) );
  338. Doo::loadClass ( 'XDeode' );
  339. $XDeode = new XDeode ( 5 );
  340. foreach ( $list as $key => $value ) {
  341. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  342. }
  343. return $list;
  344. }
  345. public function getUserByIdList($puid) {
  346. Doo::loadClass ( 'XDeode' );
  347. $XDeode = new XDeode ( 5 );
  348. $puid = $XDeode->decode ( $puid );
  349. $list=$this->find ( array (
  350. 'where' => "sid= '" . $puid . "'",
  351. 'asArray' => TRUE
  352. ) );
  353. foreach ($list as $key=>$value){
  354. $list[$key]['sidKey']=$XDeode->encode ( $value ['sid'] );
  355. }
  356. return $list;
  357. }
  358. /**
  359. * 检查信息是否填写完整
  360. * @param unknown $sid
  361. * @return string
  362. */
  363. public function checkStaffInfoIsComplete($sid){
  364. Doo::loadClass ( 'XDeode' );
  365. $XDeode = new XDeode ( 5 );
  366. if (!is_numeric($sid)){
  367. $sid = $XDeode->decode ( $sid );
  368. }
  369. $detail=$this->getOne ( array (//or wecat='' or email='' or coupletNumber=''
  370. 'where' => "sid= '" . $sid . "' and (telephone='' or qq='' or phone='' or birthday='' or marriage='' or living='' or nativePlace='' or emergencyContacts='' or IDcards=''
  371. or IDcardsImgA='' or IDcardsImgB='' or remittanceName='' or bankName='' or bankNumber='' or salaryCard='' or salaryBank='' )",
  372. 'asArray' => TRUE
  373. ) );
  374. return $detail;
  375. }
  376. /**
  377. * 根据参数字段更新相应字段(主键ID必须传)
  378. * @param array $item 相关需要更新的字段信息
  379. * @return number 返回员工ID
  380. */
  381. public function setStaffByCondition($item = array()) {
  382. $lid = 0;
  383. if (is_array ( $item ) && ! empty ( $item )) {
  384. foreach ( $item as $key => $value ) {
  385. $this->$key = $value;
  386. }
  387. $lid = $this->update ();
  388. }
  389. return $lid;
  390. }
  391. /**
  392. *
  393. * @param number $nature
  394. */
  395. public function getStaffJobNumberByNature($nature=1){
  396. $detail=$this->getOne ( array (
  397. 'where' => "nature= '" . $nature . "'",
  398. 'desc' => 'jobNumber',
  399. 'asArray' => TRUE
  400. ) );
  401. return $detail;
  402. }
  403. /**
  404. *
  405. * @param number $nature
  406. */
  407. public function getStaffJobNumberByInformal(){
  408. $detail=$this->getOne ( array (
  409. 'where' => "nature= '2' or nature ='3'",
  410. 'desc' => 'jobNumber',
  411. 'asArray' => TRUE
  412. ) );
  413. return $detail;
  414. }
  415. /**
  416. * 根据用户ID获取相关信息
  417. * @param number $sid 用户ID
  418. */
  419. public function getStaffBySid($sid = 0) {
  420. Doo::loadClass ( 'XDeode' );
  421. $XDeode = new XDeode ( 5 );
  422. if (!is_numeric($sid)){
  423. $sid = $XDeode->decode ( $sid );
  424. }
  425. $detail = array ();
  426. if (! empty ( $sid )){
  427. $detail = $this->getOne ( array (
  428. 'where' => "sid= '" . $sid . "'",
  429. 'asArray' => TRUE
  430. ) );
  431. Doo::loadModel ( 'department' );
  432. $department = new department ();
  433. $detail ['department'] =$department->getDepartmentByDid($detail['departmentID']);
  434. $d1 = strtotime($detail['hiredate']);//过去的某天,你来设定
  435. $d2 = 1 + ceil((time()-$d1)/60/60/24);
  436. $detail['workforce']=$d2;
  437. $d1 = strtotime($detail['dimissionDate']);//离职到今天
  438. $d2 = 1 + ceil((time()-$d1)/60/60/24);
  439. $detail['workforceDimission']=$d2;
  440. $detail ['cldAccessArray'] = json_decode($detail['cldAccess']);
  441. $detail['sidKey']=$XDeode->encode ( $detail ['sid'] );
  442. $webSite=WEB_SITE.'/upload/credentialInfo/';
  443. $detail['webSite']=$webSite;
  444. $detail['certificateArray']=array();
  445. if(!empty($detail['certificate'])){
  446. $certificate=json_decode($detail['certificate']);
  447. if(!empty($certificate)){
  448. foreach ($certificate as $key=>$value){
  449. $certificate[$key]=$value;
  450. }
  451. $detail['certificateArray']=$certificate;
  452. }
  453. }
  454. $detail['diplomaArray']=array();
  455. if(!empty($detail['diploma'])){
  456. $certificate=json_decode($detail['diploma']);
  457. if(!empty($certificate)){
  458. foreach ($certificate as $key=>$value){
  459. $certificate[$key]=$value;
  460. }
  461. $detail['diplomaArray']=$certificate;
  462. }
  463. }
  464. $detail['professionalTitleArray']=array();
  465. if(!empty($detail['professionalTitle'])){
  466. $certificate=json_decode($detail['professionalTitle']);
  467. if(!empty($certificate)){
  468. foreach ($certificate as $key=>$value){
  469. $certificate[$key]=$value;
  470. }
  471. $detail['professionalTitleArray']=$certificate;
  472. }
  473. }
  474. }
  475. return $detail;
  476. }
  477. public function getStaffByWxid($wxid = '') {
  478. // echo "wxid in ( " . $wxid . ")";
  479. if (empty ( $wxid ))
  480. return array ();
  481. return $this->find ( array (
  482. 'select' => 'sid,wxid',
  483. 'where' => "wxid in ( " . $wxid . ")",
  484. 'asArray' => TRUE
  485. ) );
  486. }
  487. // 建筑获取办事处人员部分信息
  488. public function getStaffByCidOnBuilding($cid = 0) {
  489. $list = $this->find ( array (
  490. 'select' => 'sid,username,cid,departmentID,category,qq,phone,telephone',
  491. 'asc' => 'sid',
  492. 'where' => "cid= '" . $cid . "'",
  493. 'asArray' => TRUE
  494. ) );
  495. return $list;
  496. }
  497. }
  498. ?>