gongModel.php 7.7 KB

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