fworkAction.php 9.4 KB

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