sealaplModel.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <?php
  2. /**
  3. * 模块.印章申请
  4. */
  5. class flow_sealaplClassModel extends flowModel
  6. {
  7. // level1部门领导
  8. // level2办公室
  9. // level3业务主管
  10. // level4法务部
  11. // level5矿分管领导
  12. // level6矿长
  13. protected $examine_dept_dic = ['1'=>"部门领导",'2'=>"办公室",'3'=>"业务主管部门",'4'=>"法律事务部", '5'=>"矿分管领导",'6'=>"矿长党委书记"];
  14. protected function flowinit(){
  15. }
  16. //提交时调用
  17. protected function flowsubmit($na, $sm){
  18. if ($sm = '提交') {
  19. $info = [
  20. "advice_level1_leader"=>$this->flowarr[0]['nowcheckname'],
  21. "advice_level1_leader_id"=>$this->flowarr[0]['nowcheckid']
  22. ];
  23. m('sealapl')->update($info, "id = {$this->id}");
  24. }
  25. }
  26. //单据判断条件从写$lx类型,$uid用户Id
  27. protected function flowbillwhere($lx, $uid){
  28. $where = '';
  29. // $this->rock->post('key');
  30. $startDate = $this->rock->post("start_date");
  31. $stopDate = $this->rock->post("stop_date");
  32. $status = $this->rock->post("status");
  33. $export_type = $this->rock->post("export_type");
  34. if ($uid == 'all') {
  35. $where .= 'and '.$this->adminid.' in (1, 28)';
  36. }
  37. // 开始时间
  38. if (!empty($startDate)) {
  39. $where .= " and office_date > '{$startDate}'";
  40. }
  41. // 结束时间
  42. if (!empty($stopDate)) {
  43. $where .= " and office_date < '{$stopDate}'";
  44. }
  45. // 审核完成
  46. $where .= " and status = '{$status}'";
  47. return [
  48. 'where' => $where,
  49. 'order'=>'status, office_date desc, id desc'
  50. ];
  51. }
  52. //读取印章保管人来审批
  53. protected function flowcheckname($num)
  54. {
  55. // 自定义审核人
  56. if (strpos($num, 'approve') === 0) {
  57. // $index = substr($num, -1);
  58. // if ($index == 4) {
  59. //// $sid = $this->rs['advice_level'.$index.'_leader_id'];
  60. //// $sna = $this->rs['advice_level'.$index.'_leader'];
  61. // } else {
  62. // $sid = $this->rs['advice_level'.$index.'_leader_id'];
  63. // $sna = $this->rs['advice_level'.$index.'_leader'];
  64. // return array($sid, $sna);
  65. // }
  66. }
  67. }
  68. //展示时替换一下
  69. public function flowrsreplace($rs, $lx=0)
  70. {
  71. // if (empty($this->id)) $this->id = $rs['id'];
  72. // if (empty($rs['id'])) $rs['id'] = $this->id;
  73. $rs['office_date'] = date("Y-m-d", strtotime($rs['office_date']));
  74. $rs['date'] = empty($rs['office_date']) ? $rs['applydt'] : $rs['office_date'];
  75. $rs['date_index'] = substr($rs['applydt'],0,4);
  76. $sqlStr = "SELECT t.*
  77. FROM (
  78. -- 子查询,为每个step选取最新的时间对应的记录
  79. SELECT step, MAX(optdt) AS max_optdt FROM zqoa_flow_log
  80. WHERE mid = {$rs['id']} AND `status` = 1 AND `table` = 'sealapl'
  81. GROUP BY step
  82. ) AS subquery
  83. JOIN zqoa_flow_log AS t ON subquery.step = t.step
  84. AND subquery.max_optdt = t.optdt
  85. WHERE t.mid = {$rs['id']}
  86. AND t.`status` = 1
  87. AND t.`table` = 'sealapl'";
  88. // 未审核完成时,设定签名为空
  89. $flow_arr = $this->db->getall($sqlStr);
  90. $flow_dict = [];
  91. foreach ($flow_arr as $key=>$value) {
  92. $flow_dict[$value['name']] = $value;
  93. }
  94. if (!isset($flow_dict["部门领导审批"])) {
  95. $rs['advice_level1_leader'] = null;
  96. $rs['advice_level1'] = null;
  97. $rs['advice_level3_leader'] = null;
  98. $rs['advice_level3'] = null;
  99. }
  100. if (!isset($flow_dict["办公室审批"])) {
  101. $rs['advice_level2_leader'] = null;
  102. $rs['advice_level2'] = null;
  103. }
  104. // if (!isset($flow_dict["业务主管部门审批"])) {
  105. // $rs['advice_level3_leader'] = null;
  106. // $rs['advice_level3'] = null;
  107. // }
  108. if (!isset($flow_dict["法律事务部审批"])) {
  109. $rs['advice_level4_leader'] = null;
  110. $rs['advice_level4'] = null;
  111. }
  112. if (!isset($flow_dict["矿分管领导审批"])) {
  113. $rs['advice_level5_leader'] = null;
  114. $rs['advice_level5'] = null;
  115. }
  116. if (!isset($flow_dict["矿长党委书记审批"])) {
  117. $rs['advice_level6_leader'] = null;
  118. $rs['advice_level6'] = null;
  119. }
  120. $rs['advice_leader_max'] = empty($rs['advice_level6_leader']) ? $rs['advice_level5_leader'] : $rs['advice_level6_leader'];
  121. $flow_info = $this->flogmodel->getone("mid={$rs['id']} and step=1 and status=1 and `table` = 'sealapl'", 'checkname', 'id desc');
  122. $rs['dept_manager'] = $flow_info ? $flow_info['checkname'] : null;
  123. if (!empty($rs['opinion_dept'])) {
  124. $dept = $rs['opinion_dept'];
  125. // 自动加需要xx部门审核
  126. // 办公室需要审核部门
  127. /*
  128. $examine_dept_arr = explode(',',$dept);
  129. $examine_info = '';
  130. foreach ($examine_dept_arr as $v) {
  131. $examine_info .= $this->examine_dept_dic[$v].'、';
  132. }
  133. if (!empty($examine_info)) {
  134. $examine_info = substr($examine_info, 0, strlen($examine_info) - 3);
  135. $examine_info = '需要“'.$examine_info.'”审核。';
  136. }
  137. if (!empty($rs['advice_level2'])) {
  138. $rs['advice_level2'] = $rs['advice_level2'].'<br>'.$examine_info;
  139. } else {
  140. $rs['advice_level2'] = $examine_info;
  141. }
  142. */
  143. // 列表-审批人:
  144. // if ($dept == 1) {
  145. // $flow_info = $this->flogmodel->getone("mid={$rs['id']} and step=3 and status=1 and `table` = 'sealapl'", 'checkname', 'id desc');
  146. // $rs['advice_level1_applyer'] = $flow_info ? $flow_info['checkname'] : null;
  147. // } else if ($dept == 2) {
  148. //
  149. // } else if ($dept == 3) {
  150. // $flow_info = $this->flogmodel->getone("mid={$rs['id']} and step=3 and status=1 and `table` = 'sealapl'", 'checkname', 'id desc');
  151. // $rs['advice_level3_applyer'] = $flow_info ? $flow_info['checkname'] : null;
  152. // } else if ($dept == 4) {
  153. // $flow_info = $this->flogmodel->getone("mid={$rs['id']} and step=3 and status=1 and `table` = 'sealapl'", 'checkname', 'id desc');
  154. // $rs['advice_level4_applyer'] = $flow_info ? $flow_info['checkname'] : null;
  155. // }
  156. }
  157. // 办公室审核人
  158. $flow_info = $this->flogmodel->getone("mid={$rs['id']} and step=2 and status=1 and `table` = 'sealapl'", 'checkname', 'id desc');
  159. $rs['advice_level2_leader'] = $flow_info ? $flow_info['checkname'] : null;
  160. // 印章专管人
  161. $seal = m('seal')->getone("id = {$rs['seal_name']}");
  162. $rs['office_applyer'] = $seal['specialized'];
  163. $rs['seal_name'] = $seal['name'];
  164. // 流程状态
  165. $rs['state_info'] = $this->getApproval($rs['nowcheckname'] ?? ''); // 当前审核人
  166. // 详情编号展示
  167. if ($rs['date'] == '1970-01-01') {
  168. $rs['date'] = "";
  169. $date = $rs['applydt'];
  170. } else {
  171. $date = $rs['date'];
  172. }
  173. $year = date("Y", strtotime($date));
  174. $month = date("m", strtotime($date));
  175. $this_month = date("Y-m", strtotime($date));
  176. $last_month = date("Y-m", strtotime("-1 month", strtotime($date)));
  177. $this_month_max_id = $this->getone("DATE_FORMAT(applydt,'%Y-%m') = '{$this_month}'", "max(id) as id")['id'];
  178. $last_month_max_id = $this->getone("DATE_FORMAT(applydt,'%Y-%m') = '{$last_month}'", "max(id) as id")['id'];
  179. $this_month_max_id = empty($last_month_max_id) ? 2 : $this_month_max_id;
  180. $rs['year'] = $year;
  181. $rs['month'] = $month;
  182. $rs['num'] = ($rs['id'] - (empty($last_month_max_id) ? $this_month_max_id - 2: $last_month_max_id));
  183. return $rs;
  184. }
  185. // 审核样式
  186. public function getApproval($names) {
  187. if (empty($names)) {
  188. $html = '<font style="background-color:#00c959; padding: 2px 8px; border-radius: 4px; color: #fff">已审核</font>';
  189. return $html;
  190. } else {
  191. $html = '<font style="background-color:#ff4974; padding: 2px 8px; border-radius: 4px; color: #fff">待审核</font><br /><font style="color: #ff4974">审核人:'.$names.'</font>';
  192. return $html;
  193. }
  194. }
  195. public function inputtitle()
  196. {
  197. return "枣泉煤矿用印审批表";
  198. }
  199. protected function flowdatalog($arr)
  200. {
  201. $arr['title'] = $this->inputtitle();
  202. return $arr;
  203. }
  204. // $ors当前单据操作信息,$crs提交过来的信息
  205. public function flowoptmenu($ors, $crs)
  206. {
  207. if ($ors['num'] == 'dept_process') {
  208. }
  209. }
  210. //审核之前调用$zt 状态, $sm说明
  211. protected function flowcheckbefore($zt, $sm, $ufied) {
  212. if ($zt == 1) {
  213. $nodes_old = $this->rs['notes'];
  214. if (isset($this->nowcourse['step'])) {
  215. if (empty($sm)) $sm = '同意';
  216. $step_name = $this->nowcourse['name'];
  217. $info = "";
  218. if ($step_name == '部门领导审批') {
  219. $info = [
  220. "advice_level1"=>$sm,
  221. "advice_level1_leader"=>$this->rock->adminname,
  222. "advice_level1_leader_id"=>$this->rock->adminid,
  223. "advice_level3"=>$sm,
  224. "advice_level3_leader"=>$this->rock->adminname,
  225. "advice_level3_leader_id"=>$this->rock->adminid,
  226. // "notes"=>'部门领导-'.$this->rock->adminname.":".$sm
  227. ];
  228. } else if ($step_name == '办公室审批') {
  229. $date = date('Y-m-d H:i:s'); // 办公室处理日期
  230. // 获取当月最大id数据
  231. $yearMon = date("Y-m", strtotime($date));
  232. $maxInfo = $this->getone("DATE_FORMAT(office_date,'%Y-%m') = '{$yearMon}' and status = 1 and seal_name = {$this->rs['seal_name']}", "max(year_num) as id");
  233. $max_year_num = 1;
  234. if (isset($maxInfo['id'])) {
  235. $max_year_num = $maxInfo['id'] + 1;
  236. }
  237. $info = [
  238. "advice_level2"=>$sm,
  239. "advice_level2_leader"=>$this->rock->adminname,
  240. "advice_level2_leader_id"=>$this->rock->adminid,
  241. "office_date"=>$date,
  242. "year_num" => $max_year_num
  243. // "notes"=>$nodes_old.(empty($nodes_old) ? "" : "<br>").'办公室-'.$this->rock->adminname.":".$sm
  244. ];
  245. } else if ($step_name == '业务主管部门审批') {
  246. $info = [
  247. "advice_level3"=>$sm,
  248. "advice_level3_leader"=>$this->rock->adminname,
  249. "advice_level3_leader_id"=>$this->rock->adminid,
  250. // "notes"=>$nodes_old.(empty($nodes_old) ? "" : "<br>").'业务主管部门-'.$this->rock->adminname.":".$sm
  251. ];
  252. } else if ($step_name == '法律事务部审批') {
  253. $info = [
  254. "advice_level4"=>$sm,
  255. "advice_level4_leader"=>$this->rock->adminname,
  256. "advice_level4_leader_id"=>$this->rock->adminid,
  257. // "notes"=>$nodes_old.(empty($nodes_old) ? "" : "<br>").'法律事务部-'.$this->rock->adminname.":".$sm
  258. ];
  259. } else if ($step_name == '矿分管领导审批') {
  260. $info = [
  261. "advice_level5"=>$sm,
  262. "advice_level5_leader"=>$this->rock->adminname,
  263. "advice_level5_leader_id"=>$this->rock->adminid,
  264. // "notes"=>$nodes_old.(empty($nodes_old) ? "" : "<br>").'矿分管领导-'.$this->rock->adminname.":".$sm
  265. ];
  266. } else if ($step_name == '矿长党委书记审批') {
  267. $info = [
  268. "advice_level6"=>$sm,
  269. "advice_level6_leader"=>$this->rock->adminname,
  270. "advice_level6_leader_id"=>$this->rock->adminid,
  271. // "notes"=>$nodes_old.(empty($nodes_old) ? "" : "<br>").'矿长党委书记-'.$this->rock->adminname.":".$sm
  272. ];
  273. }
  274. if (!empty($info)) m('sealapl')->update($info,"id={$this->id}");
  275. }
  276. // if ($this->nowcourse['step'] == 3 && $this->nowcourse['name'] == '负责部门审批') {
  277. // $opinion_dept = $this->rs['opinion_dept'];
  278. // if ($opinion_dept == 1) {
  279. // m('sealapl')->update(["advice_level1"=>$sm],"id={$this->id}");
  280. // } else if ($opinion_dept == 2) {
  281. // m('sealapl')->update(["advice_level2"=>$sm],"id={$this->id}");
  282. // } else if ($opinion_dept == 3) {
  283. // m('sealapl')->update(["advice_level3"=>$sm],"id={$this->id}");
  284. // } else if ($opinion_dept == 4) {
  285. // m('sealapl')->update(["advice_level4"=>$sm],"id={$this->id}");
  286. // }
  287. // }
  288. }
  289. // if(isset($this->nowcourse['step']) && !empty($sm)) {
  290. // $info_old = $this->rs['notes'];
  291. // $info = $this->nowcourse['step'].'.'.$this->adminname.":".$sm."\n";
  292. // $info = $info_old.$info;
  293. // $info = substr($info, 0, strlen($info)-1);
  294. // m('sealapl')->update(["notes"=>$info],"id={$this->id}");
  295. // }
  296. }
  297. }