repair_faultModel.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. $this->defaultorder = 'handle_state,asc,optdt,desc';
  10. }
  11. // 初始化单据可替换其他属性,$lx,0默认,1详情展示,2列表显示,3打印页,4外部详情页
  12. public function flowrsreplace($rs, $lx=0)
  13. {
  14. $zt = $rs['handle_state'];
  15. // 将id转换为文字
  16. $rs['handle_state'] = $this->getstatezt($zt);
  17. return $rs;
  18. }
  19. // $ors当前单据操作信息,$crs提交过来的信息
  20. public function flowoptmenu($ors, $crs)
  21. {
  22. // 处理维修
  23. if ($ors['num'] == 'noup') {
  24. $sm = $crs['sm']; // 提交过来的说明
  25. $uname = $this->uname;
  26. $uid = $this->uid;
  27. // 更新说明
  28. $this->update([
  29. "explain"=>$sm,
  30. "repairer"=>$uname,
  31. "repairer_id"=>$uid,
  32. ], $this->id);
  33. }
  34. }
  35. //显示操作菜单判断
  36. protected function flowgetoptmenu($num)
  37. {
  38. if (empty($this->id)) return false;
  39. $row = m("repair_fault")->getone("id={$this->id} and handle_state != 1");
  40. if (empty($row) || empty($row['type_id'])) return false;
  41. $type_id = $row['type_id'];
  42. $can = m("repair_type")->getone("id={$type_id} and FIND_IN_SET({$this->uid},`head_id`)", 'head_id');
  43. if (empty($can)) {
  44. return false;
  45. } else {
  46. return true;
  47. }
  48. }
  49. //提交时调用
  50. protected function flowsubmit($na, $sm){
  51. // if ($na != '编辑') {
  52. // }
  53. $row = m("repair_fault")->getone("id={$this->id}");
  54. if (!empty($row) && $row['handle_state'] == 0 && $row['sms_state'] == 0) {
  55. $typeInfo = m("repair_type")->getone("id={$row['type_id']}");
  56. m("log")->addlog("故障记录", "发送短信给{$typeInfo['head']}");
  57. // 发送成功改变状态
  58. $this->update([
  59. "sms_state"=>1,
  60. ], $this->id);
  61. }
  62. }
  63. public function flowwesearchdata($lx)
  64. {
  65. if($lx==1) return m("repair_type")->getall("1=1");
  66. return array(
  67. 'typename' => '所有分类',
  68. 'searchmsg' => '标题/分类',
  69. );
  70. }
  71. // 移动端筛选
  72. protected function flowbillwhere($uid, $lx)
  73. {
  74. $key = $this->rock->post('key');
  75. if ($this->ismobile) {
  76. $typeid = (int)$this->rock->post('type_id','0');
  77. $keywere= '';
  78. if(!isempt($key))$keywere.=" and (`title` like '%$key%' or `type`='$key')";
  79. $whyere = '';
  80. if($typeid>0){
  81. $whyere.=" and `type_id`='$typeid'";
  82. }
  83. return array(
  84. 'order' => '`handle_state` asc,`optdt` desc',
  85. 'keywere' => $keywere,
  86. 'where' => $whyere,
  87. 'fields' => '*'
  88. );
  89. }
  90. return null;
  91. }
  92. public function getstatezt($zt)
  93. {
  94. $colors = ["#ff8b1a", "#00c959", "#ff4974"];
  95. if (isset($this->hstate[$zt])) {
  96. $html = '<font style="background-color:'.$colors[$zt].'; padding: 2px 8px; border-radius: 4px; color: #fff">'.$this->hstate[$zt].'</font>';
  97. return $html;
  98. } else {
  99. return null;
  100. }
  101. }
  102. }