staff.php 9.4 KB

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