meetingModel.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. // $ors当前单据操作信息,$crs提交过来的信息
  73. public function flowoptmenu($ors, $crs)
  74. {
  75. // 切换会议议题
  76. if ($ors['num'] == 'changeTopic') {
  77. $topics = $this->db->getall("select * from `[Q]meeting_topics` where mid = {$this->id} order by sort");
  78. for ($i = 0; $i < count($topics); $i++) {
  79. if(isset($topics[$i]['topic_state']) && $topics[$i]['topic_state'] == 2) {
  80. $id = $topics[$i]['id'];
  81. $data = ['topic_state'=>$topics[$i]['topic_state']+1];
  82. m('meeting_topics')->update($data, "id={$id}");
  83. if (isset($topics[$i+1]['topic_state'])) {
  84. $id = $topics[$i+1]['id'];
  85. $data = ['topic_state'=>2];
  86. m('meeting_topics')->update($data, "id={$id}");
  87. }
  88. if (isset($topics[$i+2]['topic_state'])) {
  89. $id = $topics[$i+2]['id'];
  90. $data = ['topic_state'=>1];
  91. m('meeting_topics')->update($data, "id={$id}");
  92. }
  93. break;
  94. }
  95. }
  96. if (isset($topics[count($topics) - 1]) && $topics[count($topics) - 1]['topic_state'] == 2) {
  97. m('meeting')->update(['is_hand'=>2,'meet_state'=>2], "id={$this->id}");
  98. }
  99. } else if ($ors['num'] == 'enableMeeting') {
  100. $time = time();
  101. $stime = strtotime($this->rs['start_time']);
  102. $etime = strtotime($this->rs['end_time']);
  103. if ($stime < $time){
  104. $data = [
  105. 'meet_state'=>1,
  106. 'is_hand'=>2
  107. ];
  108. } else if ($stime >= $time) {
  109. $data = [
  110. 'meet_state'=>0,
  111. 'is_hand'=>2
  112. ];
  113. }
  114. m('meeting')->update($data, "id={$this->id}");
  115. $topic = m('meeting_topics')->getone("mid={$this->id}", "id", 'sort desc');
  116. if (isset($topic['id'])) {
  117. m('meeting_topics')->update(['topic_state'=>'2'], 'id='.$topic['id']);
  118. }
  119. } else if ($ors['num'] == 'disenableMeeting') {
  120. // $data = [
  121. // 'meet_state'=>2,
  122. // 'is_hand'=>2
  123. // ];
  124. //
  125. // m('meeting_key')->update($data, "id={$this->id}");
  126. }
  127. }
  128. //删除单据时调用
  129. public function flowdeletebill($sm) {
  130. // m('meet_sys')->deleteMeetingRoom($this->rs);
  131. }
  132. //流程全部完成后调用
  133. // public function flowcheckfinsh($sm) {
  134. protected function flowcheckfinsh($sm){
  135. // 审批完成给负责人发短信
  136. $meeting = m("meeting")->getone("id={$this->id}");
  137. if (empty($meeting)) return;
  138. m("log")->addlog("会议室审批", "发送短信给".$meeting['attendees']."部门负责人");
  139. foreach (explode(',', $meeting['attendees_id']) as $val) {
  140. if (substr($val, 0,1) == 'u') {
  141. $users[] = substr($val, 1);
  142. } else if (substr($val, 0,1) == 'd') {
  143. $depts[] = substr($val, 1);
  144. }
  145. }
  146. $users = m("admin")->getall("id in (".implode(',', $users).")");
  147. $mobile = [];
  148. foreach ($users as $val) {
  149. $mobile[] = $val['mobile'];
  150. }
  151. if (!empty($depts)) {
  152. $deptSql = "select distinct b.mobile from [Q]dept a left join [Q]admin b on a.headid = b.id where a.id in (".implode(',', $depts).") and a.headid is not null";
  153. m("log")->addlog("会议室审批", $deptSql);
  154. $depts = $this->db->getall($deptSql);
  155. // 部门负责人手机号
  156. foreach ($depts as $val) {
  157. $mobile[] = $val['mobile'];
  158. }
  159. }
  160. m("log")->addlog("会议室审批", "短信包括:".implode(' ', $mobile));
  161. }
  162. //提交时调用
  163. protected function flowsubmit($na, $sm) {
  164. if ($this->id == null) {
  165. return ;
  166. }
  167. }
  168. public function getstatezt($zt)
  169. {
  170. if (isset($this->hyarrb[$zt])) {
  171. $html = '<font color="'.$this->hyarrb[$zt].'">'.$this->hyarra[$zt].'</font>';
  172. return $html;
  173. } else {
  174. return null;
  175. }
  176. }
  177. }