meeting_keyModel.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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. $tzone = m('meeting_key')->tp[$rs['tzone']]['name'];
  49. if (isset($tzone) && !empty($tzone)) {
  50. $rs['tzone'] = $tzone;
  51. }
  52. // 会议状态
  53. // 有会议开始、结束时间时开启↓↓↓↓↓↓↓↓↓
  54. // if($is_hand != 1){
  55. // if($etime < $time){
  56. // $nzt = 2;
  57. // } else if ($stime > $time){
  58. // $nzt = 0;
  59. // }
  60. // }
  61. // 会议开始时的处理
  62. // if (($stime <= $time && $etime > $time) || ($is_hand == 1 && $zt == 1)) {
  63. // $nzt = 1;
  64. // // 会议开始,议题自动调整开始第一项
  65. // $topic = m('meeting_topics')->getone("mid={$this->id}",'id, topic_state, topic_title', 'sort');
  66. // if (isset($topic['id']) && $topic['topic_state'] < 2) {
  67. // m('meeting')->firstMeetingTopicStart($this->id);
  68. // // 当前议题
  69. // }
  70. //
  71. // // 展示近几个议题状态
  72. // $topics = m('meeting_topics')->getall("mid={$this->id}",'id, topic_state, topic_title', 'sort');
  73. // for ($i = 0; $i < count($topics); $i++) {
  74. // $topic = $topics[$i];
  75. // if ($topic['topic_state'] == 3) {
  76. // $rs['topic'] = $this->getTopicInfoState($topic);
  77. // }
  78. // if ($topic['topic_state'] == 1) {
  79. // $rs['topic'] .= $this->getTopicInfoState($topic);
  80. // }
  81. // if ($topic['topic_state'] == 2) {
  82. // $rs['topic'] .= $this->getTopicInfoState($topic);
  83. // }
  84. // }
  85. //
  86. // } else if ($stime > $time) {
  87. // $topic = m('meeting_topics')->getone("mid={$this->id}",'id, topic_state, topic_title', 'sort asc');
  88. // $rs['topic'] = $this->getTopicInfoState($topic);
  89. // } else {
  90. // $topic = m('meeting_topics')->getone("mid={$this->id}",'id, topic_state, topic_title', 'sort desc');
  91. // $rs['topic'] = $this->getTopicState($topic['topic_state']);
  92. // }
  93. //
  94. // // 更新数据状态
  95. // if($zt != $nzt) {
  96. // $this->update('meet_state='.$nzt.'', $rs['id']);
  97. // $zt = $nzt;
  98. // }
  99. // 有会议开始、结束时间时开启↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
  100. $topic = m('meeting_topics')->getone("mid={$this->id}",'id, topic_state, topic_title', 'sort desc');
  101. // $rs['topic'] = $this->getTopicState($topic['topic_state']);
  102. if ($zt == 0) {
  103. $rs['topic'] = '<font style="color:green;">【会议未开始】</font><br />';
  104. $topic = m('meeting_topics')->getone("mid={$this->id}",'id, topic_state, topic_title', 'sort asc');
  105. $rs['topic'] .= $this->getTopicInfoState($topic);
  106. } else if ($zt == 1) {
  107. // 展示近几个议题状态
  108. $rs['topic'] = '<font style="color:blue;">【会议进行中】</font><br />';
  109. $topics = m('meeting_topics')->getall("mid={$this->id}",'id, topic_state, topic_title', 'sort');
  110. for ($i = 0; $i < count($topics); $i++) {
  111. $topic = $topics[$i];
  112. if ($topic['topic_state'] == 3) {
  113. $rs['topic'] .= $this->getTopicInfoState($topic);
  114. }
  115. if ($topic['topic_state'] == 1) {
  116. $rs['topic'] .= $this->getTopicInfoState($topic);
  117. }
  118. if ($topic['topic_state'] == 2) {
  119. $rs['topic'] .= $this->getTopicInfoState($topic);
  120. }
  121. }
  122. } else if ($zt == 2) {
  123. $rs['topic'] = '<font style="color:red;">【会议已结束】</font>';
  124. }
  125. // 会议状态-将id转换为文字
  126. $rs['meet_state'] = m("meeting")->getstatezt($zt);
  127. $rs['room_id'] = $this->meeting_room[$room_id]['room_name'];
  128. return $rs;
  129. }
  130. //单据判断条件从写$lx类型,$uid用户Id
  131. protected function flowbillwhere($lx, $uid){
  132. // return [
  133. // 'order'=>'meet_state, sort'
  134. // ];
  135. }
  136. // $ors当前单据操作信息,$crs提交过来的信息
  137. public function flowoptmenu($ors, $crs)
  138. {
  139. if ($ors['num'] == 'nextTopic') {
  140. // 下一议题
  141. $topics = $this->db->getall("select * from `[Q]meeting_topics` where mid = {$this->id} order by sort");
  142. for ($i = 0; $i < count($topics); $i++) {
  143. if ($topics[$i]['topic_state'] == 2) {
  144. $id = $topics[$i]['id'];
  145. $data = [
  146. 'topic_state' => $topics[$i]['topic_state'] + 1
  147. ];
  148. m('meeting_topics')->update($data, "id={$id}");
  149. // 更新下一个状态
  150. if (isset($topics[$i + 1]['topic_state'])) {
  151. $id = $topics[$i + 1]['id'];
  152. $data = ['topic_state' => 2];
  153. m('meeting_topics')->update($data, "id={$id}");
  154. }
  155. if (isset($topics[$i + 2]['topic_state'])) {
  156. $id = $topics[$i + 2]['id'];
  157. $data = ['topic_state' => 1];
  158. m('meeting_topics')->update($data, "id={$id}");
  159. }
  160. break;
  161. }
  162. }
  163. if (isset($topics[count($topics) - 1]) && $topics[count($topics) - 1]['topic_state'] == 2) {
  164. m('meeting_key')->update(['is_hand' => 1, 'meet_state' => 2], "id={$this->id}");
  165. }
  166. } else if ($ors['num'] == 'preTopic') {
  167. // 上一议题
  168. $topics = $this->db->getall("select * from `[Q]meeting_topics` where mid = {$this->id} order by sort");
  169. $is_end = 1;
  170. for ($i = 0; $i < count($topics); $i++) {
  171. // 找到结束议题
  172. if ($topics[$i]['topic_state'] == 2) {
  173. $id = $topics[$i]['id'];
  174. // 恢复到上一状态
  175. $data = [
  176. 'topic_state' => $topics[$i]['topic_state'] - 1
  177. ];
  178. m('meeting_topics')->update($data, "id={$id}");
  179. // 更新上一个状态
  180. if (isset($topics[$i - 1]['topic_state'])) {
  181. $id = $topics[$i - 1]['id'];
  182. $data = ['topic_state' => 2];
  183. m('meeting_topics')->update($data, "id={$id}");
  184. }
  185. // 更新下一个状态
  186. if (isset($topics[$i + 1]['topic_state'])) {
  187. $id = $topics[$i + 1]['id'];
  188. $data = ['topic_state' => 0];
  189. m('meeting_topics')->update($data, "id={$id}");
  190. }
  191. if (isset($topics[$i + 2]['topic_state'])) {
  192. $id = $topics[$i + 2]['id'];
  193. $data = ['topic_state' => 0];
  194. m('meeting_topics')->update($data, "id={$id}");
  195. }
  196. $is_end = 0;
  197. break;
  198. }
  199. }
  200. if ($is_end == 1 && isset($topics[$i - 1])) {
  201. m('meeting_topics')->update(['topic_state'=>2], "id={$topics[$i-1]['id']}");
  202. }
  203. } else if ($ors['num'] == 'enableMeeting') {
  204. $time = time();
  205. $stime = strtotime($this->rs['start_time']);
  206. $etime = strtotime($this->rs['end_time']);
  207. if ($stime < $time){
  208. $data = [
  209. 'meet_state'=>1,
  210. 'is_hand'=>1
  211. ];
  212. } else if ($stime >= $time) {
  213. $data = [
  214. 'meet_state'=>0,
  215. 'is_hand'=>1
  216. ];
  217. }
  218. m('meeting_key')->update($data, "id={$this->id}");
  219. // $topic = m('meeting_topics')->getone("mid={$this->id}", "id", 'sort desc');
  220. // if (isset($topic['id'])) {
  221. // m('meeting_topics')->update(['topic_state'=>'2'], 'id='.$topic['id']);
  222. // }
  223. } else if ($ors['num'] == 'disenableMeeting') {
  224. // $data = [
  225. // 'meet_state'=>2,
  226. // 'is_hand'=>1
  227. // ];
  228. //
  229. // m('meeting_key')->update($data, "id={$this->id}");
  230. }
  231. }
  232. // 子表数据替换处理$lx=0编辑时,1展示时
  233. protected function flowsubdata($rows, $lx=0){
  234. if ($lx == 1) {
  235. for ($i = 0; $i < count($rows); $i++) {
  236. $index = $rows[$i]['topic_state'] ?? 0;
  237. $rows[$i]['topic_state'] = $this->getTopicState($index);
  238. // if (isset($rows[$i]['topic_state']) && !empty($rows[$i]['topic_state'])) {
  239. // $rows[$i]['topic_state'] = m('meeting')->ytarra[$index];
  240. // } else {
  241. //// $id = $rows[$i]['id'];
  242. //// m('meeting_topics')->update(['topic_state'=>1], "id={$id}");
  243. // }
  244. }
  245. }
  246. return $rows;
  247. }
  248. public function getTopicState($zt)
  249. {
  250. $colors = ["#ff83ec", "#ff8b1a", "#00c959", "#ff4974"];
  251. if (isset(m('meeting')->hyarrb[$zt])) {
  252. $html = '<font style="background-color:'.$colors[$zt].'; padding: 4px 8px; border-radius: 4px;">'.m('meeting')->ytarra[$zt].'</font>';
  253. return $html;
  254. } else {
  255. return null;
  256. }
  257. }
  258. public function getTopicInfoState($topic)
  259. {
  260. $zt = $topic['topic_state'];
  261. $colors = ["#ff83ec", "#ff8b1a", "#00c959", "#ff4974"];
  262. $title = ["【等待议题】", "【下一议题】", "【当前议题】", "【上一议题】"];
  263. $info = str_replace("\n", "", $title[$zt].":".$topic['topic_title']);
  264. if (isset(m('meeting')->hyarrb[$zt])) {
  265. $html = '<font style="color:'.$colors[$zt].';">'.$info.'</font><br />';
  266. return $html;
  267. } else {
  268. return null;
  269. }
  270. }
  271. }