workModel.php 6.0 KB

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