meeting_keyModel.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. class flow_meeting_keyClassModel extends flowModel
  3. {
  4. public $meeting_room;
  5. protected function flowinit(){
  6. $this->subsubdatastyle = "custom:min-width:60px; padding: 15px; vertical-align:top;";
  7. $this->meeting_room = m("meeting_room")->meetingRoomIdList();
  8. }
  9. //删除单据时调用
  10. public function flowdeletebill($sm) {
  11. }
  12. //流程全部完成后调用
  13. public function flowcheckfinsh($sm) {
  14. }
  15. //提交时调用
  16. protected function flowsubmit($na, $sm) {
  17. if ($na != '编辑') {
  18. // 提交时初始化为0
  19. // m('meeting_topics')->update(["topic_state"=>0], 'mid='.$this->id);
  20. // m('meeting_key')->update(["meet_state"=>1], 'id='.$this->id);
  21. }
  22. // $meet = m('meeting')->getone("id={$this->id}",'start_time');
  23. //
  24. // if (isset($meet['start_time']) && strtotime($meet['start_time']) > time()) {
  25. // $topic = m('meeting_topics')->getone("mid={$this->id}",'id, topic_state', 'sort');
  26. // if (isset($topic['id']) && $topic['topic_state'] < 2) {
  27. // m('meeting')->firstMeetingTopicStart($this->id);
  28. // }
  29. // } else {
  30. // $topic = m('meeting_topics')->getone("mid={$this->id}",'id, topic_state', 'sort');
  31. // if (isset($topic['id']) && $topic['topic_state'] < 2) {
  32. // m('meeting')->update(["meet_state"=>1], "id=".$topic['id']);
  33. // }
  34. // }
  35. }
  36. // 初始化单据可替换其他属性,$lx,0默认,1详情展示,2列表显示,3打印页,4外部详情页
  37. public function flowrsreplace($rs, $lx=0)
  38. {
  39. // m('log')->addlog('会议单据', json_encode($rs, true));
  40. $this->id = $rs['id'];
  41. $zt = $rs['meet_state'];
  42. $is_hand = $rs['is_hand'] ?? 0;
  43. $room_id = $rs['room_id'];
  44. $nzt = $zt;
  45. $time = time();
  46. $stime = strtotime($rs['start_time']);
  47. $etime = strtotime($rs['end_time']);
  48. // 会议状态
  49. if($is_hand != 1){
  50. if($etime < $time){
  51. $nzt = 2;
  52. } else if ($stime > $time){
  53. $nzt = 0;
  54. }
  55. }
  56. // 会议开始时的处理
  57. if ($stime <= $time && $etime > $time) {
  58. $nzt = 1;
  59. // 会议开始,议题自动调整开始第一项
  60. $topic = m('meeting_topics')->getone("mid={$this->id}",'id, topic_state', 'sort');
  61. if (isset($topic['id']) && $topic['topic_state'] < 2) {
  62. m('meeting')->firstMeetingTopicStart($this->id);
  63. }
  64. }
  65. // 更新数据状态
  66. if($zt != $nzt) {
  67. $this->update('meet_state='.$nzt.'', $rs['id']);
  68. $zt = $nzt;
  69. }
  70. // 会议状态-将id转换为文字
  71. $rs['meet_state'] = m("meeting")->getstatezt($zt);
  72. $rs['room_id'] = $this->meeting_room[$room_id]['room_name'];
  73. return $rs;
  74. }
  75. // $ors当前单据操作信息,$crs提交过来的信息
  76. public function flowoptmenu($ors, $crs)
  77. {
  78. // 切换会议议题
  79. if ($ors['num'] == 'changeTopic') {
  80. $topics = $this->db->getall("select * from `[Q]meeting_topics` where mid = {$this->id} order by sort");
  81. for ($i = 0; $i < count($topics); $i++) {
  82. if ($topics[$i]['topic_state'] == 2) {
  83. $id = $topics[$i]['id'];
  84. $data = [
  85. 'topic_state' => $topics[$i]['topic_state'] + 1
  86. ];
  87. m('meeting_topics')->update($data, "id={$id}");
  88. // 更新下一个状态
  89. if (isset($topics[$i + 1]['topic_state'])) {
  90. $id = $topics[$i + 1]['id'];
  91. $data = ['topic_state' => 2];
  92. m('meeting_topics')->update($data, "id={$id}");
  93. }
  94. if (isset($topics[$i + 2]['topic_state'])) {
  95. $id = $topics[$i + 2]['id'];
  96. $data = ['topic_state' => 1];
  97. m('meeting_topics')->update($data, "id={$id}");
  98. }
  99. break;
  100. }
  101. }
  102. if (isset($topics[count($topics) - 1]) && $topics[count($topics) - 1]['topic_state'] == 2) {
  103. m('meeting_key')->update(['is_hand' => 1, 'meet_state' => 2], "id={$this->id}");
  104. }
  105. } else if ($ors['num'] == 'enableMeeting') {
  106. $time = time();
  107. $stime = strtotime($this->rs['start_time']);
  108. $etime = strtotime($this->rs['end_time']);
  109. if ($stime < $time){
  110. $data = [
  111. 'meet_state'=>1,
  112. 'is_hand'=>1
  113. ];
  114. } else if ($stime >= $time) {
  115. $data = [
  116. 'meet_state'=>0,
  117. 'is_hand'=>1
  118. ];
  119. }
  120. m('meeting_key')->update($data, "id={$this->id}");
  121. // $topic = m('meeting_topics')->getone("mid={$this->id}", "id", 'sort desc');
  122. // if (isset($topic['id'])) {
  123. // m('meeting_topics')->update(['topic_state'=>'2'], 'id='.$topic['id']);
  124. // }
  125. } else if ($ors['num'] == 'disenableMeeting') {
  126. // $data = [
  127. // 'meet_state'=>2,
  128. // 'is_hand'=>1
  129. // ];
  130. //
  131. // m('meeting_key')->update($data, "id={$this->id}");
  132. }
  133. }
  134. // 子表数据替换处理$lx=0编辑时,1展示时
  135. protected function flowsubdata($rows, $lx=0){
  136. if ($lx == 1) {
  137. for ($i = 0; $i < count($rows); $i++) {
  138. $index = $rows[$i]['topic_state'] ?? 0;
  139. $rows[$i]['topic_state'] = $this->getTopicState($index);
  140. // if (isset($rows[$i]['topic_state']) && !empty($rows[$i]['topic_state'])) {
  141. // $rows[$i]['topic_state'] = m('meeting')->ytarra[$index];
  142. // } else {
  143. //// $id = $rows[$i]['id'];
  144. //// m('meeting_topics')->update(['topic_state'=>1], "id={$id}");
  145. // }
  146. }
  147. }
  148. return $rows;
  149. }
  150. public function getTopicState($zt)
  151. {
  152. $colors = ["#ff83ec", "#ff8b1a", "#00c959", "#ff4974"];
  153. if (isset(m('meeting')->hyarrb[$zt])) {
  154. $html = '<font style="background-color:'.$colors[$zt].'; padding: 4px 8px; border-radius: 4px;">'.m('meeting')->ytarra[$zt].'</font>';
  155. return $html;
  156. } else {
  157. return null;
  158. }
  159. }
  160. }