staff.php 14 KB

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