meeting_keyModel.php 12 KB

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