hyarra = array('正常','会议中','结束','取消'); $this->ytarra = array('等待','待进行','进行中','已结束'); $this->hyarrb = array('green','blue','#ff6600','#888888'); $this->dbobj = c('date'); $this->meeting_room = m("meeting_room")->meetingRoomIdList(); $this->reatearr = array( 'd' => '每天', 'w1' => '每周一', 'w2' => '每周二', 'w3' => '每周三', 'w4' => '每周四', 'w5' => '每周五', 'w6' => '每周六', 'w7' => '每周日', 'm' => '每月', 'y' => '每年', ); } //录入页上的标题 public function inputtitle() { return "会议室审批单"; } //子表数据替换处理$lx=0编辑时,1展示时 protected function flowsubdata($rows, $lx=0){ for ($i = 0; $i < count($rows); $i++) { if (isset($rows[$i]['topic_state']) && !empty($rows[$i]['topic_state'])) { $index = $rows[$i]['topic_state'] ?? 1; $rows[$i]['topic_state'] = $this->ytarra[$index]; } else { $id = isset($rows[$i]['id']); m('meeting_topics')->update(['topic_state'=>1], "id={$id}"); } } return $rows; } // 初始化单据可替换其他属性,$lx,0默认,1详情展示,2列表显示,3打印页,4外部详情页 public function flowrsreplace($rs, $lx=0) { // m('log')->addlog('会议单据', json_encode($rs, true)); $this->id = $rs['id']; $zt = $rs['meet_state']; $is_hand = $rs['is_hand'] ?? 0; $room_id = $rs['room_id']; $nzt = $zt; $time = time(); $stime = strtotime($rs['start_time']); $etime = strtotime($rs['end_time']); if($is_hand != 1){ if($etime < $time){ $nzt = 2; } else if ($stime > $time){ $nzt = 0; } else { $nzt = 1; $topic = m('meeting_topics')->getone("mid={$this->id}",'id, topic_state', 'sort'); if (isset($topic['id']) && $topic['topic_state']<2) { m('meeting')->firstMeetingTopicStart($this->id); } } } if ($stime <= $time && $nzt != 2) { $nzt = 1; } // 更新数据状态 if($zt != $nzt){ $this->update('meet_state='.$nzt.'', $rs['id']); $zt = $nzt; } // 将id转换为文字 $rs['meet_state'] = $this->getstatezt($zt); if (!empty($room_id)) $rs['room_id'] = $this->meeting_room[$room_id]['room_name']; return $rs; } // $ors当前单据操作信息,$crs提交过来的信息 public function flowoptmenu($ors, $crs) { // 切换会议议题 if ($ors['num'] == 'changeTopic') { $topics = $this->db->getall("select * from `[Q]meeting_topics` where mid = {$this->id} order by sort"); for ($i = 0; $i < count($topics); $i++) { if(isset($topics[$i]['topic_state']) && $topics[$i]['topic_state'] == 2) { $id = $topics[$i]['id']; $data = ['topic_state'=>$topics[$i]['topic_state']+1]; m('meeting_topics')->update($data, "id={$id}"); if (isset($topics[$i+1]['topic_state'])) { $id = $topics[$i+1]['id']; $data = ['topic_state'=>2]; m('meeting_topics')->update($data, "id={$id}"); } if (isset($topics[$i+2]['topic_state'])) { $id = $topics[$i+2]['id']; $data = ['topic_state'=>1]; m('meeting_topics')->update($data, "id={$id}"); } break; } } if (isset($topics[count($topics) - 1]) && $topics[count($topics) - 1]['topic_state'] == 2) { m('meeting')->update(['is_hand'=>1,'meet_state'=>2], "id={$this->id}"); } } else if ($ors['num'] == 'enableMeeting') { $time = time(); $stime = strtotime($this->rs['start_time']); $etime = strtotime($this->rs['end_time']); if ($stime < $time){ $data = [ 'meet_state'=>1, 'is_hand'=>1 ]; } else if ($stime >= $time) { $data = [ 'meet_state'=>0, 'is_hand'=>1 ]; } m('meeting')->update($data, "id={$this->id}"); $topic = m('meeting_topics')->getone("mid={$this->id}", "id", 'sort desc'); if (isset($topic['id'])) { m('meeting_topics')->update(['topic_state'=>'2'], 'id='.$topic['id']); } } else if ($ors['num'] == 'disenableMeeting') { // $data = [ // 'meet_state'=>2, // 'is_hand'=>1 // ]; // // m('meeting_key')->update($data, "id={$this->id}"); } else if ($ors['num'] == "noup") { // 动作名 if ($ors['actname'] == "change_room") { $data = $this->rs; $roomName = $this->meeting_room[$data['room_id']]['room_name']; if (!empty($roomName)) { $this->update([ "meeting_room"=>$roomName, ], "id={$this->id}"); } } } } //删除单据时调用 public function flowdeletebill($sm) { // m('meet_sys')->deleteMeetingRoom($this->rs); } //流程全部完成后调用 // public function flowcheckfinsh($sm) { protected function flowcheckfinsh($sm){ // 审批完成给负责人发短信 $meeting = m("meeting")->getone("id={$this->id}"); if (empty($meeting)) return; m("log")->addlog("会议室审批", "发送短信给".$meeting['attendees']."部门负责人"); foreach (explode(',', $meeting['attendees_id']) as $val) { if (substr($val, 0,1) == 'u') { $users[] = substr($val, 1); } else if (substr($val, 0,1) == 'd') { $depts[] = substr($val, 1); } } $users = m("admin")->getall("id in (".implode(',', $users).")"); $mobile = []; foreach ($users as $val) { $mobile[] = $val['mobile']; } if (!empty($depts)) { $deptSql = "select distinct b.mobile, a.name from [Q]dept a left join [Q]admin b on a.headid = b.id where a.id in (".implode(',', $depts).") "; m("log")->addlog("会议室审批", $deptSql); $depts = $this->db->getall($deptSql); $depts_e = []; // 部门负责人手机号 foreach ($depts as $val) { if (empty($val['mobile'])) { $depts_e[] = $val['name']; } else { $mobile[] = $val['mobile']; } } } $infoText = "短信包括:".implode('、', $mobile); if (!empty($depts_e)) { $infoText .= ",其中".implode('、', $mobile)."未设负责人,无法通知"; } m("log")->addlog("会议室审批", $infoText); } public function getstatezt($zt) { if (isset($this->hyarrb[$zt])) { $html = ''.$this->hyarra[$zt].''; return $html; } else { return null; } } }