staff.php 7.8 KB

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