sealaplModel.php 13 KB

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