staff.php 9.7 KB

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