meetingModel.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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['state'];
  42. $is_hand = $rs['is_hand'];
  43. $nzt = $zt;
  44. $time = time();
  45. $stime = strtotime($rs['meeting_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. }
  55. }
  56. if ($stime <= $time && $nzt != 2){
  57. $nzt = 1;
  58. }
  59. // 更新数据状态
  60. if($zt != $nzt){
  61. $this->update('state='.$nzt.'', $rs['id']);
  62. $zt = $nzt;
  63. }
  64. // 将id转换为文字
  65. $rs['state'] = $this->getstatezt($zt);
  66. return $rs;
  67. }
  68. public function getstatezt($zt)
  69. {
  70. return '<font color="'.$this->hyarrb[$zt].'">'.$this->hyarra[$zt].'</font>';
  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. break;
  89. }
  90. }
  91. if (isset($topics[count($topics) - 1]) && $topics[count($topics) - 1]['topic_state'] == 2) {
  92. m('meeting')->update(['is_hand'=>2,'state'=>2], "id={$this->id}");
  93. }
  94. } else if ($ors['num'] == 'enableMeeting') {
  95. $time = time();
  96. $stime = strtotime($this->rs['meeting_time']);
  97. $etime = strtotime($this->rs['end_time']);
  98. if ($stime < $time){
  99. $data = [
  100. 'state'=>1,
  101. 'is_hand'=>2
  102. ];
  103. } else if ($stime >= $time) {
  104. $data = [
  105. 'state'=>0,
  106. 'is_hand'=>2
  107. ];
  108. }
  109. m('meeting')->update($data, "id={$this->id}");
  110. }
  111. }
  112. //删除单据时调用
  113. public function flowdeletebill($sm) {
  114. // m('meet_sys')->deleteMeetingRoom($this->rs);
  115. }
  116. //流程全部完成后调用
  117. public function flowcheckfinsh($sm) {
  118. // 会议议题状态全部设置为1
  119. m('meeting_topic')->update(['topic_state'=>'1'], 'mid='.$this->id);
  120. }
  121. //提交时调用
  122. protected function flowsubmit($na, $sm) {
  123. if ($this->id == null) {
  124. return ;
  125. }
  126. }
  127. }