| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?php
- class meetingClassModel extends Model
- {
- public $hyarra, $ytarra, $hyarrb;
- public function initModel()
- {
- $this->hyarra = array('等待中', '会议中', '结束', '取消');
- $this->ytarra = array('等待', '待进行', '进行中', '已结束');
- $this->hyarrb = array('green', 'blue', '#ff6600', '#888888');
- }
- // ---------------验证--------------------
- /**
- * 判断会议室是否重复申请了
- */
- public function isapplymsg($startdt, $enddt, $roomName, $id=0, $meetType=1)
- {
- $msg = '';
- if ($meetType == 1) {
- $sql = /** @lang text */
- 'SELECT * FROM (
- SELECT 1 as type, id, meeting_room, start_time, end_time, title, null as tzone
- FROM [Q]meeting
- WHERE id <> '.$id.'
- AND meet_state in (0, 1)
- AND start_time regexp date_format("'.$startdt.'", "%Y-%m-%d")
- UNION All
- select 2 as type, id, meeting_room, start_time, end_time, title, tzone
- FROM [Q]meeting_key
- WHERE meet_state in (0, 1)
- AND start_time regexp date_format("'.$startdt.'", "%Y-%m-%d")
- ) t order by type desc, start_time asc
- ';
- } else {
- $sql = /** @lang text */
- 'SELECT * FROM (
- SELECT 1 as type, id, meeting_room, start_time, end_time, title, null as tzone
- FROM [Q]meeting
- WHERE meet_state in (0, 1)
- AND start_time regexp date_format("'.$startdt.'", "%Y-%m-%d")
- UNION All
- SELECT 2 as type, id, meeting_room, start_time, end_time, title, tzone
- FROM [Q]meeting_key
- WHERE id <> '.$id.'
- AND start_time regexp date_format("'.$startdt.'", "%Y-%m-%d")
- AND meet_state in (0, 1)
- ) t order by type desc, start_time asc
- ';
- }
- $rows = $this->db->getall($sql);
- foreach($rows as $k=>$rs){
- if($rs['meeting_room'] != $roomName)continue;
- $sdt = $rs['start_time'];
- $edt = $rs['end_time'];
- $type = $rs['type'];
- if ($type == 2) {
- $tp = m("meeting_key")->tp[$rs['tzone']];
- $sdt = substr($startdt, 0, 10).' '.$tp['start_time'];
- $edt = substr($startdt, 0, 10).' '.$tp['end_time'];
- if(
- ($sdt<=$startdt && $edt>$startdt)
- || ($sdt<$enddt && $edt>=$enddt)
- || ($sdt>$startdt && $edt<$enddt)
- || ($sdt==$startdt && $edt==$enddt)
- )$msg = '该会议室的时间段已被申请过了,主题“'.$rs['title'].'”';
- return $msg;
- }
- if ($type == 1) {
- if(
- ($sdt<=$startdt && $edt>$startdt)
- || ($sdt<$enddt && $edt>=$enddt)
- || ($sdt>$startdt && $edt<$enddt)
- || ($sdt==$startdt && $edt==$enddt)
- )$msg = '该会议室的时间段已被申请过了,主题“'.$rs['title'].'”';
- return $msg;
- }
- }
- return $msg;
- }
- // ---------------所有类型会议数据--------------------
- // 获取今日有效会议
- public function getMeetingEffective($uid) {
- $sql = "select * from [Q]meeting where uid={$uid} and meet_state in (0, 1) and start_time>='".date("Y-m-d")."' order by start_time asc";
- return $this->db->getall($sql);
- }
- // ---------------flow相关--------------------
- // 第一个议题状态开始
- public function firstMeetingTopicStart($meeting_id) {
- $topic = m('meeting_topics')->getall("mid={$meeting_id}", "id", 'sort');
- if (isset($topic[0]['id'])) {
- m('meeting_topics')->update(['topic_state'=>'2'], 'id='.$topic[0]['id']);
- }
- if (isset($topic[1]['id'])) {
- m('meeting_topics')->update(['topic_state'=>'1'], 'id='.$topic[1]['id']);
- }
- }
- // 会议室状态样式
- 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 meetingState($stime, $etime, $type=1) {
- // type == 1 获取状态码, type==2获取状态名
- $code = [0, 1, 2];
- $info = m('meeting')->hyarra;
- if ($stime > date("Y-m-d H:i:s")) {
- // 开始时间比当前时间大——未开始
- return $type == 1 ? $code[0] : $info[0];
- } else if ($etime < date("Y-m-d H:i:s")) {
- // 当前时间 比 结束时间比——已结束
- return $type == 1 ? $code[2] : $info[2];
- } else {
- // 在时间段内——会议中
- return $type == 1 ? $code[1] : $info[1];
- }
- }
- // 根据会议时间-更换会议状态
- public function meetingStateChange($mid, $stime, $etime) {
- $state = $this->meetingState($stime, $etime, 1);
- $this->update(["meet_state"=>$state], "id=".$mid);
- }
- }
|