| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- class flow_repair_faultClassModel extends flowModel
- {
- public $hstate, $hcolor;
- public function initModel()
- {
- $this->hstate = array('未处理', '已处理');
- $this->hcolor = array('#ff6600','green');
- }
- // 初始化单据可替换其他属性,$lx,0默认,1详情展示,2列表显示,3打印页,4外部详情页
- public function flowrsreplace($rs, $lx=0)
- {
- $zt = $rs['handle_state'];
- // 将id转换为文字
- $rs['handle_state'] = $this->getstatezt($zt);
- return $rs;
- }
- // $ors当前单据操作信息,$crs提交过来的信息
- public function flowoptmenu($ors, $crs)
- {
- // 处理维修
- if ($ors['num'] == 'noup') {
- $sm = $crs['sm']; // 提交过来的说明
- $uname = $this->uname;
- $uid = $this->uid;
- // 更新说明
- $this->update([
- "explain"=>$sm,
- "repairer"=>$uname,
- "repairer_id"=>$uid,
- ], $this->id);
- }
- }
- //显示操作菜单判断
- protected function flowgetoptmenu($num)
- {
- if (empty($this->id)) return false;
- $row = m("repair_fault")->getone("id={$this->id} and handle_state != 1");
- if (empty($row) || empty($row['type_id'])) return false;
- $type_id = $row['type_id'];
- $can = m("repair_type")->getone("id={$type_id} and FIND_IN_SET({$this->uid},`head_id`)", 'head_id');
- if (empty($can)) {
- return false;
- } else {
- return true;
- }
- }
- //提交时调用
- protected function flowsubmit($na, $sm){
- $row = m("repair_fault")->getone("id={$this->id}");
- if (!empty($row) && $row['handle_state'] == 0 && $row['sms_state'] == 0) {
- $typeInfo = m("repair_type")->getone("id={$row['type_id']}");
- m("log")->addlog("故障记录", "发送短信给{$typeInfo['head']}");
- // 发送成功改变状态
- $this->update([
- "sms_state"=>1,
- ], $this->id);
- }
- }
- public function getstatezt($zt)
- {
- if (isset($this->hstate[$zt])) {
- $html = '<font color="'.$this->hcolor[$zt].'">'.$this->hstate[$zt].'</font>';
- return $html;
- } else {
- return null;
- }
- }
- }
|