staff.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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 $_table = 'CLD_staff';
  69. public $_primarykey = 'sid';
  70. public $_fields = array (
  71. 'IDcards',
  72. 'IDcardsImgA',
  73. 'IDcardsImgB',
  74. 'certificate',
  75. 'diploma',
  76. 'professionalTitle',
  77. 'sid',
  78. 'username',
  79. 'staffManage',
  80. 'birthday',
  81. 'position',
  82. 'passwork',
  83. 'isadmin',
  84. 'cid',
  85. 'othercid',
  86. 'appDate',
  87. 'category',
  88. 'othercategory',
  89. 'gender',
  90. 'qq',
  91. 'phone',
  92. 'telephone',
  93. 'email',
  94. 'avatar',
  95. 'hiredate',
  96. 'hireBiasDate',
  97. 'wxid',
  98. 'nature',
  99. 'remittanceName',
  100. 'bankName',
  101. 'bankNumber',
  102. 'remittanceBankType',
  103. 'coupletNumber',
  104. 'did',
  105. 'jobNumber',
  106. 'baseWage',
  107. 'postWage',
  108. 'achievementBonus',
  109. 'pendingApprovals',
  110. 'processApprovals',
  111. 'processCC',
  112. 'pendingApprovalsLeave',
  113. 'processApprovalsLeave',
  114. 'processLeaveCC',
  115. 'staffManageLeave',
  116. 'InductionDate',
  117. 'pendStatus',
  118. 'wecat',
  119. 'updateDate',
  120. 'dimissionReason',
  121. 'salaryCard',
  122. 'salaryBank',
  123. 'qualifications',
  124. 'marriage',
  125. 'living',
  126. 'nativePlace',
  127. 'emergencyContacts',
  128. 'practiceDate',
  129. 'probationaryDate',
  130. 'regularsDate',
  131. 'dimissionDate',
  132. 'seniorityFormula',
  133. 'cldAccess',
  134. 'didName'
  135. );
  136. public function checkUser($uid, $passwork) {
  137. return $this->find ( array (
  138. 'select' => 'position,birthday,sid,username,isadmin,cid,othercid,category,othercategory,gender,qq,phone,telephone,email,avatar,hiredate,nature',
  139. 'where' => "username= '" . $uid . "' and passwork = '" . md5 ( $passwork ) . "'",
  140. 'asArray' => TRUE
  141. ) );
  142. }
  143. public function getStaffByName($username = '') {
  144. $detail=$this->getOne ( array (
  145. 'asc' => 'sid',
  146. 'where' => "username= '" . $username . "'",
  147. 'asArray' => TRUE
  148. ) );
  149. Doo::loadClass ( 'XDeode' );
  150. $XDeode = new XDeode ( 5 );
  151. if (!empty($detail))
  152. $detail['sidKey'] = $XDeode->encode ( $detail ['sid'] );
  153. return $detail;
  154. }
  155. /**
  156. * @return string
  157. */
  158. public function getStaff($admin=false) {
  159. Doo::loadClass ( 'XDeode' );
  160. $XDeode = new XDeode ( 5 );
  161. Doo::loadModel ( 'department' );
  162. $department = new department ();
  163. $condition = array (
  164. 'desc' => 'jobNumber',
  165. 'asArray' => TRUE
  166. );
  167. if ($admin)
  168. $condition += array (
  169. 'where' => "username != 'admin'",
  170. );
  171. $list = $this->find ( $condition);
  172. foreach ( $list as $key => $value ) {
  173. $list [$key] ['departmentName'] ='';
  174. if($value['departmentID']!=0){
  175. $list [$key] ['departmentName'] =$department->getDepartmentByDid($value['departmentID']);
  176. }
  177. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  178. $list [$key] ['cidKey'] = $XDeode->encode ( $value ['cid'] );
  179. $list [$key] ['didKey'] = '';
  180. if (!empty($value ['departmentID']))
  181. $list [$key] ['didKey'] = $XDeode->encode ( $value ['departmentID'] );
  182. }
  183. return $list;
  184. }
  185. /**
  186. * 根据条件获得查询内容
  187. * @param string $con
  188. * @return string
  189. */
  190. public function getStaffByCondition($con=''){
  191. if ( empty ( $con ))
  192. return array ();
  193. Doo::loadClass ( 'XDeode' );
  194. $XDeode = new XDeode ( 5 );
  195. Doo::loadModel ( 'department' );
  196. $department = new department ();
  197. $list = $this->find ( array (
  198. 'where' => $con,
  199. 'desc' => 'jobNumber',
  200. 'asArray' => TRUE
  201. ) );
  202. foreach ( $list as $key => $value ) {
  203. $list [$key] ['departmentName'] ='';
  204. if($value['departmentID']!=0){
  205. $list [$key] ['departmentName'] =$department->getDepartmentByDid($value['departmentID']);
  206. }
  207. $list [$key] ['didArray']=array();
  208. if (!empty($value['did']))
  209. $list [$key] ['didArray']=explode(',', $value['did']);
  210. $list [$key] ['cldAccessArray'] = json_decode($value['cldAccess']);
  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. }
  217. return $list;
  218. }
  219. public function getStaffInCid($cid = '') {
  220. if (empty ( $cid ))
  221. return array ();
  222. $list = $this->find ( array (
  223. 'asc' => 'sid',
  224. 'where' => "cid in(" . $cid . ")",
  225. 'asArray' => TRUE
  226. ) );
  227. Doo::loadClass ( 'XDeode' );
  228. $XDeode = new XDeode ( 5 );
  229. foreach ( $list as $key => $value ) {
  230. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  231. }
  232. return $list;
  233. }
  234. public function getStaffByCid($cid = 0) {
  235. $list = $this->find ( array (
  236. 'asc' => 'sid',
  237. 'where' => "cid= '" . $cid . "'",
  238. 'asArray' => TRUE
  239. ) );
  240. Doo::loadClass ( 'XDeode' );
  241. $XDeode = new XDeode ( 5 );
  242. foreach ( $list as $key => $value ) {
  243. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  244. }
  245. return $list;
  246. }
  247. /**
  248. * 获得审批中员工
  249. */
  250. public function getStaffByApplied($sid=0){
  251. $list = $this->find ( array (
  252. 'asc' => 'sid',
  253. 'where' => "(pendStatus= '2' or pendStatus='3') and (pendingApprovals ='" . $sid . "' or pendingApprovalsLeave='" . $sid . "')",
  254. 'asArray' => TRUE
  255. ) );
  256. Doo::loadClass ( 'XDeode' );
  257. $XDeode = new XDeode ( 5 );
  258. foreach ( $list as $key => $value ) {
  259. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  260. }
  261. return $list;
  262. }
  263. /**
  264. * 获得最近审批通过的员工
  265. * @return string
  266. */
  267. public function getStaffByApprovals(){
  268. $list = $this->find ( array (
  269. 'asc' => 'InductionDate',
  270. 'where' => "username!= 'admin' and pendStatus=0 and InductionDate!=0",
  271. 'limit' => 10,
  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 getStaffByUpdateDate(){
  285. $list = $this->find ( array (
  286. 'asc' => 'updateDate',
  287. 'where' => "username!= 'admin'",
  288. 'limit' => 10,
  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 getUserById($sid = 0) {
  299. $list =$this->find ( array (
  300. 'asc' => 'sid',
  301. 'where' => "sid= '" . $sid . "'",
  302. 'asArray' => TRUE
  303. ) );
  304. Doo::loadClass ( 'XDeode' );
  305. $XDeode = new XDeode ( 5 );
  306. foreach ( $list as $key => $value ) {
  307. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  308. }
  309. return $list;
  310. }
  311. public function getUserByIdList($puid) {
  312. Doo::loadClass ( 'XDeode' );
  313. $XDeode = new XDeode ( 5 );
  314. $puid = $XDeode->decode ( $puid );
  315. $list=$this->find ( array (
  316. 'where' => "sid= '" . $puid . "'",
  317. 'asArray' => TRUE
  318. ) );
  319. foreach ($list as $key=>$value){
  320. $list[$key]['sidKey']=$XDeode->encode ( $value ['sid'] );
  321. }
  322. return $list;
  323. }
  324. /**
  325. * 根据参数字段更新相应字段(主键ID必须传)
  326. * @param array $item 相关需要更新的字段信息
  327. * @return number 返回员工ID
  328. */
  329. public function setStaffByCondition($item = array()) {
  330. $lid = 0;
  331. if (is_array ( $item ) && ! empty ( $item )) {
  332. foreach ( $item as $key => $value ) {
  333. $this->$key = $value;
  334. }
  335. $lid = $this->update ();
  336. }
  337. return $lid;
  338. }
  339. /**
  340. *
  341. * @param number $nature
  342. */
  343. public function getStaffJobNumberByNature($nature=1){
  344. $detail=$this->getOne ( array (
  345. 'where' => "nature= '" . $nature . "'",
  346. 'desc' => 'jobNumber',
  347. 'asArray' => TRUE
  348. ) );
  349. return $detail;
  350. }
  351. /**
  352. *
  353. * @param number $nature
  354. */
  355. public function getStaffJobNumberByInformal(){
  356. $detail=$this->getOne ( array (
  357. 'where' => "nature= '2' or nature ='3'",
  358. 'desc' => 'jobNumber',
  359. 'asArray' => TRUE
  360. ) );
  361. return $detail;
  362. }
  363. /**
  364. * 根据用户ID获取相关信息
  365. * @param number $sid 用户ID
  366. */
  367. public function getStaffBySid($sid = 0) {
  368. Doo::loadClass ( 'XDeode' );
  369. $XDeode = new XDeode ( 5 );
  370. if (!is_numeric($sid)){
  371. $sid = $XDeode->decode ( $sid );
  372. }
  373. $detail = array ();
  374. if (! empty ( $sid )){
  375. $detail = $this->getOne ( array (
  376. 'where' => "sid= '" . $sid . "'",
  377. 'asArray' => TRUE
  378. ) );
  379. Doo::loadModel ( 'department' );
  380. $department = new department ();
  381. $detail ['department'] =$department->getDepartmentByDid($detail['departmentID']);
  382. $d1 = strtotime($detail['hiredate']);//过去的某天,你来设定
  383. $d2 = 1 + ceil((time()-$d1)/60/60/24);
  384. $detail['workforce']=$d2;
  385. $d1 = strtotime($detail['dimissionDate']);//离职到今天
  386. $d2 = 1 + ceil((time()-$d1)/60/60/24);
  387. $detail['workforceDimission']=$d2;
  388. $detail ['cldAccessArray'] = json_decode($detail['cldAccess']);
  389. $detail['sidKey']=$XDeode->encode ( $detail ['sid'] );
  390. }
  391. return $detail;
  392. }
  393. public function getStaffByWxid($wxid = '') {
  394. // echo "wxid in ( " . $wxid . ")";
  395. if (empty ( $wxid ))
  396. return array ();
  397. return $this->find ( array (
  398. 'select' => 'sid,wxid',
  399. 'where' => "wxid in ( " . $wxid . ")",
  400. 'asArray' => TRUE
  401. ) );
  402. }
  403. // 建筑获取办事处人员部分信息
  404. public function getStaffByCidOnBuilding($cid = 0) {
  405. $list = $this->find ( array (
  406. 'select' => 'sid,username,cid,departmentID,category,qq,phone,telephone',
  407. 'asc' => 'sid',
  408. 'where' => "cid= '" . $cid . "'",
  409. 'asArray' => TRUE
  410. ) );
  411. return $list;
  412. }
  413. }
  414. ?>