staff.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  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 $appliedPromote;
  78. public $departmentID;
  79. public $_table = 'CLD_staff';
  80. public $_primarykey = 'sid';
  81. public $_fields = array (
  82. 'nation',
  83. 'graduateInstitutions',
  84. 'major',
  85. 'education',
  86. 'graduationTime',
  87. 'registeredResidence',
  88. 'householdRegistrationType',
  89. 'IDcardsValidity',
  90. 'IDcards',
  91. 'IDcardsImgA',
  92. 'IDcardsImgB',
  93. 'certificate',
  94. 'diploma',
  95. 'professionalTitle',
  96. 'sid',
  97. 'username',
  98. 'staffManage',
  99. 'birthday',
  100. 'position',
  101. 'passwork',
  102. 'isadmin',
  103. 'cid',
  104. 'othercid',
  105. 'appDate',
  106. 'category',
  107. 'othercategory',
  108. 'gender',
  109. 'qq',
  110. 'phone',
  111. 'telephone',
  112. 'email',
  113. 'avatar',
  114. 'hiredate',
  115. 'hireBiasDate',
  116. 'wxid',
  117. 'nature',
  118. 'remittanceName',
  119. 'bankName',
  120. 'bankNumber',
  121. 'remittanceBankType',
  122. 'coupletNumber',
  123. 'did',
  124. 'jobNumber',
  125. 'baseWage',
  126. 'postWage',
  127. 'achievementBonus',
  128. 'pendingApprovals',
  129. 'processApprovals',
  130. 'processCC',
  131. 'pendingApprovalsLeave',
  132. 'processApprovalsLeave',
  133. 'processLeaveCC',
  134. 'staffManageLeave',
  135. 'InductionDate',
  136. 'pendStatus',
  137. 'wecat',
  138. 'updateDate',
  139. 'dimissionReason',
  140. 'salaryCard',
  141. 'salaryBank',
  142. 'qualifications',
  143. 'marriage',
  144. 'living',
  145. 'nativePlace',
  146. 'emergencyContacts',
  147. 'practiceDate',
  148. 'probationaryDate',
  149. 'regularsDate',
  150. 'dimissionDate',
  151. 'seniorityFormula',
  152. 'cldAccess',
  153. 'departmentID',
  154. 'didName',
  155. 'positionId',
  156. 'appliedPromote'
  157. );
  158. public function checkUser($uid, $passwork) {
  159. return $this->find ( array (
  160. 'select' => 'position,birthday,sid,username,isadmin,cid,othercid,category,othercategory,gender,qq,phone,telephone,email,avatar,hiredate,nature',
  161. 'where' => "username= '" . $uid . "' and passwork = '" . md5 ( $passwork ) . "' and nature!=4",
  162. 'asArray' => TRUE
  163. ) );
  164. }
  165. public function getStaffByName($username = '') {
  166. if (empty($username))
  167. return array();
  168. $detail=$this->getOne ( array (
  169. 'asc' => 'sid',
  170. 'where' => "username= '" . $username . "'",
  171. 'asArray' => TRUE
  172. ) );
  173. if (empty($detail))
  174. return array();
  175. Doo::loadModel ( 'department' );
  176. $department = new department ();
  177. $detail ['departmentName']=array();
  178. if($detail['departmentID']!=0){
  179. $detail ['departmentName'] =$department->getDepartmentByDid($detail['departmentID']);
  180. }
  181. Doo::loadClass ( 'XDeode' );
  182. $XDeode = new XDeode ( 5 );
  183. if (!empty($detail))
  184. $detail['sidKey'] = $XDeode->encode ( $detail ['sid'] );
  185. return $detail;
  186. }
  187. /**
  188. * @return string
  189. */
  190. public function getStaff($admin=false) {
  191. Doo::loadClass ( 'XDeode' );
  192. $XDeode = new XDeode ( 5 );
  193. Doo::loadModel ( 'department' );
  194. $department = new department ();
  195. Doo::loadModel ( 'position' );
  196. $position = new position ();
  197. $condition = array (
  198. 'desc' => 'jobNumber',
  199. 'asArray' => TRUE
  200. );
  201. if ($admin)
  202. $condition += array (
  203. 'where' => "username != 'admin' and nature !=4",
  204. );
  205. $list = $this->find ( $condition);
  206. foreach ( $list as $key => $value ) {
  207. $list [$key] ['departmentName'] ='';
  208. if($value['departmentID']!=0){
  209. $list [$key] ['departmentName'] =$department->getDepartmentByDid($value['departmentID']);
  210. }
  211. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  212. $list [$key] ['cidKey'] = $XDeode->encode ( $value ['cid'] );
  213. $list [$key] ['didKey'] = '';
  214. if (!empty($value ['departmentID']))
  215. $list [$key] ['didKey'] = $XDeode->encode ( $value ['departmentID'] );
  216. $list [$key] ['position'] ='';
  217. $pdetail=$position->getPositionByPid($value['positionId']);
  218. if (!empty($pdetail))
  219. $list [$key] ['position'] =$pdetail['positionName'];
  220. }
  221. return $list;
  222. }
  223. /**
  224. * 根据条件获得查询内容
  225. * @param string $con
  226. * @return string
  227. */
  228. public function getStaffByCondition($con=''){
  229. if ( empty ( $con ))
  230. return array ();
  231. Doo::loadClass ( 'XDeode' );
  232. $XDeode = new XDeode ( 5 );
  233. Doo::loadModel ( 'department' );
  234. $department = new department ();
  235. Doo::loadModel ( 'position' );
  236. $position = new position ();
  237. $list = $this->find ( array (
  238. 'where' => $con,
  239. 'desc' => 'jobNumber',
  240. 'asArray' => TRUE
  241. ) );
  242. foreach ( $list as $key => $value ) {
  243. $list [$key] ['position'] ='';
  244. $pdetail=$position->getPositionByPid($value['positionId']);
  245. if (!empty($pdetail))
  246. $list [$key] ['position'] =$pdetail['positionName'];
  247. $list [$key] ['departmentName'] ='';
  248. if($value['departmentID']!=0){
  249. $list [$key] ['departmentName'] =$department->getDepartmentByDid($value['departmentID']);
  250. }
  251. $list [$key] ['didArray']=array();
  252. if (!empty($value['did']))
  253. $list [$key] ['didArray']=explode(',', $value['did']);
  254. $list [$key] ['cldAccessArray'] = json_decode($value['cldAccess']);
  255. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  256. $list [$key] ['cidKey'] = $XDeode->encode ( $value ['cid'] );
  257. $list [$key] ['didKey'] = '';
  258. if (!empty($value ['departmentID']))
  259. $list [$key] ['didKey'] = $XDeode->encode ( $value ['departmentID'] );
  260. }
  261. return $list;
  262. }
  263. public function getStaffInCid($cid = '') {
  264. if (empty ( $cid ))
  265. return array ();
  266. $list = $this->find ( array (
  267. 'asc' => 'sid',
  268. 'where' => "cid in(" . $cid . ")",
  269. 'asArray' => TRUE
  270. ) );
  271. Doo::loadClass ( 'XDeode' );
  272. $XDeode = new XDeode ( 5 );
  273. foreach ( $list as $key => $value ) {
  274. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  275. }
  276. return $list;
  277. }
  278. /**
  279. * 获得单位下所有的员工
  280. * @param number $pid
  281. */
  282. public function getStaffByPositionId($pid=0){
  283. Doo::loadClass ( 'XDeode' );
  284. $XDeode = new XDeode ( 5 );
  285. if (! is_numeric ( $pid ))
  286. $pid = $XDeode->decode ( $pid );
  287. $list = $this->find ( array (
  288. 'where' => "positionId= '" . $pid . "' and username!='admin'",
  289. 'asArray' => TRUE
  290. ) );
  291. // Doo::loadClass ( 'XDeode' );
  292. // $XDeode = new XDeode ( 5 );
  293. // foreach ( $list as $key => $value ) {
  294. // $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  295. // }
  296. return $list;
  297. }
  298. public function getStaffByCid($cid = 0) {
  299. $list = $this->find ( array (
  300. 'asc' => 'sid',
  301. 'where' => "cid= '" . $cid . "' and nature !=4 ",
  302. 'asArray' => TRUE
  303. ) );
  304. Doo::loadClass ( 'XDeode' );
  305. $XDeode = new XDeode ( 5 );
  306. Doo::loadModel ( 'position' );
  307. $position = new position ();
  308. foreach ( $list as $key => $value ) {
  309. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  310. $list [$key] ['position'] ='';
  311. $pdetail=$position->getPositionByPid($value['positionId']);
  312. if (!empty($pdetail))
  313. $list [$key] ['position'] =$pdetail['positionName'];
  314. }
  315. return $list;
  316. }
  317. public function getStaffByCidAll($cid = 0){
  318. $list = $this->find ( array (
  319. 'asc' => 'sid',
  320. 'where' => "cid= '" . $cid . "' ",
  321. 'asArray' => TRUE
  322. ) );
  323. Doo::loadClass ( 'XDeode' );
  324. $XDeode = new XDeode ( 5 );
  325. Doo::loadModel ( 'position' );
  326. $position = new position ();
  327. foreach ( $list as $key => $value ) {
  328. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  329. $list [$key] ['position'] ='';
  330. $pdetail=$position->getPositionByPid($value['positionId']);
  331. if (!empty($pdetail))
  332. $list [$key] ['position'] =$pdetail['positionName'];
  333. }
  334. return $list;
  335. }
  336. /**
  337. * 获得审批中员工
  338. */
  339. public function getStaffByApplied($sid=0){
  340. $list = $this->find ( array (
  341. 'asc' => 'sid',
  342. 'where' => "(pendStatus= '2' or pendStatus='3' or pendStatus='5' or pendStatus='6' or pendStatus='7') and (pendingApprovals ='" . $sid . "' or pendingApprovalsLeave='" . $sid . "')",
  343. 'asArray' => TRUE
  344. ) );
  345. Doo::loadClass ( 'XDeode' );
  346. $XDeode = new XDeode ( 5 );
  347. Doo::loadModel ( 'position' );
  348. $position = new position ();
  349. foreach ( $list as $key => $value ) {
  350. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  351. $list [$key] ['position'] ='';
  352. $pdetail=$position->getPositionByPid($value['positionId']);
  353. if (!empty($pdetail))
  354. $list [$key] ['position'] =$pdetail['positionName'];
  355. }
  356. return $list;
  357. }
  358. /**
  359. * 获得最近审批通过的员工
  360. * @return string
  361. */
  362. public function getStaffByApprovals(){
  363. $list = $this->find ( array (
  364. 'asc' => 'InductionDate',
  365. 'where' => "username!= 'admin' and pendStatus=0 and InductionDate!=0",
  366. 'limit' => 10,
  367. 'asArray' => TRUE
  368. ) );
  369. Doo::loadClass ( 'XDeode' );
  370. $XDeode = new XDeode ( 5 );
  371. foreach ( $list as $key => $value ) {
  372. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  373. }
  374. return $list;
  375. }
  376. /**
  377. * 获得最近更新的员工
  378. */
  379. public function getStaffByUpdateDate(){
  380. $list = $this->find ( array (
  381. 'asc' => 'updateDate',
  382. 'where' => "username!= 'admin'",
  383. 'limit' => 10,
  384. 'asArray' => TRUE
  385. ) );
  386. Doo::loadClass ( 'XDeode' );
  387. $XDeode = new XDeode ( 5 );
  388. foreach ( $list as $key => $value ) {
  389. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  390. }
  391. return $list;
  392. }
  393. public function getUserById($sid = 0) {
  394. $list =$this->find ( array (
  395. 'asc' => 'sid',
  396. 'where' => "sid= '" . $sid . "'",
  397. 'asArray' => TRUE
  398. ) );
  399. Doo::loadClass ( 'XDeode' );
  400. $XDeode = new XDeode ( 5 );
  401. foreach ( $list as $key => $value ) {
  402. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  403. }
  404. return $list;
  405. }
  406. public function getUserByIdList($puid) {
  407. Doo::loadClass ( 'XDeode' );
  408. $XDeode = new XDeode ( 5 );
  409. $puid = $XDeode->decode ( $puid );
  410. $list=$this->find ( array (
  411. 'where' => "sid= '" . $puid . "'",
  412. 'asArray' => TRUE
  413. ) );
  414. foreach ($list as $key=>$value){
  415. $list[$key]['sidKey']=$XDeode->encode ( $value ['sid'] );
  416. }
  417. return $list;
  418. }
  419. /**
  420. * 检查信息是否填写完整
  421. * @param unknown $sid
  422. * @return string
  423. */
  424. public function checkStaffInfoIsComplete($sid){
  425. Doo::loadClass ( 'XDeode' );
  426. $XDeode = new XDeode ( 5 );
  427. if (!is_numeric($sid)){
  428. $sid = $XDeode->decode ( $sid );
  429. }
  430. $detail=$this->getOne ( array (//or wecat='' or email='' or coupletNumber=''
  431. 'where' => "sid= '" . $sid . "' and (telephone='' or qq='' or phone='' or birthday='' or marriage='' or living='' or nativePlace='' or emergencyContacts='' or IDcards=''
  432. or IDcardsImgA='' or IDcardsImgB='' or remittanceName='' or bankName='' or bankNumber='' or salaryCard='' or salaryBank='' )",
  433. 'asArray' => TRUE
  434. ) );
  435. return $detail;
  436. }
  437. /**
  438. * 根据参数字段更新相应字段(主键ID必须传)
  439. * @param array $item 相关需要更新的字段信息
  440. * @return number 返回员工ID
  441. */
  442. public function setStaffByCondition($item = array()) {
  443. $lid = 0;
  444. if (is_array ( $item ) && ! empty ( $item )) {
  445. foreach ( $item as $key => $value ) {
  446. $this->$key = $value;
  447. }
  448. $lid = $this->update ();
  449. }
  450. return $lid;
  451. }
  452. /**
  453. *
  454. * @param number $nature
  455. */
  456. public function getStaffJobNumberByNature($nature=1){
  457. $detail=$this->getOne ( array (
  458. 'where' => "nature= '" . $nature . "'",
  459. 'desc' => 'jobNumber',
  460. 'asArray' => TRUE
  461. ) );
  462. return $detail;
  463. }
  464. /**
  465. *
  466. * @param number $nature
  467. */
  468. public function getStaffJobNumberByInformal(){
  469. $detail=$this->getOne ( array (
  470. 'where' => "nature= '2' or nature ='3'",
  471. 'desc' => 'jobNumber',
  472. 'asArray' => TRUE
  473. ) );
  474. return $detail;
  475. }
  476. /**
  477. * 根据用户ID获取相关信息
  478. * @param number $sid 用户ID
  479. */
  480. public function getStaffBySid($sid = 0) {
  481. Doo::loadClass ( 'XDeode' );
  482. $XDeode = new XDeode ( 5 );
  483. if (!is_numeric($sid)&&!empty($sid)){
  484. $sid = $XDeode->decode ( $sid );
  485. }
  486. $detail = array ();
  487. if (! empty ( $sid )){
  488. $detail = $this->getOne ( array (
  489. 'where' => "sid= '" . $sid . "'",
  490. 'asArray' => TRUE
  491. ) );
  492. $detail['sidKey']=$XDeode->encode ( $detail ['sid'] );
  493. Doo::loadModel ( 'department' );
  494. $department = new department ();
  495. $detail ['department'] =$department->getDepartmentByDid($detail['departmentID']);
  496. //获得岗位信息
  497. Doo::loadModel ( 'position' );
  498. $position = new position ();
  499. $positionIdKey=$XDeode->encode ( $detail ['positionId'] );
  500. $detail ['positionIdKey']=$positionIdKey;
  501. $positionDetail=$position->getPositionByPid($detail ['positionId']);
  502. //print_r('/'.$detail ['positionId'].'/');
  503. if(empty($positionDetail)){
  504. $positionDetail['baseWage']=0;
  505. $positionDetail['postWage']=0;
  506. $positionDetail['achievementBonus']=0;
  507. $positionDetail['positionName']='';
  508. }
  509. $detail ['positionDetail'] =$positionDetail;
  510. $d1 = strtotime($detail['hiredate']);//过去的某天,你来设定
  511. $d2 = 1 + ceil((time()-$d1)/60/60/24);
  512. $detail['workforce']=$d2;
  513. $d1 = strtotime($detail['dimissionDate']);//离职到今天
  514. $d2 = 1 + ceil((time()-$d1)/60/60/24);
  515. $detail['workforceDimission']=$d2;
  516. $detail ['cldAccessArray'] =array();
  517. if (!empty($detail['cldAccess']))
  518. $detail ['cldAccessArray'] =json_decode($detail['cldAccess']);
  519. $detail['sidKey']=$XDeode->encode ( $detail ['sid'] );
  520. $webSite=WEB_SITE.'/upload/credentialInfo/';
  521. $detail['webSite']=$webSite;
  522. $detail['certificateArray']=array();
  523. if(!empty($detail['certificate'])){
  524. $certificate=json_decode($detail['certificate']);
  525. if(!empty($certificate)){
  526. foreach ($certificate as $key=>$value){
  527. $certificate[$key]=$value;
  528. }
  529. $detail['certificateArray']=$certificate;
  530. }
  531. }
  532. $detail['diplomaArray']=array();
  533. if(!empty($detail['diploma'])){
  534. $certificate=json_decode($detail['diploma']);
  535. if(!empty($certificate)){
  536. foreach ($certificate as $key=>$value){
  537. $certificate[$key]=$value;
  538. }
  539. $detail['diplomaArray']=$certificate;
  540. }
  541. }
  542. $detail['professionalTitleArray']=array();
  543. if(!empty($detail['professionalTitle'])){
  544. $certificate=json_decode($detail['professionalTitle']);
  545. if(!empty($certificate)){
  546. foreach ($certificate as $key=>$value){
  547. $certificate[$key]=$value;
  548. }
  549. $detail['professionalTitleArray']=$certificate;
  550. }
  551. }
  552. }
  553. return $detail;
  554. }
  555. public function getApprovalData($sid=0){
  556. $list = $this->find ( array (
  557. 'asc' => 'sid',
  558. 'where' => "(pendStatus= '2' or pendStatus='3' or pendStatus='5' or pendStatus='6') and ( pendingApprovalsLeave='" . $sid . "' or pendingApprovals='" . $sid . "') ",
  559. 'asArray' => TRUE
  560. ) );
  561. return $list;
  562. }
  563. public function getStaffByWxid($wxid = '') {
  564. // echo "wxid in ( " . $wxid . ")";
  565. if (empty ( $wxid ))
  566. return array ();
  567. return $this->find ( array (
  568. 'select' => 'sid,wxid',
  569. 'where' => "wxid in ( " . $wxid . ")",
  570. 'asArray' => TRUE
  571. ) );
  572. }
  573. // 建筑获取办事处人员部分信息
  574. public function getStaffByCidOnBuilding($cid = 0) {
  575. $list = $this->find ( array (
  576. 'select' => 'sid,username,cid,departmentID,category,qq,phone,telephone',
  577. 'asc' => 'sid',
  578. 'where' => "cid= '" . $cid . "'",
  579. 'asArray' => TRUE
  580. ) );
  581. return $list;
  582. }
  583. }
  584. ?>