workModel.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. class flow_workClassModel extends flowModel
  3. {
  4. private $absfile = false;
  5. private $statearr;
  6. private $updatexm= false;
  7. public function initModel()
  8. {
  9. $this->statearr = c('array')->strtoarray('待执行|blue,已完成|green,执行中|#ff6600,终止|#888888,验证未通过|#9D4FF7');
  10. }
  11. //自定义审核人读取
  12. protected function flowcheckname($num){
  13. $sid = '';
  14. $sna = '';
  15. if($num=='run'){
  16. $sid = $this->rs['distid'];
  17. $sna = $this->rs['dist'];
  18. }
  19. return array($sid, $sna);
  20. }
  21. //转办时要更新对应的执行人员
  22. protected function flowcheckbefore(){
  23. $up = array();
  24. if($this->checkiszhuanyi==1){
  25. $up['dist'] = $this->rs['syszb_name'];
  26. $up['distid'] = $this->rs['syszb_nameid'];
  27. $up['status'] = 3; //待执行状态
  28. }
  29. if($up)$up['update'] = $up;
  30. return $up;
  31. }
  32. public function flowrsreplace($rs, $slx=0){
  33. $zts = $rs['status'];
  34. $str = $this->getstatus($rs,'','',1);
  35. if($slx>=1){
  36. $projectid = (int)$rs['projectid'];
  37. $rs['projectid'] = '';
  38. if($projectid>0){
  39. $prs = $this->db->getone('[Q]project', $projectid);
  40. if($prs){
  41. $rs['projectid']=''.$prs['title'].'('.$prs['progress'].'%)';
  42. }
  43. }
  44. }
  45. if(!isempt($rs['enddt']) && !in_array($zts,array(1,2,5))){
  46. if(strtotime($rs['enddt'])<time())$rs['explain'].='<font color=red>(已超期)</font>';
  47. }
  48. //$rs['status']= $str;
  49. if($rs['score']==0)$rs['score']='';
  50. if($rs['mark']==0)$rs['mark']='';
  51. if($slx==1){
  52. $zhuid = (int)arrvalue($rs,'zhuid','0');
  53. $nrs = arrvalue($rs,'file_content');
  54. if($zhuid>0 && isempt($nrs)){
  55. $rs['file_content'] = m('file')->getstr($this->mtable, $zhuid, 3);
  56. $this->absfile = true;
  57. }
  58. }
  59. return $rs;
  60. }
  61. protected function flowgetfields($lx)
  62. {
  63. if($this->absfile){
  64. return array('file_content'=>'关联文件');
  65. }
  66. }
  67. protected function flowchangedata(){
  68. $this->rs['stateid'] = $this->rs['state'];
  69. }
  70. protected function flowdatalog($arr)
  71. {
  72. $isaddlog = 0;
  73. $uid = $this->adminid;
  74. $ispingfen = 0;
  75. $distid = ','.$this->rs['distid'].',';
  76. $zt = $this->rs['stateid'];
  77. if($this->contain($distid, ','.$this->adminid.',') && ($zt==0||$zt==2)){
  78. $isaddlog = 1;
  79. }
  80. $arr['isaddlog'] = $isaddlog; //是否可以添加日志记录
  81. $arr['state'] = $this->rs['stateid'];
  82. //判断是否可以督导评分
  83. $where = $this->ddwhere($uid);
  84. if($this->rows("`id`='$this->id' and `status`=1 and `mark`=0 $where")==1){
  85. $ispingfen = 1;
  86. }
  87. $arr['ispingfen'] = $ispingfen; //是否可以评分
  88. $arr['score'] = $this->rs['score'];
  89. return $arr;
  90. }
  91. protected function flowsubmit($na, $sm)
  92. {
  93. //$this->push($this->rs['distid'], '', '[{type}]{title}');//提交给对应人提醒
  94. $this->push($this->rs['ddid'], '', '{optname}提交任务[{type}.{title}]分配给:{dist},需要你督导','任务督导');//提醒给督导人员
  95. $zt = 0;
  96. if(!isempt($this->rs['distid']))$zt = 3;//待执行的状态值
  97. $this->updatestatus($zt);
  98. if($this->updatexm)m('work')->updateproject($this->rs['projectid']);
  99. }
  100. protected function flowcheckfinsh($zt){
  101. if($this->updatexm)m('work')->updateproject($this->rs['projectid']);
  102. }
  103. protected function flowaddlog($a)
  104. {
  105. //提交报告时发送给创建人和督导人员
  106. if($a['name']=='进度报告'){
  107. $state = $a['status'];
  108. $arr['state'] = $state;
  109. $cont = ''.$this->adminname.'添加[{type}.{title}]的任务进度,说明:'.$a['explain'].'';
  110. if($state=='1')$cont='[{type}.{title}]任务'.$this->adminname.'已完成';
  111. $toid = $this->rs['optid'];
  112. $ddid = $this->rs['ddid'];
  113. if(!isempt($ddid))$toid.=','.$ddid.'';
  114. $this->push($toid, '任务', $cont);
  115. $this->update($arr, $this->id);
  116. }
  117. if($a['name']=='指派给' || $a['name']=='转发'){
  118. $cname = $this->rock->post('changename');
  119. $cnameid = $this->rock->post('changenameid');
  120. $state = '0';
  121. $arr['state'] = $state;
  122. $arr['distid'] = $cnameid;
  123. $arr['dist'] = $cname;
  124. $this->update($arr, $this->id);
  125. $this->push($cnameid, '任务', ''.$this->adminname.'指派任务[{type}.{title}]给你');
  126. }
  127. if($a['name'] == '任务评分'){
  128. $fenshu = (int)$this->rock->post('fenshu','0');
  129. $this->push($this->rs['distid'], '任务', ''.$this->adminname.'评分[{type}.{title}],分数('.$fenshu.')','任务评分');
  130. $this->update(array(
  131. 'mark' => $fenshu
  132. ), $this->id);
  133. }
  134. }
  135. private function ddwhere($uid)
  136. {
  137. $downid = m('admin')->getdown($uid, 1);
  138. $where = 'and `ddid`='.$uid.'';
  139. if($downid!='')$where = 'and (('.$uid.' in(`ddid`)) or (ifnull(`ddid`,\'0\')=\'0\' and `distid` in('.$downid.')) or (ifnull(`ddid`,\'0\')=\'0\' and `optid`='.$uid.'))';
  140. return $where;
  141. }
  142. protected function flowbillwhere($uid, $lx)
  143. {
  144. $where = '';
  145. $projcetid = (int)$this->rock->post('projcetid');
  146. if($projcetid>0)$where='and `projectid`='.$projcetid.'';
  147. return array(
  148. 'keywhere' => $where,
  149. 'order' => '`optdt` desc'
  150. );
  151. }
  152. /**
  153. * 提醒快过期的任务
  154. * $txsj 提前几天提醒
  155. */
  156. public function tododay($txsj = 1)
  157. {
  158. $dtobj= c('date');
  159. $dt = $this->rock->date;
  160. $rows = $this->getrows("`status` in(0,3,4) and ifnull(`distid`,'')<>'' and `enddt`>='$dt'");
  161. $arr = array();
  162. foreach($rows as $k=>$rs){
  163. $jg = $dtobj->datediff('d', $this->rock->date, $rs['enddt']);
  164. if($jg <= $txsj){
  165. $dista = explode(',', $rs['distid']);
  166. foreach($dista as $distid){
  167. if(!isset($arr[$distid]))$arr[$distid] = array();
  168. $tis = ''.$jg.'天后截止';
  169. if($jg == 0)$tis = '需今日完成';
  170. $arr[$distid][]= '['.$rs['type'].']'.$rs['title'].'('.$tis.');';
  171. }
  172. }
  173. }
  174. foreach($arr as $uid => $strarr){
  175. $this->flowweixinarr['url'] = $this->getwxurl();//设置微信提醒的详情链接
  176. $str = '';
  177. foreach($strarr as $k=>$str1){
  178. if($k>0)$str.="\n";
  179. $str.="".($k+1).".$str1";
  180. }
  181. if($str != '')$this->push($uid, '', $str, '任务到期提醒');
  182. }
  183. }
  184. //任务待办格式推送
  185. protected function flownexttodo($type)
  186. {
  187. if($type=='daiban'){
  188. return array(
  189. 'cont' => '标题:{title}\n创建人:{optname}\n任务类型:{type}\n等级:{grade}',
  190. 'title'=> '任务待处理'
  191. );
  192. }
  193. }
  194. }
粤ICP备19079148号