staff.php 10 KB

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