fworkAction.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <?php
  2. class fworkClassAction extends Action
  3. {
  4. public $atypess,$modeids;
  5. /**
  6. * 流程申请获取数组
  7. */
  8. public function getmodearrAjax()
  9. {
  10. $rows = m('mode')->getmoderows($this->adminid,'and islu=1');
  11. $row = array();
  12. $viewobj = m('view');
  13. foreach($rows as $k=>$rs){
  14. $lx = $rs['type'];
  15. if(!$viewobj->isadd($rs, $this->adminid))continue;
  16. if(!isset($row[$lx]))$row[$lx]=array();
  17. $row[$lx][] = $rs;
  18. }
  19. $this->returnjson(array('rows'=>$row));
  20. }
  21. /**
  22. * 单据查看获取数组
  23. */
  24. public function getmodesearcharrAjax()
  25. {
  26. $rows = m('mode')->getmoderows($this->adminid);
  27. $row = array();
  28. $mid = '0';
  29. foreach($rows as $k=>$rs){
  30. $path = ''.P.'/flow/page/rock_page_'.$rs['num'].'.php';
  31. if((!file_exists($path) && $rs['isscl']==1) || $rs['isscl']==0)continue;
  32. $lx = $rs['type'];
  33. $mid.=','.$rs['id'].'';
  34. $row[$lx][] = $rs;
  35. }
  36. if($mid!='0'){
  37. $where = m('admin')->getjoinstr('syrid', $this->adminid, 1);
  38. $wrows = m('flow_where')->getrows('`setid` in('.$mid.') and `status`=1 and `islb` and `num` is not null and ('.$where.') and `pnum` is null group by `setid`','`setid`,min(sort),`num`');
  39. $atypea = array();
  40. foreach($wrows as $k1=>$rs1){
  41. $nus = $rs1['setid'];
  42. if(!isset($atypea[$nus]))$atypea[$nus] = $rs1['num'];
  43. }
  44. foreach($row as $lx=>$rowaa){
  45. $nrowa = array();
  46. foreach($rowaa as $k2=>$rs2){
  47. $atype = $this->rock->arrvalue($atypea, $rs2['id']);
  48. $row[$lx][$k2]['atype'] = $atype;
  49. if($atype)$nrowa[] = $row[$lx][$k2];
  50. }
  51. $row[$lx] = $nrowa;
  52. }
  53. }
  54. $this->returnjson(array('rows'=>$row));
  55. }
  56. public function flowbillbefore($table)
  57. {
  58. $lx = $this->post('atype');
  59. $this->atypess = $lx;
  60. $dt = $this->post('dt1');
  61. $dt2 = $this->post('dt2');
  62. $key = $this->post('key');
  63. $zt = $this->post('zt');
  64. $modeid = (int)$this->post('modeid','0');
  65. $uid = $this->adminid;
  66. $where = 'and (a.`uid`='.$uid.' or a.`optid`='.$uid.')';
  67. //待办
  68. if($lx=='daib'){
  69. $where = 'and a.`isturn`=1 and a.`status` not in(1,2) and '.$this->rock->dbinstr('a.nowcheckid', $uid);
  70. }
  71. //我下属申请
  72. if($lx=='xia'){
  73. $where = 'and a.`isturn`=1 and '.$this->rock->dbinstr('b.superid', $uid);
  74. }
  75. //我参与
  76. if($lx=='jmy'){
  77. $where = 'and a.`isturn`=1 and '.$this->rock->dbinstr('a.allcheckid', $uid);
  78. }
  79. //未通过
  80. if($lx=='mywtg'){
  81. $where.=" and a.status=2";
  82. }
  83. //待提交
  84. if($lx=='daiturn'){
  85. $where.=" and a.`status` not in(5) and a.`isturn`=0 "; //未提交
  86. }
  87. //异常
  88. if($lx=='error'){
  89. $whers = m('flowbill')->errorwhere('a.');
  90. $where = ' and '.$whers.'';
  91. }
  92. //授权单据查看
  93. if($lx=='grantview'){
  94. $where =' and 1=2';
  95. if($modeid>0){
  96. $moders = m('flow_set')->getone($modeid);
  97. $where = m('view')->viewwhere($moders, $uid);
  98. }
  99. }
  100. $this->modeids = false;
  101. //抄送的
  102. if($lx=='chaosview'){
  103. $where =' and 1=2';
  104. $where1= $this->rock->dbinstr('csnameid', $uid);
  105. if($modeid>0)$where1.=' and `modeid`='.$modeid.'';
  106. $crows = $this->db->getall("select * from `[Q]flow_chao` where $where1");
  107. $this->modeids = '0';
  108. if($crows){
  109. $modeids = '';
  110. $modeidsa= array();
  111. foreach($crows as $k1=>$rs1){
  112. $modeids.=','.$rs1['modeid'].'';
  113. $modeidsa[$rs1['modeid']][] = $rs1['mid'];
  114. }
  115. $this->modeids = substr($modeids,1);
  116. foreach($modeidsa as $mkid=>$mids)$wherea[]='(a.`modeid` = '.$mkid.' and a.`mid` in('.join(',', $mids).'))';
  117. $where = ' and a.`isturn`=1 and ( '.join(' or ', $wherea).' )';
  118. }
  119. }
  120. //流程监控
  121. if($lx=='jiankong'){
  122. $where =' and 1=2';
  123. $this->modeids = '0';
  124. if($modeid==0){
  125. $rows = m('view')->getjilu($this->adminid);
  126. foreach($rows as $k1=>$rs1){
  127. $this->modeids.=','.$rs1['modeid'].'';
  128. }
  129. }else{
  130. $wwhere = m('view')->jiankongwhere($modeid, $this->adminid);//返回主表的条件
  131. $wwhere = str_replace('{asqom}','', $wwhere);
  132. $moders = $this->db->getone('[Q]flow_set', $modeid);
  133. $where =' and `mid` in(select `id` from `[Q]'.$moders['table'].'` where 1=1 '.$wwhere.')';
  134. }
  135. }
  136. if($zt!=''){
  137. if($zt!='6'){
  138. $where.=" and a.`status`='$zt'";
  139. if($zt!='5')$where.=' and a.`isturn`=1';
  140. }else{
  141. $where.=" and a.`status` not in(5) and a.`isturn`=0 "; //未提交
  142. }
  143. }
  144. if($dt!='')$where.=" and a.`applydt`>='$dt'";
  145. if($dt2!='')$where.=" and a.`applydt`<='$dt2'";
  146. if($modeid>0)$where.=' and a.modeid='.$modeid.'';
  147. if(!isempt($key))$where.=" and (b.`name` like '%$key%' or b.`deptname` like '%$key%' or a.`sericnum` like '$key%' or a.`nowcheckname`='$key' or a.`modename`='$key')";
  148. return array(
  149. 'table' => '`[Q]flow_bill` a left join `[Q]admin` b on a.uid=b.id',
  150. 'where' => " and a.isdel=0 $where",
  151. 'fields'=> 'a.*,b.name,b.deptname',
  152. 'order' => 'a.optdt desc'
  153. );
  154. }
  155. public function flowbillafter($table, $rows)
  156. {
  157. $rows = m('flowbill')->getbilldata($rows);
  158. $flowarr = array();
  159. if($this->atypess!='error'){
  160. if($this->modeids===false){
  161. $flowarr = m('mode')->getmodemyarr($this->adminid);
  162. }else{
  163. $flowarr = m('mode')->getmodemyarr(0,'and `id` in('.$this->modeids.')');
  164. }
  165. }else if($rows){
  166. foreach($rows as $k=>$rs){
  167. $errorsm = '';
  168. $chuli = '到[流程模块→流程审核步骤]下对应的步骤设置审核人';
  169. $errtype = 0;//有步骤没审核人
  170. if(isempt($rs['nowcheckid'])){
  171. if($rs['nowcourseid']=='0'){
  172. $errorsm = '<font color=blue>当前没有审核步骤</font>';
  173. $chuli = '到[流程模块→流程单据查看]删除最后一条处理记录,然后[重新匹配流程]';
  174. $errtype = 1; //没有步骤
  175. }else{
  176. $errorsm = '<font color=red>当前没有审核人</font>';
  177. }
  178. }else{
  179. $errorsm = '<font color=#800000>审核人帐号已停用</font>';
  180. $errtype = 2; //人员停用
  181. }
  182. $rows[$k]['errorsm'] = $errorsm;
  183. $rows[$k]['chuli'] = $chuli;
  184. $rows[$k]['errtype'] = $errtype;
  185. }
  186. }
  187. return array(
  188. 'rows' => $rows,
  189. 'flowarr' => $flowarr
  190. );
  191. }
  192. public function flowtodosbefore($table)
  193. {
  194. $dt = $this->post('dt1');
  195. $key = $this->post('key');
  196. $zt = $this->post('zt');
  197. $modenum= $this->post('modeid');
  198. $uid = $this->adminid;
  199. $where = 'and `uid`='.$uid.'';
  200. if(!isempt($modenum))$where.=" and `modenum`='$modenum'";
  201. if(!isempt($dt))$where.=" and `adddt` like '$dt%'";
  202. return array(
  203. 'where' => $where,
  204. 'order' => '`adddt` desc'
  205. );
  206. }
  207. public function flowtodosafter($table, $rows)
  208. {
  209. $nums = "''";
  210. $mors = $this->db->getall('select `modenum` from `[Q]flow_todos` where `uid`='.$this->adminid.' group by `modenum`');
  211. foreach($mors as $k=>$rs)$nums.=",'".$rs['modenum']."'";
  212. $flowarr = m('mode')->getrows("`status`=1 and `num` in($nums)",'`num`,`name`,`summary`,`type`','sort');
  213. $modearr = array();
  214. foreach($flowarr as $k=>$rs){
  215. $modearr[$rs['num']] = $rs['summary'];
  216. }
  217. if($rows){
  218. foreach($rows as $k=>$rs){
  219. //$rows[$k]['id'] = $rs['mid'];
  220. $rers = $this->db->getone('[Q]'.$rs['table'].'', $rs['mid']);
  221. $summary = '';
  222. if($rers){
  223. $summary = $this->rock->reparr(arrvalue($modearr, $rs['modenum']), $rers);
  224. $rows[$k]['optdt'] = arrvalue($rers,'optdt');
  225. $rows[$k]['optname'] = arrvalue($rers,'optname');
  226. }
  227. $rows[$k]['summary'] = $summary;
  228. if($rs['isread']=='1'){
  229. $rows[$k]['ishui'] = 1;
  230. $rows[$k]['isread'] = '<font color="#888888">已读</font>';
  231. }else{
  232. $rows[$k]['isread'] = '<font color="red">未读</font>';
  233. }
  234. }
  235. }
  236. return array(
  237. 'rows' => $rows,
  238. 'flowarr' => $flowarr
  239. );
  240. }
  241. public function meetqingkbefore($table)
  242. {
  243. $pid = $this->option->getval('hyname','-1', 2);
  244. return array(
  245. 'where' => "and `pid`='$pid'",
  246. 'order' => 'sort',
  247. 'field' => 'id,name',
  248. );
  249. }
  250. public function meetqingkafter($table, $rows)
  251. {
  252. $dtobj = c('date');
  253. $startdt = $this->post('startdt', $this->date);
  254. $enddt = $this->post('enddt');
  255. if($enddt=='')$enddt = $dtobj->adddate($startdt,'d',7);
  256. $jg = $dtobj->datediff('d',$startdt, $enddt);
  257. if($jg>30)$jg = 30;
  258. $flow = m('flow')->initflow('meet');
  259. $data = m('meet')->getall("`status`=1 and `type`=0 and `startdt`<='$enddt 23:59:59' and `enddt`>='$startdt' order by `startdt` asc",'hyname,title,startdt,enddt,state,joinname,optname,id');
  260. $datss = array();
  261. foreach($data as $k=>$rs){
  262. $rs = $flow->flowrsreplace($rs);
  263. $key = substr($rs['startdt'],0,10).$rs['hyname'];
  264. if(!isset($datss[$key]))$datss[$key] = array();
  265. $str = '['.substr($rs['startdt'],11,5).'→'.substr($rs['enddt'],11,5).']'.$rs['title'].'('.$rs['joinname'].') '.$rs['state'].'';
  266. $datss[$key][] = $str;
  267. }
  268. $columns = $rows;
  269. $barr = array();
  270. $dt = $startdt;
  271. $gdrows = $flow->getall('`type`=1 and `status`=1');
  272. for($i=0; $i<=$jg; $i++){
  273. if($i>0)$dt = $dtobj->adddate($dt,'d',1);
  274. //固定会议
  275. if($gdrows && $dt > $this->rock->date){
  276. $srows = $flow->createmeet($gdrows, $dt, true);
  277. if($srows)foreach($srows as $k1=>$rs){
  278. $key = substr($rs['startdt'],0,10).$rs['hyname'];
  279. if(!isset($datss[$key]))$datss[$key] = array();
  280. $str = '['.substr($rs['startdt'],11,5).'→'.substr($rs['enddt'],11,5).']'.$rs['title'].'('.$rs['joinname'].') <font color=blue>固定会议</font>';
  281. $datss[$key][] = $str;
  282. }
  283. }
  284. $w = $dtobj->cnweek($dt);
  285. $status = 1;
  286. if($w=='六'||$w=='日')$status = 0;
  287. $sbarr = array(
  288. 'dt' => '星期'.$w.'<br>'.$dt.'',
  289. 'status' => $status
  290. );
  291. foreach($rows as $k=>$rs){
  292. $key = $dt.$rs['name'];
  293. $str = '';
  294. if(isset($datss[$key])){
  295. foreach($datss[$key] as $k1=>$strs){
  296. $str.= ''.($k1+1).'.'.$strs.'<br>';
  297. }
  298. }
  299. $sbarr['meet_'.$rs['id'].''] = $str;
  300. }
  301. $barr[] = $sbarr;
  302. }
  303. $arr['columns'] = $columns;
  304. $arr['startdt'] = $startdt;
  305. $arr['enddt'] = $enddt;
  306. $arr['rows'] = $barr;
  307. $arr['totalCount'] = $jg+1;
  308. return $arr;
  309. }
  310. public function deltodoAjax()
  311. {
  312. $id = c('check')->onlynumber($this->post('id','0'));
  313. m('flow_todos')->delete('id in('.$id.') and `uid`='.$this->adminid.'');
  314. $this->backmsg();
  315. }
  316. public function deltodoydAjax()
  317. {
  318. $id = c('check')->onlynumber($this->post('id','0'));
  319. m('flow_todos')->update('`readdt`=now(),`isread`=1','id in('.$id.') and `uid`='.$this->adminid.' and `isread`=0');
  320. return returnsuccess();
  321. }
  322. }
粤ICP备19079148号