1
0

userinfoModel.php 6.1 KB

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