meetingModel.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. class meetingClassModel extends Model
  3. {
  4. public $hyarra, $ytarra, $hyarrb;
  5. public function initModel()
  6. {
  7. $this->hyarra = array('等待中', '会议中', '结束', '取消');
  8. $this->ytarra = array('等待', '待进行', '进行中', '已结束');
  9. $this->hyarrb = array('green', 'blue', '#ff6600', '#888888');
  10. }
  11. /**
  12. * 判断会议室是否重复申请了
  13. */
  14. public function isapplymsg($startdt, $enddt, $hyname, $id=0, $meetType=1)
  15. {
  16. $msg = '';
  17. if ($meetType == 1) {
  18. $sql = /** @lang text */
  19. 'select id, meeting_room, start_time, end_time, title
  20. from [Q]meeting where id <> '.$id.' and meet_state in (0, 1)
  21. union all
  22. select id, meeting_room, start_time, end_time, title
  23. from [Q]meeting_key where meet_state in (0, 1)';
  24. } else {
  25. $sql = /** @lang text */
  26. 'select id, meeting_room, start_time, end_time, title
  27. from [Q]meeting where meet_state in (0, 1)
  28. union all
  29. select id, meeting_room, start_time, end_time, title
  30. from [Q]meeting_key where id <> '.$id.' and meet_state in (0, 1)';
  31. }
  32. // m('log')->addlog("验证", $sql);
  33. $rows = $this->db->getall($sql);
  34. foreach($rows as $k=>$rs){
  35. if($rs['meeting_room'] != $hyname)continue;
  36. $sdt = $rs['start_time'];
  37. $edt = $rs['end_time'];
  38. // m('log')->addlog("验证", json_encode($rs));
  39. if(
  40. ($sdt<=$startdt && $edt>$startdt)
  41. || ($sdt<$enddt && $edt>=$enddt)
  42. || ($sdt>$startdt && $edt<$enddt)
  43. || ($sdt==$startdt && $edt==$enddt)
  44. )$msg = '该会议室的时间段已被申请过了,主题“'.$rs['title'].'”';
  45. }
  46. return $msg;
  47. }
  48. public function firstMeetingTopicStart($meeting_id) {
  49. $topic = m('meeting_topics')->getall("mid={$meeting_id}", "id", 'sort');
  50. if (isset($topic[0]['id'])) {
  51. m('meeting_topics')->update(['topic_state'=>'2'], 'id='.$topic[0]['id']);
  52. }
  53. if (isset($topic[1]['id'])) {
  54. m('meeting_topics')->update(['topic_state'=>'1'], 'id='.$topic[1]['id']);
  55. }
  56. }
  57. // 会议室状态
  58. public function getstatezt($zt)
  59. {
  60. if (isset($this->hyarrb[$zt])) {
  61. $html = '<font color="'.$this->hyarrb[$zt].'">'.$this->hyarra[$zt].'</font>';
  62. return $html;
  63. } else {
  64. return null;
  65. }
  66. }
  67. // 会议状态
  68. public function meetingState($stime, $etime, $type=1) {
  69. // type == 1 获取状态码, type==2获取状态名
  70. $code = [0, 1, 2];
  71. $info = m('meeting')->hyarra;
  72. if ($stime > date("Y-m-d H:i:s")) {
  73. // 开始时间比当前时间大——未开始
  74. return $type == 1 ? $code[0] : $info[0];
  75. } else if ($etime < date("Y-m-d H:i:s")) {
  76. // 当前时间 比 结束时间比——已结束
  77. return $type == 1 ? $code[2] : $info[2];
  78. } else {
  79. // 在时间段内——会议中
  80. return $type == 1 ? $code[1] : $info[1];
  81. }
  82. }
  83. }