staff.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. Doo::loadCore ( 'db/DooModel' );
  3. class staff extends DooModel {
  4. public $sid;
  5. public $username;
  6. public $passwork;
  7. public $isadmin;
  8. public $cid;
  9. public $othercid;
  10. public $category;
  11. public $othercategory;
  12. public $gender;
  13. public $qq;
  14. public $phone;
  15. public $telephone;
  16. public $email;
  17. public $birthday;
  18. public $position;
  19. public $avatar;
  20. public $appDate;
  21. public $hiredate;
  22. public $wxid;
  23. public $nature;
  24. public $remittanceName;
  25. public $bankName;
  26. public $bankNumber;
  27. public $coupletNumber;
  28. public $remittanceBankType;
  29. public $did;
  30. public $didName;
  31. public $jobNumber;
  32. public $_table = 'CLD_staff';
  33. public $_primarykey = 'sid';
  34. public $_fields = array (
  35. 'sid',
  36. 'username',
  37. 'birthday',
  38. 'position',
  39. 'passwork',
  40. 'isadmin',
  41. 'cid',
  42. 'othercid',
  43. 'appDate',
  44. 'category',
  45. 'othercategory',
  46. 'gender',
  47. 'qq',
  48. 'phone',
  49. 'telephone',
  50. 'email',
  51. 'avatar',
  52. 'hiredate',
  53. 'wxid',
  54. 'nature',
  55. 'remittanceName',
  56. 'bankName',
  57. 'bankNumber',
  58. 'remittanceBankType',
  59. 'coupletNumber',
  60. 'did',
  61. 'jobNumber',
  62. 'didName'
  63. );
  64. public function checkUser($uid, $passwork) {
  65. return $this->find ( array (
  66. 'select' => 'position,birthday,sid,username,isadmin,cid,othercid,category,othercategory,gender,qq,phone,telephone,email,avatar,hiredate,nature',
  67. 'where' => "username= '" . $uid . "' and passwork = '" . md5 ( $passwork ) . "'",
  68. 'asArray' => TRUE
  69. ) );
  70. }
  71. public function getStaffByName($username = '') {
  72. return $this->getOne ( array (
  73. 'asc' => 'sid',
  74. 'where' => "username= '" . $username . "'",
  75. 'asArray' => TRUE
  76. ) );
  77. }
  78. /**
  79. *
  80. * @return string
  81. */
  82. public function getStaff($admin=false) {
  83. Doo::loadClass ( 'XDeode' );
  84. $XDeode = new XDeode ( 5 );
  85. Doo::loadModel ( 'department' );
  86. $department = new department ();
  87. $condition = array (
  88. 'asc' => 'jobNumber',
  89. 'asArray' => TRUE
  90. );
  91. if ($admin)
  92. $condition += array (
  93. 'where' => "isadmin = 0",
  94. );
  95. $list = $this->find ( $condition);
  96. foreach ( $list as $key => $value ) {
  97. $list [$key] ['departmentName'] ='';
  98. if($value['departmentID']!=0){
  99. $list [$key] ['departmentName'] =$department->getDepartmentByDid($value['departmentID']);
  100. }
  101. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  102. }
  103. return $list;
  104. }
  105. public function getStaffInCid($cid = '') {
  106. if (empty ( $cid ))
  107. return array ();
  108. $list = $this->find ( array (
  109. 'asc' => 'sid',
  110. 'where' => "cid in(" . $cid . ")",
  111. 'asArray' => TRUE
  112. ) );
  113. Doo::loadClass ( 'XDeode' );
  114. $XDeode = new XDeode ( 5 );
  115. foreach ( $list as $key => $value ) {
  116. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  117. }
  118. return $list;
  119. }
  120. public function getStaffByCid($cid = 0) {
  121. $list = $this->find ( array (
  122. 'asc' => 'sid',
  123. 'where' => "cid= '" . $cid . "'",
  124. 'asArray' => TRUE
  125. ) );
  126. Doo::loadClass ( 'XDeode' );
  127. $XDeode = new XDeode ( 5 );
  128. foreach ( $list as $key => $value ) {
  129. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  130. }
  131. return $list;
  132. }
  133. public function getUserById($sid = 0) {
  134. $list =$this->find ( array (
  135. 'asc' => 'sid',
  136. 'where' => "sid= '" . $sid . "'",
  137. 'asArray' => TRUE
  138. ) );
  139. Doo::loadClass ( 'XDeode' );
  140. $XDeode = new XDeode ( 5 );
  141. foreach ( $list as $key => $value ) {
  142. $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
  143. }
  144. return $list;
  145. }
  146. public function getUserByIdList($puid) {
  147. Doo::loadClass ( 'XDeode' );
  148. $XDeode = new XDeode ( 5 );
  149. $puid = $XDeode->decode ( $puid );
  150. $list=$this->find ( array (
  151. 'where' => "sid= '" . $puid . "'",
  152. 'asArray' => TRUE
  153. ) );
  154. foreach ($list as $key=>$value){
  155. $list[$key]['sidKey']=$XDeode->encode ( $value ['sid'] );
  156. }
  157. return $list;
  158. }
  159. /**
  160. *
  161. * @param number $nature
  162. */
  163. public function getStaffJobNumberByNature($nature=1){
  164. $detail=$this->getOne ( array (
  165. 'where' => "nature= '" . $nature . "'",
  166. 'desc' => 'jobNumber',
  167. 'asArray' => TRUE
  168. ) );
  169. return $detail;
  170. }
  171. /**
  172. * 根据用户ID获取相关信息
  173. * @param number $sid 用户ID
  174. */
  175. public function getStaffBySid($sid = 0) {
  176. $detail = array ();
  177. if (! empty ( $sid ))
  178. $detail = $this->getOne ( array (
  179. 'where' => "sid= '" . $sid . "'",
  180. 'asArray' => TRUE
  181. ) );
  182. return $detail;
  183. }
  184. public function getStaffByWxid($wxid = '') {
  185. // echo "wxid in ( " . $wxid . ")";
  186. if (empty ( $wxid ))
  187. return array ();
  188. return $this->find ( array (
  189. 'select' => 'sid,wxid',
  190. 'where' => "wxid in ( " . $wxid . ")",
  191. 'asArray' => TRUE
  192. ) );
  193. }
  194. }
  195. ?>