repair_faultModel.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. class flow_repair_faultClassModel extends flowModel
  3. {
  4. public $hstate, $hcolor;
  5. public function initModel()
  6. {
  7. $this->hstate = array('未处理', '已处理');
  8. $this->hcolor = array('#ff6600','green');
  9. }
  10. // 初始化单据可替换其他属性,$lx,0默认,1详情展示,2列表显示,3打印页,4外部详情页
  11. public function flowrsreplace($rs, $lx=0)
  12. {
  13. $zt = $rs['handle_state'];
  14. // 将id转换为文字
  15. $rs['handle_state'] = $this->getstatezt($zt);
  16. return $rs;
  17. }
  18. // $ors当前单据操作信息,$crs提交过来的信息
  19. public function flowoptmenu($ors, $crs)
  20. {
  21. // 处理维修
  22. if ($ors['num'] == 'noup') {
  23. $sm = $crs['sm']; // 提交过来的说明
  24. $uname = $this->uname;
  25. $uid = $this->uid;
  26. // 更新说明
  27. $this->update([
  28. "explain"=>$sm,
  29. "repairer"=>$uname,
  30. "repairer_id"=>$uid,
  31. ], $this->id);
  32. }
  33. }
  34. //显示操作菜单判断
  35. protected function flowgetoptmenu($num)
  36. {
  37. if (empty($this->id)) return false;
  38. $row = m("repair_fault")->getone("id={$this->id} and handle_state != 1");
  39. if (empty($row) || empty($row['type_id'])) return false;
  40. $type_id = $row['type_id'];
  41. $can = m("repair_type")->getone("id={$type_id} and FIND_IN_SET({$this->uid},`head_id`)", 'head_id');
  42. if (empty($can)) {
  43. return false;
  44. } else {
  45. return true;
  46. }
  47. }
  48. //提交时调用
  49. protected function flowsubmit($na, $sm){
  50. // if ($na != '编辑') {
  51. // }
  52. $row = m("repair_fault")->getone("id={$this->id}");
  53. if (!empty($row) && $row['handle_state'] == 0 && $row['sms_state'] == 0) {
  54. $typeInfo = m("repair_type")->getone("id={$row['type_id']}");
  55. m("log")->addlog("故障记录", "发送短信给{$typeInfo['head']}");
  56. // 发送成功改变状态
  57. $this->update([
  58. "sms_state"=>1,
  59. ], $this->id);
  60. }
  61. }
  62. public function flowwesearchdata($lx)
  63. {
  64. $pid = m("repair_type")->type_pid;
  65. if($lx==1)return $this->option->getselectdata($pid, true);
  66. return array(
  67. 'typename' => '所有分类',
  68. 'searchmsg' => '标题/分类',
  69. );
  70. }
  71. public function getstatezt($zt)
  72. {
  73. $colors = ["#ff8b1a", "#00c959", "#ff4974"];
  74. if (isset($this->hstate[$zt])) {
  75. $html = '<font style="background-color:'.$colors[$zt].'; padding: 2px 8px; border-radius: 4px; color: #fff">'.$this->hstate[$zt].'</font>';
  76. return $html;
  77. } else {
  78. return null;
  79. }
  80. }
  81. }