meetingModel.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. class flow_meetingClassModel extends flowModel
  3. {
  4. public $hyarra, $ytarra, $hyarrb, $dbobj, $reatearr;
  5. public function initModel()
  6. {
  7. $this->hyarra = array('正常','会议中','结束','取消');
  8. $this->ytarra = array('等待','待进行','进行中','已结束');
  9. $this->hyarrb = array('green','blue','#ff6600','#888888');
  10. $this->dbobj = c('date');
  11. $this->reatearr = array(
  12. 'd' => '每天',
  13. 'w1' => '每周一',
  14. 'w2' => '每周二',
  15. 'w3' => '每周三',
  16. 'w4' => '每周四',
  17. 'w5' => '每周五',
  18. 'w6' => '每周六',
  19. 'w7' => '每周日',
  20. 'm' => '每月',
  21. 'y' => '每年',
  22. );
  23. }
  24. //子表数据替换处理$lx=0编辑时,1展示时
  25. protected function flowsubdata($rows, $lx=0){
  26. for ($i = 0; $i < count($rows); $i++) {
  27. if (isset($rows[$i]['topic_state']) && !empty($rows[$i]['topic_state'])) {
  28. $index = $rows[$i]['topic_state'] ?? 1;
  29. $rows[$i]['topic_state'] = $this->ytarra[$index];
  30. } else {
  31. $id = isset($rows[$i]['id']);
  32. m('meeting_topics')->update(['topic_state'=>1], "id={$id}");
  33. }
  34. }
  35. return $rows;
  36. }
  37. // 初始化单据可替换其他属性,$lx,0默认,1详情展示,2列表显示,3打印页,4外部详情页
  38. public function flowrsreplace($rs, $lx=0)
  39. {
  40. // m('log')->addlog('会议单据', json_encode($rs, true));
  41. $zt = $rs['meet_state'];
  42. $is_hand = $rs['is_hand'];
  43. $nzt = $zt;
  44. $time = time();
  45. $stime = strtotime($rs['start_time']);
  46. $etime = strtotime($rs['end_time']);
  47. if($is_hand != 2){
  48. if($etime < $time){
  49. $nzt = 2;
  50. } else if ($stime > $time){
  51. $nzt = 0;
  52. } else {
  53. $nzt = 1;
  54. $topic = m('meeting_topics')->getone("mid={$this->id}",'id, topic_state', 'sort');
  55. if (isset($topic['id']) && $topic['topic_state']<2) {
  56. m('meeting')->firstMeetingTopicStart($this->id);
  57. }
  58. }
  59. }
  60. if ($stime <= $time && $nzt != 2) {
  61. $nzt = 1;
  62. }
  63. // 更新数据状态
  64. if($zt != $nzt){
  65. $this->update('meet_state='.$nzt.'', $rs['id']);
  66. $zt = $nzt;
  67. }
  68. // 将id转换为文字
  69. $rs['meet_state'] = $this->getstatezt($zt);
  70. return $rs;
  71. }
  72. public function getstatezt($zt)
  73. {
  74. if (isset($this->hyarrb[$zt])) {
  75. $html = '<font color="'.$this->hyarrb[$zt].'">'.$this->hyarra[$zt].'</font>';
  76. return $html;
  77. } else {
  78. return null;
  79. }
  80. }
  81. // $ors当前单据操作信息,$crs提交过来的信息
  82. public function flowoptmenu($ors, $crs)
  83. {
  84. // 切换会议议题
  85. if ($ors['num'] == 'changeTopic') {
  86. $topics = $this->db->getall("select * from `[Q]meeting_topics` where mid = {$this->id} order by sort");
  87. for ($i = 0; $i < count($topics); $i++) {
  88. if(isset($topics[$i]['topic_state']) && $topics[$i]['topic_state'] == 2) {
  89. $id = $topics[$i]['id'];
  90. $data = ['topic_state'=>$topics[$i]['topic_state']+1];
  91. m('meeting_topics')->update($data, "id={$id}");
  92. if (isset($topics[$i+1]['topic_state'])) {
  93. $id = $topics[$i+1]['id'];
  94. $data = ['topic_state'=>2];
  95. m('meeting_topics')->update($data, "id={$id}");
  96. }
  97. if (isset($topics[$i+2]['topic_state'])) {
  98. $id = $topics[$i+2]['id'];
  99. $data = ['topic_state'=>1];
  100. m('meeting_topics')->update($data, "id={$id}");
  101. }
  102. break;
  103. }
  104. }
  105. if (isset($topics[count($topics) - 1]) && $topics[count($topics) - 1]['topic_state'] == 2) {
  106. m('meeting')->update(['is_hand'=>2,'meet_state'=>2], "id={$this->id}");
  107. }
  108. } else if ($ors['num'] == 'enableMeeting') {
  109. $time = time();
  110. $stime = strtotime($this->rs['start_time']);
  111. $etime = strtotime($this->rs['end_time']);
  112. if ($stime < $time){
  113. $data = [
  114. 'meet_state'=>1,
  115. 'is_hand'=>2
  116. ];
  117. } else if ($stime >= $time) {
  118. $data = [
  119. 'meet_state'=>0,
  120. 'is_hand'=>2
  121. ];
  122. }
  123. m('meeting')->update($data, "id={$this->id}");
  124. $topic = m('meeting_topics')->getone("mid={$this->id}", "id", 'sort desc');
  125. if (isset($topic['id'])) {
  126. m('meeting_topics')->update(['topic_state'=>'2'], 'id='.$topic['id']);
  127. }
  128. } else if ($ors['num'] == 'disenableMeeting') {
  129. // $data = [
  130. // 'meet_state'=>2,
  131. // 'is_hand'=>2
  132. // ];
  133. //
  134. // m('meeting_key')->update($data, "id={$this->id}");
  135. }
  136. }
  137. //删除单据时调用
  138. public function flowdeletebill($sm) {
  139. // m('meet_sys')->deleteMeetingRoom($this->rs);
  140. }
  141. //流程全部完成后调用
  142. public function flowcheckfinsh($sm) {
  143. // 会议议题状态全部设置为1
  144. // m('meeting_topics')->update(['topic_state'=>'1'], 'mid='.$this->id);
  145. }
  146. //提交时调用
  147. protected function flowsubmit($na, $sm) {
  148. if ($this->id == null) {
  149. return ;
  150. }
  151. }
  152. }