| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 |
- <?php
- class flow_meetingClassModel extends flowModel
- {
- public $hyarra, $ytarra, $hyarrb, $dbobj, $reatearr, $meeting_room;
- public function initModel()
- {
- $this->hyarra = array('未开始','会议中','结束','取消');
- $this->ytarra = array('等待','待进行','进行中','已结束');
- $this->hyarrb = array('green','blue','#ff6600','#888888');
- $this->dbobj = c('date');
- // $this->defaultorder = 'start_time desc';
- $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']."({$this->meeting_room[$room_id]['desc']})"; // 会议室Id替换会议室名
- $rs['state_info'] = $this->getApproval($rs['nowcheckname'] ?? ''); // 当前审核人
- $meet_dev = ["不需要", "远程视频会议", "电子大屏"];
- $rs['meet_dev'] = $rs['meet_dev'] == 0 ? $meet_dev[$rs['meet_dev']] : "<font color=red>".$meet_dev[$rs['meet_dev']]."</font>";
- $rs['fixed'] = $rs['fixed'] == 1 ? '是' : '否'; // 是否固定会议
- return $rs;
- }
- //提交时调用
- protected function flowsubmit($na, $sm){
- $this->meetingAuditSms($this->id, 0);
- $this->meetingApplicantSms($this->id); // 提醒申请人
- $this->meetingMaXuSms($this->id); // 单独给马旭发
- }
- // $ors当前单据操作信息,$crs提交过来的信息
- public function flowoptmenu($ors, $crs)
- {
- if ($ors['num'] == 'enableMeeting') {
- // 开始会议
- $data = [
- 'meet_state'=>1,
- 'is_hand'=>1
- ];
- m('meeting')->update($data, "id={$this->id}");
- } else if ($ors['num'] == 'noup_end_meet') {
- // 手动结束会议
- $data = [
- 'meet_state'=>2,
- 'is_hand'=>1
- ];
- m('meeting')->update($data, "id={$this->id}");
- } else if ($ors['num'] == "noup_chage_room") {
- $data = $this->rs;
- $roomName = $this->meeting_room[$data['room_id']]['room_name'];
- $isApply = m('meeting')->isapplymsg($this->rs['start_time'], $this->rs['end_time'], $roomName, $this->id, 1);
- if (empty($isApply)) {
- $this->update([
- "meeting_room"=>$roomName,
- ], "id={$this->id}");
- // 更换会议室 - 发送会议短信
- // $this->meetingSuccSms($this->id);
- } else {
- return $isApply;
- }
- }
- }
- //操作菜单操作之前
- protected function flowoptmenubefore($ors, $arr)
- {
- if($ors['num']=='noup_chage_room') {
- $room_id = $this->rock->post('fields_room_id');
- $room = m("meeting_room")->getone("id={$room_id}", 'room_name');
- $roomName = $room['room_name'];
- $isApply = m('meeting')->isapplymsg($this->rs['start_time'], $this->rs['end_time'], $roomName, $this->id, 1);
- if (!empty($isApply)) {
- return $isApply;
- }
- }
- }
- //删除单据时调用
- public function flowdeletebill($sm) {
- // m('meet_sys')->deleteMeetingRoom($this->rs);
- }
- //审核之前调用$zt 状态, $sm说明
- protected function flowcheckbefore($zt, $sm) {
- if ($this->nowcourse['step'] == 1) {
- $this->meetingAuditSms($this->id, 1);
- // return [
- // "msg"=>'发送短信'
- // ];
- } else if ($this->nowcourse['step'] == 2) {
- $meet_room = $sm['meeting_room'];
- $isApply = m('meeting')->isapplymsg($this->rs['start_time'], $this->rs['end_time'], $meet_room, $this->id, 1);
- if (!empty($isApply)) {
- return [
- "msg"=>$isApply
- ];
- }
- }
- }
- //审核完成后调用
- protected function flowcheckafter($zt, $sm){
- }
- //流程全部完成后调用
- protected function flowcheckfinsh($sm){
- // 审批完成给负责人发短信
- $this->meetingSuccSms($this->id);
- }
- //单据判断条件从写$lx类型,$uid用户Id
- protected function flowbillwhere($lx, $uid){
- return [
- 'order'=>'start_time desc'
- ];
- }
- // 自定义方法
- // 状态样式
- public function getstatezt($zt)
- {
- if (isset($this->hyarrb[$zt])) {
- $html = '<font color="'.$this->hyarrb[$zt].'">'.$this->hyarra[$zt].'</font>';
- return $html;
- } else {
- return null;
- }
- }
- // 审核样式
- public function getApproval($names) {
- if (empty($names)) {
- $html = '<font style="background-color:#00c959; padding: 2px 8px; border-radius: 4px; color: #fff">已审核</font>';
- return $html;
- } else {
- $html = '<font style="background-color:#ff4974; padding: 2px 8px; border-radius: 4px; color: #fff">待审核</font><br /><font style="color: #ff4974">审核人:'.$names.'</font>';
- return $html;
- }
- }
- // 审批完成通知参会
- public function meetingSuccSms($meetId) {
- if (empty($meetId)) {
- m("log")->addlog("短信发送", "会议Id为空");
- return;
- }
- // 获取当前会议信息
- $meeting = m("meeting")->getone("id={$this->id}");
- $meetTime = $meeting['start_time']; // 时间
- $meetTime = date('m月d日H点i分', strtotime($meetTime));
- $meetName = $this->strLength35($meeting['title']); // 主题
- $meetRoom = $meeting['meeting_room']; // 地点
- m("log")->addlog("会议室审批", "发送短信给".$meeting['attendees']);
- $userIds = []; // 用户id
- $users = []; // 用户信息
- $deptIds = []; // 部门id
- $depts = []; // 部门信息
- $nullMobileArr = ["user"=>[], "dept"=>[]]; // 没有手机号的用户、部门
- // 分解参会人员、部门id
- foreach (explode(',', $meeting['attendees_id']) as $val) {
- // u=用户 or d=部门
- if (substr($val, 0,1) == 'u') {
- $userIds[] = substr($val, 1);
- } else if (substr($val, 0,1) == 'd') {
- $deptIds[] = substr($val, 1);
- }
- }
- // 用户:获取用户电话
- if (count($userIds) > 0) {
- // 获取所有用户信息
- $uInfo = m("admin")->getall("id in (".implode(',', $userIds).")");
- for ($i = 0; $i < count($userIds); $i++) {
- $mobile = $uInfo[$i]['mobile'];
- $name = $uInfo[$i]['name'];
- if (empty($mobile)) {
- $nullMobileArr['user'][] = $name;
- continue;
- }
- $users['phoneNum'][] = $mobile;
- $users['para'][] = [
- "name" => $name,
- "meetdate" => $meetTime,
- "meetname" => $meetName,
- "meetroom" => $meetRoom
- ];
- }
- if (count($users['phoneNum']) > 0) {
- m('send_sms')->sendBatchSms($users['phoneNum'], $users['para'], 1);
- }
- }
- // 部门
- if (count($deptIds) > 0) {
- // $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(',', $deptIds).") ";
- // $deptSql = "SELECT * FROM [Q]admin WHERE FIND_IN_SET(id, (SELECT headid FROM [Q]dept WHERE id in (".implode(',', $deptIds)."))";
- $deptSql = "SELECT distinct a.mobile, b.name FROM zqoa_admin a JOIN zqoa_dept b ON FIND_IN_SET(a.id, b.headid) > 0 WHERE b.id IN (".implode(',', $deptIds).")";
- $dInfo = $this->db->getall($deptSql);
- for ($i = 0; $i < count($dInfo); $i++) {
- $mobile = $dInfo[$i]['mobile'];
- $deptName = $dInfo[$i]['name']; // 部门名
- if (empty($mobile)) {
- $nullMobileArr['dept'][] = $name;
- continue;
- }
- $depts['phoneNum'][] = $mobile;
- $depts['para'][] = [
- "deptname" => $deptName,
- "meetdate" => $meetTime,
- "meetname" => $meetName,
- "meetroom" => $meetRoom
- ];
- }
- if (isset($depts['phoneNum']) && count($depts['phoneNum']) > 0) {
- m('send_sms')->sendBatchSms($depts['phoneNum'], $depts['para'], 3);
- }
- }
- $nullMobileInfo = '';
- if (count($nullMobileArr['user']) > 0) {
- $nullMobileInfo .= "以下用户未设手机号:".implode(',', $nullMobileArr['user'])."。";
- }
- if (count($nullMobileArr['dept']) > 0) {
- $nullMobileInfo .= "以下部门未设手机号:".implode(',', $nullMobileArr['dept'])."。";
- }
- if (!empty($nullMobileInfo)) {
- m("log")->addlog("会议短信", $nullMobileInfo);
- };
- }
- // 提醒审批
- public function meetingAuditSms($meetId, $setp) {
- if (empty($meetId)) {
- m("log")->addlog("短信发送", "会议Id为空");
- return;
- }
- // 获取当前会议信息
- $meeting = m("meeting")->getone("id={$this->id}");
- $meetTime = $meeting['start_time']; // 时间
- $meetTime = date('m月d日H点i分', strtotime($meetTime));
- $meetName = $this->strLength35($meeting['title']); // 主题
- $smsInfo = [];
- if ($setp == 0) {
- m("log")->addlog("会议室审批", "提醒部门领导审批【".$meetName."】");
- $checkid = $this->nowcourse['checkid'];
- } else {
- $checkid = $this->nextcourse['checkid'];
- m("log")->addlog("会议室审批", "提醒管理员审批【".$meetName."】");
- }
- if (!empty($checkid)) {
- $cAdmins = m("admin")->getall("id in ({$checkid})");
- if (!empty($cAdmins) && is_array($cAdmins)) {
- for ($i = 0; $i < count($cAdmins); $i++) {
- $user = $cAdmins[$i];
- $mobile = $user['mobile']; // 领导手机号
- $meetUName = $this->rs['attn']; // 申请人姓名
- if (!empty($mobile)) {
- $smsInfo['phoneNum'][] = $mobile;
- $smsInfo['para'][] = [
- "usernam" => $meetUName,
- "username" => $meetUName,
- "meetingname" => $meetName,
- "begindate" => $meetTime,
- ];
- }
- }
- if (count($smsInfo['phoneNum']) > 0) {
- m('send_sms')->sendBatchSms($smsInfo['phoneNum'], $smsInfo['para'], 2);
- }
- }
- }
- }
- // 提醒申请人
- public function meetingApplicantSms($meetId) {
- if (empty($meetId)) {
- m("log")->addlog("短信发送", "会议Id为空");
- return;
- }
- if (empty($this->rs)) {
- m("log")->addlog("短信发送", "表单数据为空");
- return;
- }
- // 获取当前会议信息
- $meeting = m("meeting")->getone("id={$this->id}");
- $uname = $this->rs['optname'];
- $mdate = date('m月d日H点i分', strtotime($this->rs['start_time']));
- $mname = $this->strLength35($this->rs['title']);
- $mobile = $this->rs['mobile'];
- $smsInfo['phoneNum'][] = $mobile;
- $smsInfo['para'][] = [
- "username" => $uname,
- "date" => $mdate,
- "meetname" => $mname
- ];
- if (count($smsInfo['phoneNum']) > 0) {
- m('send_sms')->sendBatchSms($smsInfo['phoneNum'], $smsInfo['para'], 4);
- }
- }
- public function meetingMaXuSms($meetId) {
- if (empty($meetId)) {
- m("log")->addlog("短信发送", "会议Id为空");
- return;
- }
- if (empty($this->rs)) {
- m("log")->addlog("短信发送", "表单数据为空");
- return;
- }
- $uname = "马旭";
- $mdate = date('m月d日H点i分', strtotime($this->rs['start_time']));
- $mname = $this->strLength35($this->rs['title']);
- $mobile = "18695503090";
- $smsInfo['phoneNum'][] = $mobile;
- $smsInfo['para'][] = [
- "username" => $uname,
- "date" => $mdate,
- "meetname" => $mname
- ];
- if (count($smsInfo['phoneNum']) > 0) {
- m('send_sms')->sendBatchSms($smsInfo['phoneNum'], $smsInfo['para'], 4);
- }
- }
- // 固定会议,每日改变会议日期
- public function fixedMeetings($mid='') {
- $meets = $this->getall('fixed=1');
- for ($i = 0; $i < count($meets); $i++) {
- $meet = $meets[$i];
- $date = date('Y-m-d', strtotime('+1 day'));
- $id = $meet['id'];
- $st = $meet['start_time'];
- $et = $meet['end_time'];
- $st = $date.' '.substr($st, 11);
- $et = $date.' '.substr($et, 11);
- m('meeting')->update([
- 'start_time'=>$st,
- 'end_time'=>$et,
- 'meet_state' => 0,
- 'is_hand' => 0
- ], "id={$id}");
- }
- }
- function strLength35($str) {
- if (strlen($str) > 35) {
- $str = substr($str, 0, 35);
- $str = substr_replace($str, '…', 34, 1);
- }
- return $str;
- }
- }
|