meetingModel.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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
  21. where id <> '.$id.'
  22. and meet_state in (0, 1)
  23. union all
  24. select id, meeting_room, start_time, end_time, title
  25. from [Q]meeting_key
  26. where meet_state in (0, 1)
  27. ';
  28. } else {
  29. $sql = /** @lang text */
  30. 'select id, meeting_room, start_time, end_time, title
  31. from [Q]meeting where meet_state in (0, 1)
  32. union all
  33. select id, meeting_room, start_time, end_time, title
  34. from [Q]meeting_key where id <> '.$id.' and meet_state in (0, 1)';
  35. }
  36. m('log')->addlog("验证1", $sql);
  37. $rows = $this->db->getall($sql);
  38. foreach($rows as $k=>$rs){
  39. // m('log')->addlog("验证2", $rs['meeting_room']);
  40. // m('log')->addlog("验证3", $hyname);
  41. if($rs['meeting_room'] != $hyname)continue;
  42. $sdt = $rs['start_time'];
  43. $edt = $rs['end_time'];
  44. // m('log')->addlog("验证", json_encode($rs));
  45. if(
  46. ($sdt<=$startdt && $edt>$startdt)
  47. || ($sdt<$enddt && $edt>=$enddt)
  48. || ($sdt>$startdt && $edt<$enddt)
  49. || ($sdt==$startdt && $edt==$enddt)
  50. )$msg = '该会议室的时间段已被申请过了,主题“'.$rs['title'].'”';
  51. }
  52. return $msg;
  53. }
  54. public function firstMeetingTopicStart($meeting_id) {
  55. $topic = m('meeting_topics')->getall("mid={$meeting_id}", "id", 'sort');
  56. if (isset($topic[0]['id'])) {
  57. m('meeting_topics')->update(['topic_state'=>'2'], 'id='.$topic[0]['id']);
  58. }
  59. if (isset($topic[1]['id'])) {
  60. m('meeting_topics')->update(['topic_state'=>'1'], 'id='.$topic[1]['id']);
  61. }
  62. }
  63. // 会议室状态
  64. public function getstatezt($zt)
  65. {
  66. if (isset($this->hyarrb[$zt])) {
  67. $html = '<font color="'.$this->hyarrb[$zt].'">'.$this->hyarra[$zt].'</font>';
  68. return $html;
  69. } else {
  70. return null;
  71. }
  72. }
  73. // 会议状态
  74. public function meetingState($stime, $etime, $type=1) {
  75. // type == 1 获取状态码, type==2获取状态名
  76. $code = [0, 1, 2];
  77. $info = m('meeting')->hyarra;
  78. if ($stime > date("Y-m-d H:i:s")) {
  79. // 开始时间比当前时间大——未开始
  80. return $type == 1 ? $code[0] : $info[0];
  81. } else if ($etime < date("Y-m-d H:i:s")) {
  82. // 当前时间 比 结束时间比——已结束
  83. return $type == 1 ? $code[2] : $info[2];
  84. } else {
  85. // 在时间段内——会议中
  86. return $type == 1 ? $code[1] : $info[1];
  87. }
  88. }
  89. }