gongModel.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <?php
  2. class flow_gongClassModel extends flowModel
  3. {
  4. private $readunarr = array();//未读人员
  5. private $logobj;
  6. public function initModel()
  7. {
  8. $this->logobj = m('log');
  9. }
  10. protected function flowchangedata(){
  11. $cont = c('html')->replace($this->rs['content']);
  12. $fm = $this->rs['fengmian'];
  13. if(!isempt($fm)){
  14. $cont='<div align="center"><img style="max-width:100%" src="'.$this->rock->gethttppath($fm).'"></div>'.$cont.'';
  15. }
  16. $url = $this->rs['url'];
  17. if(!isempt($url))$cont.='<div><a href="'.$url.'">打开相应地址&gt;&gt;</a></div>';
  18. $this->rs['content'] = $cont;
  19. }
  20. public function flowrsreplace($rs, $lx=0)
  21. {
  22. $mintou = (int)arrvalue($rs, 'mintou','0');
  23. if($lx==2){
  24. $zt = $this->logobj->isread($this->mtable, $rs['id'], $this->adminid);
  25. if($zt>0)$rs['ishui']=1;
  26. }
  27. if($lx==1){
  28. $receid = $rs['receid'];
  29. if(isempt($receid))$receid='all';
  30. $barr = m('log')->getreadshu($this->mtable, $rs['id'],$receid , $rs['optdt'], $this->adminmodel);
  31. foreach($barr as $k=>$v)$rs[$k]=$v;
  32. $this->readunarr = $barr['wduarr'];
  33. }
  34. if($mintou>0){
  35. $rs['title'] .='(投票)';
  36. }
  37. return $rs;
  38. }
  39. protected function flowsubmit($na, $sm)
  40. {
  41. if($this->rs['status']==1)$this->tisongtodo();
  42. }
  43. //移动端列表
  44. private $ydarr = false;
  45. public function flowrsreplace_we($row, $rs)
  46. {
  47. if(!isempt($rs['fengmian']))$row['picurl'] = $rs['fengmian'];
  48. if($this->ydarr===false)$this->ydarr = explode(',', m('log')->getread('infor', $this->adminid));
  49. if(!in_array($rs['id'], $this->ydarr)){
  50. $row['statustext'] = '未读';
  51. $row['statuscolor'] = '#ED5A5A';
  52. }else{
  53. $row['ishui'] = 1;
  54. }
  55. return $row;
  56. }
  57. public function flowwesearchdata($lx)
  58. {
  59. if($lx==1)return $this->option->getselectdata('gongtype', true);
  60. return array(
  61. 'typename' => '所有通知',
  62. 'searchmsg' => '通知标题/分类',
  63. );
  64. }
  65. //审核完成后发通知
  66. protected function flowcheckfinsh($zt)
  67. {
  68. if($zt==1)$this->tisongtodo();
  69. }
  70. public function getreceids($receid, $whe='')
  71. {
  72. $receid = $this->adminmodel->gjoin($receid,'ud','where');
  73. if($receid=='' || $receid=='all'){
  74. $where = '';
  75. }else{
  76. $where = 'and id>0 and ('.$receid.')';
  77. }
  78. $ids = '';
  79. $rows = $this->adminmodel->getall('`status`=1 '.$where.' '.$whe.'','id');
  80. foreach($rows as $k=>$rs)$ids.=',u'.$rs['id'].'';
  81. if($ids!='')$ids = substr($ids, 1);
  82. return $ids;
  83. }
  84. //发送推送通知
  85. private function tisongtodo()
  86. {
  87. //还没到展示时间就不发送提醒
  88. $zstart= arrvalue($this->rs, 'zstart');
  89. if(!isempt($zstart) && $zstart>$this->rock->date)return;
  90. $h = c('html');
  91. $cont = $h->htmlremove($this->rs['content']);
  92. $cont = $h->substrstr($cont,0, 40);
  93. if(strlen($cont)>41)$cont.='...';
  94. if(isempt($cont))$cont = $this->rs['title']; //为空时
  95. $this->push($this->rs['receid'], '通知公告', $cont, $this->rs['title'],1);
  96. //添加短信提醒,短信提醒
  97. if(arrvalue($this->rs,'issms')=='1'){
  98. $receid = $this->rs['receid'];//接收人ID,可以为部门合聚,如d2,u1(必须)
  99. if(isempt($receid))$receid = 'all'; //为空就是全部人
  100. $qiannum= ''; //【系统→短信管理→短信签名】下获取,如没有自己的签名默认【信呼OA】
  101. $tplnum = m('option')->getval('gongsmstpl', 'gongsms');//到【数据选项→行政选项】下设置通知短信模版编号
  102. $params = array(
  103. 'title' => $this->rs['title'],
  104. 'typename' => $this->rs['typename'],
  105. );
  106. $url = $this->getxiangurlx();//详情连接地址(选填),短信模版有url就需要填写
  107. c('xinhuapi')->sendsms($receid, $qiannum, $tplnum, $params, $url);
  108. }
  109. }
  110. protected function flowgetoptmenu($opt)
  111. {
  112. $to = m('log')->isread($this->mtable, $this->id);
  113. return $to<=0;
  114. }
  115. protected function flowoptmenu($ors, $crs)
  116. {
  117. $table = $this->mtable;
  118. $mid = $this->id;
  119. $uid = $this->adminid;
  120. $lx = $ors['num'];
  121. $log = m('log');
  122. if($lx=='yd'){
  123. $log->addread($table, $mid, $uid);
  124. }
  125. if($lx=='allyd'){
  126. $ydid = $log->getread($table, $uid);
  127. $where = "id not in($ydid)";
  128. $meswh = m('admin')->getjoinstr('receid', $uid);
  129. $where .= $meswh;
  130. $rows = m($table)->getrows($where,'id');
  131. foreach($rows as $k=>$rs)$log->addread($table, $rs['id'], $uid);
  132. }
  133. }
  134. protected function flowbillwhere($uid, $lx)
  135. {
  136. $key = $this->rock->post('key');
  137. $typeid = (int)$this->rock->post('typeid','0');
  138. $keywere= '';
  139. $whyere = '';
  140. if(!isempt($key))$keywere.=" and (`title` like '%$key%' or `typename`='$key')";
  141. //我和我未读
  142. if($lx=='my' || $lx=='wexx'){
  143. $whyere= "and (`zstart` is null or `zstart`<='{$this->rock->date}')";
  144. $whyere.= " and (`zsend` is null or `zsend`>='{$this->rock->date}')";
  145. $wdate = $this->adminmodel->getmou('workdate', $uid);
  146. if(!isempt($wdate))$whyere.=" and `indate`>='$wdate'";
  147. }
  148. if($typeid>0){
  149. $typename=$this->option->getmou('name', $typeid);
  150. $whyere.=" and `typename`='$typename'";
  151. }
  152. return array(
  153. 'order' => '`istop` desc,`optdt` desc',
  154. 'keywere' => $keywere,
  155. 'where' => $whyere,
  156. 'fields' => 'id,typename,optdt,title,optname,zuozhe,indate,recename,fengmian,mintou,`status`,`istop`,`appxs`,`comid`'
  157. );
  158. }
  159. //显示投票
  160. protected function flowdatalog($arr)
  161. {
  162. $istoupiao = 0;
  163. $mintou = (int)arrvalue($this->rs, 'mintou','0');
  164. $maxtou = (int)arrvalue($this->rs, 'maxtou','0');
  165. $status = (int)arrvalue($this->rs, 'status','0');
  166. $touarr = array();
  167. $logarr = array();
  168. if($mintou>0){
  169. $istoupiao = 4;
  170. $toutype = 0;//不需要投票,1已投票,2未投票
  171. $receid = $this->rs['receid'];
  172. if(isempt($receid)){
  173. $istoupiao = 1;
  174. }else{
  175. $bo = $this->adminmodel->containjoin($receid, $this->adminid);
  176. if($bo)$istoupiao = 1;
  177. }
  178. $zongps = 0;
  179. $touitems = m('infors')->getall('mid='.$this->id.'','*','`sort`');
  180. foreach($touitems as $k=>$rs){
  181. $zongps+=floatval($rs['touci']);
  182. $touitems[$k]['bili'] = 0;
  183. }
  184. if($zongps>0)foreach($touitems as $k=>$rs){
  185. $touitems[$k]['bili'] = $this->rock->number(floatval($rs['touci'])/$zongps * 100);
  186. }
  187. $touarr['touitems'] = $touitems;
  188. if($istoupiao==1){
  189. if($this->rs['startdt']>$this->rock->now)$istoupiao = 2; //未开始
  190. if($this->rs['enddt']<$this->rock->now)$istoupiao = 3; //结束
  191. }
  192. $touarr['type'] = ($mintou==1 && $maxtou==1)? 'radio': 'checkbox';
  193. //判断我是否投票了
  194. if($istoupiao==1 && $status==1){
  195. $towheer = $this->mwhere." and `name`='投票' and `checkid`='$this->adminid'";
  196. if($this->flogmodel->rows($towheer)>0){
  197. $toutype = 1;
  198. $istoupiao = 5;
  199. }else{
  200. $toutype = 2; //未投票
  201. }
  202. }
  203. $touarr['toutype'] = $toutype;
  204. //判断是否可以显示结果
  205. $showtou = 0;
  206. if($istoupiao!=2 && $status==1 && ($toutype==1 || $toutype==0))$showtou = 1;
  207. if($showtou==0){
  208. foreach($arr['logarr'] as $k1=>$rs1){
  209. if($rs1['actname']!='投票')$logarr[] = $rs1;
  210. }
  211. }
  212. $touarr['showtou'] = $showtou;
  213. $touarr['mintou'] = $mintou;
  214. $touarr['maxtou'] = $maxtou;
  215. }
  216. $toupiaoarrr = explode(',',',<font color=blue>投票进行中</font>,<font color=#ff6600>未开始</font>,<font color=#888888>已结束</font>,<font color=#888888>你不在投票对象中</font>,<font color=green>已投票过了</font>');
  217. $arr['istoupiao'] = $istoupiao; //投票状态0不能,1可以,2未开始,3结束 4你不需要投票
  218. $arr['toupiaostatus'] = $toupiaoarrr[$istoupiao];
  219. $arr['title'] = '';
  220. $arr['touarr'] = $touarr;
  221. if($logarr)$arr['logarr'] = $logarr;
  222. $arr['readunarr'] = $this->readunarr;//读取未查阅
  223. return $arr;
  224. }
  225. }
粤ICP备19079148号