staff.php 10 KB

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