| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?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, $hyname, $id=0, $meetType=1)
- {
- $msg = '';
- if ($meetType == 1) {
- $sql = /** @lang text */
- 'select id, meeting_room, start_time, end_time, title
- from [Q]meeting where id <> '.$id.' and meet_state in (0, 1)
- union all
- select id, meeting_room, start_time, end_time, title
- from [Q]meeting_key where meet_state in (0, 1)';
- } else {
- $sql = /** @lang text */
- 'select id, meeting_room, start_time, end_time, title
- from [Q]meeting where meet_state in (0, 1)
- union all
- select id, meeting_room, start_time, end_time, title
- from [Q]meeting_key where id <> '.$id.' and meet_state in (0, 1)';
- }
- // m('log')->addlog("验证", $sql);
- $rows = $this->db->getall($sql);
- foreach($rows as $k=>$rs){
- if($rs['meeting_room'] != $hyname)continue;
- $sdt = $rs['start_time'];
- $edt = $rs['end_time'];
- // m('log')->addlog("验证", json_encode($rs));
- if(
- ($sdt<=$startdt && $edt>$startdt)
- || ($sdt<$enddt && $edt>=$enddt)
- || ($sdt>$startdt && $edt<$enddt)
- || ($sdt==$startdt && $edt==$enddt)
- )$msg = '该会议室的时间段已被申请过了,主题“'.$rs['title'].'”';
- }
- return $msg;
- }
- 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];
- }
- }
- }
|