repair_faultModel.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. $row = m("repair_fault")->getone("id={$this->id}");
  51. if (!empty($row) && $row['handle_state'] == 0 && $row['sms_state'] == 0) {
  52. $typeInfo = m("repair_type")->getone("id={$row['type_id']}");
  53. m("log")->addlog("故障记录", "发送短信给{$typeInfo['head']}");
  54. // 发送成功改变状态
  55. $this->update([
  56. "sms_state"=>1,
  57. ], $this->id);
  58. }
  59. }
  60. public function getstatezt($zt)
  61. {
  62. if (isset($this->hstate[$zt])) {
  63. $html = '<font color="'.$this->hcolor[$zt].'">'.$this->hstate[$zt].'</font>';
  64. return $html;
  65. } else {
  66. return null;
  67. }
  68. }
  69. }