userinfoModel.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?php
  2. class flow_userinfoClassModel extends flowModel
  3. {
  4. public $uidfields = 'id';
  5. protected $flowviewufieds = 'id';
  6. protected $flowcompanyidfieds = 'companyid';
  7. public $statearr,$statearrs,$birtypearr;
  8. public function flowsearchfields()
  9. {
  10. $arr[] = array('name'=>'部门/用户...','fields'=>'id');
  11. return $arr;
  12. }
  13. public function initModel()
  14. {
  15. //读取状态
  16. $this->statearr = array();
  17. $this->statearrs = array();
  18. $ztarrs = m('option')->getmnum('userstate');
  19. if(!$ztarrs){
  20. $ztarrs[] = array('value'=>0,'name'=>'试用期');
  21. $ztarrs[] = array('value'=>1,'name'=>'正式');
  22. $ztarrs[] = array('value'=>2,'name'=>'实习生');
  23. $ztarrs[] = array('value'=>3,'name'=>'兼职');
  24. $ztarrs[] = array('value'=>4,'name'=>'临时工');
  25. $ztarrs[] = array('value'=>5,'name'=>'离职');
  26. }
  27. foreach($ztarrs as $k=>$rs){
  28. $this->statearr[$rs['value']] = $rs['name'];
  29. $this->statearrs[] = array('id'=> $rs['value'], 'name'=>$rs['name']);
  30. }
  31. $this->birtypearr = explode(',','阳历,农历');
  32. //$this->calendar = c('calendar');去掉了,没用
  33. }
  34. public function getstatusarr()
  35. {
  36. $barr = array();
  37. foreach($this->statearr as $k=>$v){
  38. $barr[$k] = array($v,'');
  39. }
  40. return $barr;
  41. }
  42. private function getdwname($rs)
  43. {
  44. $dwid1 = arrvalue($rs,'companyid','0');
  45. $dwid = arrvalue($rs,'dwid','0');
  46. $dwid .= ','.$dwid1.'';
  47. $temp_dwid = '';
  48. if(!isempt($dwid)){
  49. $dwarr = m('company')->getall('`id` in('.$dwid.')');
  50. foreach($dwarr as $k1=>$rs1)$temp_dwid.=','.$rs1['name'].'';
  51. if($temp_dwid!='')$temp_dwid = substr($temp_dwid, 1);
  52. }
  53. return $temp_dwid;
  54. }
  55. public function flowrsreplace($rs, $lx=0)
  56. {
  57. if($rs['state']==5)$rs['ishui']=1;
  58. $rs['stateval'] = $rs['state'];
  59. $rs['state'] = $this->getuserstate($rs['state']);
  60. $rs['shengri'] = '';
  61. if(!isempt($rs['birthday'])){
  62. if($rs['birtype']==0){
  63. //$rs['shengri'] = $rs['birthday'];
  64. }else{
  65. //$days = $this->calendar->daytocal($rs['birthday']);
  66. //$rs['shengri'] = ''.$days['year'].'年农历'.$days['month'].'月'.$days['day'].'';
  67. }
  68. }
  69. $rs['birtype'] = $this->birtypearr[$rs['birtype']];
  70. if($lx==1){
  71. $rs['companyid'] = $this->getdwname($rs);
  72. }
  73. if(getconfig('systype')=='demo')$rs['mobile']='';
  74. //导出处理
  75. if($this->daochubo){
  76. //if(isset($rs['mobile']))$rs['mobile'] = '&nbsp;'.$rs['mobile'];
  77. //if(isset($rs['idnum']))$rs['idnum'] = '&nbsp;'.$rs['idnum'];
  78. //if(isset($rs['banknum']))$rs['banknum'] = '&nbsp;'.$rs['banknum'];
  79. }
  80. return $rs;
  81. }
  82. //编辑时候替换
  83. protected function flowrsreplaceedit($rs)
  84. {
  85. if(getconfig('systype')=='demo')$rs['mobile'] = '';
  86. return $rs;
  87. }
  88. public function getuserstate($zt)
  89. {
  90. return $this->rock->arrvalue($this->statearr,$zt,'未知');
  91. }
  92. protected function flowbillwhere($uid, $lx)
  93. {
  94. $fields = 'a.id,a.name,a.deptname,a.ranking,a.state,a.tel,a.sex,a.mobile,a.workdate,a.jiguan,a.minzu,a.xueli,a.email,a.syenddt,a.quitdt,a.positivedt,a.birtype,a.birthday,a.num,b.name as companyid';
  95. if($this->daochubo)$fields='a.*,b.name as companyid';//导出的
  96. return array(
  97. 'ztfields' => 'state',
  98. 'order' => 'a.id',
  99. 'table' => '`[Q]userinfo` a left join `[Q]company` b on a.companyid=b.id',
  100. 'fields' => $fields,
  101. 'asqom' => 'a.',
  102. 'orlikefields' => 'b.name'
  103. );
  104. }
  105. /**
  106. * 员工生日提醒
  107. */
  108. public function birthdaytodo()
  109. {
  110. $dt = date('m-d');
  111. //$cala = $this->calendar->toCalday($this->rock->date);
  112. $nongli = '';
  113. $rows = $this->db->getall("select a.`birthday`,b.`id`,b.`name` from `[Q]".$this->mtable."` a left join `[Q]admin` b on a.`id`=b.`id` where b.`status`=1 and a.`state`<>5 and a.`birthday` like '%".$dt."' ");
  114. //是否生日短信提醒
  115. $smsnum = $this->option->getval('smsbirthday');
  116. $dxobj = c('xinhuapi');
  117. $dt = date('Y年m月d日');
  118. foreach($rows as $k=>$rs){
  119. $dtnong = '';
  120. $cont = '今天是'.$dt.',是你的生日,我们在这里祝你生日快乐。';
  121. $this->push($rs['id'],'', $cont, '生日祝福');
  122. if(!isempt($smsnum)){
  123. $smarr = explode(',', $smsnum);
  124. $tpl = $smarr[0];
  125. $qmv = arrvalue($smarr, 1, ''); //签名
  126. $dxobj->sendsms($rs['id'], $qmv, $tpl, array(
  127. 'name' => $rs['name'],
  128. 'dt' => $dt,
  129. 'dtnong'=> $dtnong
  130. ));
  131. }
  132. }
  133. }
  134. //导入数据的测试显示
  135. public function flowdaorutestdata()
  136. {
  137. return array(
  138. 'name' => '张三',
  139. 'state' => '正式',
  140. 'mobile' => '15812345678',
  141. 'ranking' => '程序员',
  142. 'idnum' => '1001111111',
  143. 'housedizhi'=> '福建',
  144. 'nowdizhi' => '福建',
  145. 'hunyin' => '未婚',
  146. 'birthday' => '2017-01-17',
  147. 'xueli' => '博士后',
  148. 'minzu' => '汉族',
  149. 'email' => 'zhangsan@rockoa.com',
  150. 'workdate' => '2017-01-17',
  151. 'syenddt' => '2017-03-17',
  152. 'positivedt'=> '2017-04-01',
  153. 'jiguan' => '福建',
  154. );
  155. }
  156. //导入之前判断
  157. public function flowdaorubefore($rows)
  158. {
  159. $inarr = array();
  160. $dba = m('admin');
  161. //根据手机号关联用户
  162. foreach($rows as $k=>$rs){
  163. $arr = $rs;
  164. if(!isset($rs['mobile']))return '手机号必须开启导入';
  165. $mobile = $rs['mobile'];
  166. $urs = $this->adminmodel->getone("`mobile`='$mobile'");
  167. if(!$urs)return '行'.($k+1).'的手机号('.$mobile.')找不对应用户,请先添加用户';
  168. $arr['id'] = $urs['id'];
  169. $arr['ranking'] = $urs['ranking'];
  170. $arr['deptname'] = $urs['deptname'];
  171. if(isset($rs['state'])){
  172. $state = $rs['state'];
  173. $zt = 0; //默认人员状态
  174. foreach($this->statearrs as $k1=>$rs1){
  175. if($rs1['name']==$state){
  176. $zt = $rs1['id'];
  177. break;
  178. }
  179. }
  180. $arr['state'] = $zt;
  181. }
  182. //更新入职日期
  183. $workdate = arrvalue($arr, 'workdate');
  184. if(!isempt($workdate)){
  185. $dba->update("`workdate`='$workdate'", $arr['id']);
  186. }
  187. $inarr[] = $arr;
  188. }
  189. return $inarr;
  190. }
  191. //导入之后
  192. public function flowdaoruafter()
  193. {
  194. $this->adminmodel->updateinfo();
  195. }
  196. }
粤ICP备19079148号