staff.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  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. $condition = array (
  196. 'desc' => 'jobNumber',
  197. 'asArray' => TRUE
  198. );
  199. if ($admin)
  200. $condition += array (
  201. 'where' => "username != 'admin' and nature !=4",
  202. );
  203. $list = $this->find ( $condition);
  204. foreach ( $list as $key => $value ) {
  205. $list [$key] ['departmentName'] ='';
  206. if($value['departmentID']!=0){
  207. $list [$key] ['departmentName'] =$department->getDepartmentByDid($value['departmentID']);
  208. }
  209. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  210. $list [$key] ['cidKey'] = $XDeode->encode ( $value ['cid'] );
  211. $list [$key] ['didKey'] = '';
  212. if (!empty($value ['departmentID']))
  213. $list [$key] ['didKey'] = $XDeode->encode ( $value ['departmentID'] );
  214. }
  215. return $list;
  216. }
  217. /**
  218. * 根据条件获得查询内容
  219. * @param string $con
  220. * @return string
  221. */
  222. public function getStaffByCondition($con=''){
  223. if ( empty ( $con ))
  224. return array ();
  225. Doo::loadClass ( 'XDeode' );
  226. $XDeode = new XDeode ( 5 );
  227. Doo::loadModel ( 'department' );
  228. $department = new department ();
  229. Doo::loadModel ( 'position' );
  230. $position = new position ();
  231. $list = $this->find ( array (
  232. 'where' => $con,
  233. 'desc' => 'jobNumber',
  234. 'asArray' => TRUE
  235. ) );
  236. foreach ( $list as $key => $value ) {
  237. $list [$key] ['position'] ='';
  238. $pdetail=$position->getPositionByPid($value['positionId']);
  239. if (!empty($pdetail))
  240. $list [$key] ['position'] =$pdetail['positionName'];
  241. $list [$key] ['departmentName'] ='';
  242. if($value['departmentID']!=0){
  243. $list [$key] ['departmentName'] =$department->getDepartmentByDid($value['departmentID']);
  244. }
  245. $list [$key] ['didArray']=array();
  246. if (!empty($value['did']))
  247. $list [$key] ['didArray']=explode(',', $value['did']);
  248. $list [$key] ['cldAccessArray'] = json_decode($value['cldAccess']);
  249. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  250. $list [$key] ['cidKey'] = $XDeode->encode ( $value ['cid'] );
  251. $list [$key] ['didKey'] = '';
  252. if (!empty($value ['departmentID']))
  253. $list [$key] ['didKey'] = $XDeode->encode ( $value ['departmentID'] );
  254. }
  255. return $list;
  256. }
  257. public function getStaffInCid($cid = '') {
  258. if (empty ( $cid ))
  259. return array ();
  260. $list = $this->find ( array (
  261. 'asc' => 'sid',
  262. 'where' => "cid in(" . $cid . ")",
  263. 'asArray' => TRUE
  264. ) );
  265. Doo::loadClass ( 'XDeode' );
  266. $XDeode = new XDeode ( 5 );
  267. foreach ( $list as $key => $value ) {
  268. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  269. }
  270. return $list;
  271. }
  272. /**
  273. * 获得单位下所有的员工
  274. * @param number $pid
  275. */
  276. public function getStaffByPositionId($pid=0){
  277. Doo::loadClass ( 'XDeode' );
  278. $XDeode = new XDeode ( 5 );
  279. if (! is_numeric ( $pid ))
  280. $pid = $XDeode->decode ( $pid );
  281. $list = $this->find ( array (
  282. 'where' => "positionId= '" . $pid . "' and username!='admin'",
  283. 'asArray' => TRUE
  284. ) );
  285. // Doo::loadClass ( 'XDeode' );
  286. // $XDeode = new XDeode ( 5 );
  287. // foreach ( $list as $key => $value ) {
  288. // $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  289. // }
  290. return $list;
  291. }
  292. public function getStaffByCid($cid = 0) {
  293. $list = $this->find ( array (
  294. 'asc' => 'sid',
  295. 'where' => "cid= '" . $cid . "' and nature !=4 ",
  296. 'asArray' => TRUE
  297. ) );
  298. Doo::loadClass ( 'XDeode' );
  299. $XDeode = new XDeode ( 5 );
  300. foreach ( $list as $key => $value ) {
  301. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  302. }
  303. return $list;
  304. }
  305. /**
  306. * 获得审批中员工
  307. */
  308. public function getStaffByApplied($sid=0){
  309. $list = $this->find ( array (
  310. 'asc' => 'sid',
  311. 'where' => "(pendStatus= '2' or pendStatus='3' or pendStatus='5' or pendStatus='6') and (pendingApprovals ='" . $sid . "' or pendingApprovalsLeave='" . $sid . "')",
  312. 'asArray' => TRUE
  313. ) );
  314. Doo::loadClass ( 'XDeode' );
  315. $XDeode = new XDeode ( 5 );
  316. Doo::loadModel ( 'position' );
  317. $position = new position ();
  318. foreach ( $list as $key => $value ) {
  319. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  320. $list [$key] ['position'] ='';
  321. $pdetail=$position->getPositionByPid($value['positionId']);
  322. if (!empty($pdetail))
  323. $list [$key] ['position'] =$pdetail['positionName'];
  324. }
  325. return $list;
  326. }
  327. /**
  328. * 获得最近审批通过的员工
  329. * @return string
  330. */
  331. public function getStaffByApprovals(){
  332. $list = $this->find ( array (
  333. 'asc' => 'InductionDate',
  334. 'where' => "username!= 'admin' and pendStatus=0 and InductionDate!=0",
  335. 'limit' => 10,
  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. /**
  346. * 获得最近更新的员工
  347. */
  348. public function getStaffByUpdateDate(){
  349. $list = $this->find ( array (
  350. 'asc' => 'updateDate',
  351. 'where' => "username!= 'admin'",
  352. 'limit' => 10,
  353. 'asArray' => TRUE
  354. ) );
  355. Doo::loadClass ( 'XDeode' );
  356. $XDeode = new XDeode ( 5 );
  357. foreach ( $list as $key => $value ) {
  358. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  359. }
  360. return $list;
  361. }
  362. public function getUserById($sid = 0) {
  363. $list =$this->find ( array (
  364. 'asc' => 'sid',
  365. 'where' => "sid= '" . $sid . "'",
  366. 'asArray' => TRUE
  367. ) );
  368. Doo::loadClass ( 'XDeode' );
  369. $XDeode = new XDeode ( 5 );
  370. foreach ( $list as $key => $value ) {
  371. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  372. }
  373. return $list;
  374. }
  375. public function getUserByIdList($puid) {
  376. Doo::loadClass ( 'XDeode' );
  377. $XDeode = new XDeode ( 5 );
  378. $puid = $XDeode->decode ( $puid );
  379. $list=$this->find ( array (
  380. 'where' => "sid= '" . $puid . "'",
  381. 'asArray' => TRUE
  382. ) );
  383. foreach ($list as $key=>$value){
  384. $list[$key]['sidKey']=$XDeode->encode ( $value ['sid'] );
  385. }
  386. return $list;
  387. }
  388. /**
  389. * 检查信息是否填写完整
  390. * @param unknown $sid
  391. * @return string
  392. */
  393. public function checkStaffInfoIsComplete($sid){
  394. Doo::loadClass ( 'XDeode' );
  395. $XDeode = new XDeode ( 5 );
  396. if (!is_numeric($sid)){
  397. $sid = $XDeode->decode ( $sid );
  398. }
  399. $detail=$this->getOne ( array (//or wecat='' or email='' or coupletNumber=''
  400. 'where' => "sid= '" . $sid . "' and (telephone='' or qq='' or phone='' or birthday='' or marriage='' or living='' or nativePlace='' or emergencyContacts='' or IDcards=''
  401. or IDcardsImgA='' or IDcardsImgB='' or remittanceName='' or bankName='' or bankNumber='' or salaryCard='' or salaryBank='' )",
  402. 'asArray' => TRUE
  403. ) );
  404. return $detail;
  405. }
  406. /**
  407. * 根据参数字段更新相应字段(主键ID必须传)
  408. * @param array $item 相关需要更新的字段信息
  409. * @return number 返回员工ID
  410. */
  411. public function setStaffByCondition($item = array()) {
  412. $lid = 0;
  413. if (is_array ( $item ) && ! empty ( $item )) {
  414. foreach ( $item as $key => $value ) {
  415. $this->$key = $value;
  416. }
  417. $lid = $this->update ();
  418. }
  419. return $lid;
  420. }
  421. /**
  422. *
  423. * @param number $nature
  424. */
  425. public function getStaffJobNumberByNature($nature=1){
  426. $detail=$this->getOne ( array (
  427. 'where' => "nature= '" . $nature . "'",
  428. 'desc' => 'jobNumber',
  429. 'asArray' => TRUE
  430. ) );
  431. return $detail;
  432. }
  433. /**
  434. *
  435. * @param number $nature
  436. */
  437. public function getStaffJobNumberByInformal(){
  438. $detail=$this->getOne ( array (
  439. 'where' => "nature= '2' or nature ='3'",
  440. 'desc' => 'jobNumber',
  441. 'asArray' => TRUE
  442. ) );
  443. return $detail;
  444. }
  445. /**
  446. * 根据用户ID获取相关信息
  447. * @param number $sid 用户ID
  448. */
  449. public function getStaffBySid($sid = 0) {
  450. Doo::loadClass ( 'XDeode' );
  451. $XDeode = new XDeode ( 5 );
  452. if (!is_numeric($sid)){
  453. $sid = $XDeode->decode ( $sid );
  454. }
  455. $detail = array ();
  456. if (! empty ( $sid )){
  457. $detail = $this->getOne ( array (
  458. 'where' => "sid= '" . $sid . "'",
  459. 'asArray' => TRUE
  460. ) );
  461. $detail['sidKey']=$XDeode->encode ( $detail ['sid'] );
  462. Doo::loadModel ( 'department' );
  463. $department = new department ();
  464. $detail ['department'] =$department->getDepartmentByDid($detail['departmentID']);
  465. //获得岗位信息
  466. Doo::loadModel ( 'position' );
  467. $position = new position ();
  468. $positionIdKey=$XDeode->encode ( $detail ['positionId'] );
  469. $detail ['positionIdKey']=$positionIdKey;
  470. $positionDetail=$position->getPositionByPid($detail ['positionId']);
  471. //print_r('/'.$detail ['positionId'].'/');
  472. if(empty($positionDetail)){
  473. $positionDetail['baseWage']=0;
  474. $positionDetail['postWage']=0;
  475. $positionDetail['achievementBonus']=0;
  476. $positionDetail['positionName']='';
  477. }
  478. $detail ['positionDetail'] =$positionDetail;
  479. $d1 = strtotime($detail['hiredate']);//过去的某天,你来设定
  480. $d2 = 1 + ceil((time()-$d1)/60/60/24);
  481. $detail['workforce']=$d2;
  482. $d1 = strtotime($detail['dimissionDate']);//离职到今天
  483. $d2 = 1 + ceil((time()-$d1)/60/60/24);
  484. $detail['workforceDimission']=$d2;
  485. $detail ['cldAccessArray'] =array();
  486. if (!empty($detail['cldAccess']))
  487. $detail ['cldAccessArray'] =json_decode($detail['cldAccess']);
  488. $detail['sidKey']=$XDeode->encode ( $detail ['sid'] );
  489. $webSite=WEB_SITE.'/upload/credentialInfo/';
  490. $detail['webSite']=$webSite;
  491. $detail['certificateArray']=array();
  492. if(!empty($detail['certificate'])){
  493. $certificate=json_decode($detail['certificate']);
  494. if(!empty($certificate)){
  495. foreach ($certificate as $key=>$value){
  496. $certificate[$key]=$value;
  497. }
  498. $detail['certificateArray']=$certificate;
  499. }
  500. }
  501. $detail['diplomaArray']=array();
  502. if(!empty($detail['diploma'])){
  503. $certificate=json_decode($detail['diploma']);
  504. if(!empty($certificate)){
  505. foreach ($certificate as $key=>$value){
  506. $certificate[$key]=$value;
  507. }
  508. $detail['diplomaArray']=$certificate;
  509. }
  510. }
  511. $detail['professionalTitleArray']=array();
  512. if(!empty($detail['professionalTitle'])){
  513. $certificate=json_decode($detail['professionalTitle']);
  514. if(!empty($certificate)){
  515. foreach ($certificate as $key=>$value){
  516. $certificate[$key]=$value;
  517. }
  518. $detail['professionalTitleArray']=$certificate;
  519. }
  520. }
  521. }
  522. return $detail;
  523. }
  524. public function getApprovalData($sid=0){
  525. $list = $this->find ( array (
  526. 'asc' => 'sid',
  527. 'where' => "(pendStatus= '2' or pendStatus='3' or pendStatus='5' or pendStatus='6') and ( pendingApprovalsLeave='" . $sid . "' or pendingApprovals='" . $sid . "') ",
  528. 'asArray' => TRUE
  529. ) );
  530. return $list;
  531. }
  532. public function getStaffByWxid($wxid = '') {
  533. // echo "wxid in ( " . $wxid . ")";
  534. if (empty ( $wxid ))
  535. return array ();
  536. return $this->find ( array (
  537. 'select' => 'sid,wxid',
  538. 'where' => "wxid in ( " . $wxid . ")",
  539. 'asArray' => TRUE
  540. ) );
  541. }
  542. // 建筑获取办事处人员部分信息
  543. public function getStaffByCidOnBuilding($cid = 0) {
  544. $list = $this->find ( array (
  545. 'select' => 'sid,username,cid,departmentID,category,qq,phone,telephone',
  546. 'asc' => 'sid',
  547. 'where' => "cid= '" . $cid . "'",
  548. 'asArray' => TRUE
  549. ) );
  550. return $list;
  551. }
  552. }
  553. ?>