workModel.php 6.1 KB

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