meetingModel.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. $rows[$i]['topic_state'] = $this->ytarra[$rows[$i]['topic_state'] ?? 1];
  28. }
  29. return $rows;
  30. }
  31. // 初始化单据可替换其他属性,$lx,0默认,1详情展示,2列表显示,3打印页,4外部详情页
  32. public function flowrsreplace($rs, $lx=0)
  33. {
  34. // m('log')->addlog('会议单据', json_encode($rs, true));
  35. $zt = $rs['state'];
  36. $nzt = $zt;
  37. $time = time();
  38. $stime = strtotime($rs['meeting_time']);
  39. $etime = strtotime($rs['end_time']);
  40. // if($zt < 2){
  41. if($etime<$time){
  42. $nzt = 2;
  43. }else if($stime>$time){
  44. // 开始时间大于当前时间,认为会议开始
  45. $nzt = 0;
  46. }else{
  47. $nzt = 1;
  48. }
  49. // }
  50. // if ($nzt != 2 || $nzt != 3) {
  51. // // 状态不是取消、结束,则赋值“正常”
  52. // $nzt = 1;
  53. // }
  54. // 更新数据状态
  55. if($zt != $nzt){
  56. $this->update('state='.$nzt.'', $rs['id']);
  57. $zt = $nzt;
  58. }
  59. // 将id转换为文字
  60. $rs['state'] = $this->getstatezt($zt);
  61. return $rs;
  62. }
  63. public function getstatezt($zt)
  64. {
  65. return '<font color="'.$this->hyarrb[$zt].'">'.$this->hyarra[$zt].'</font>';
  66. }
  67. // $ors当前单据操作信息,$crs提交过来的信息
  68. public function flowoptmenu($ors, $crs)
  69. {
  70. // 切换会议议题
  71. if ($ors['num'] == 'changeTopic') {
  72. $topics = $this->db->getall("select * from `[Q]meeting_topics` where mid = {$this->id} order by sort");
  73. $have_state = False;
  74. // 查找状态为1的
  75. for ($i = 0; $i < count($topics); $i++) {
  76. $data = $topics[$i];
  77. if (isset($data['id'])) {
  78. if ($data['topic_state'] == 1) {
  79. $have_state = True;
  80. m('meeting_topics')->update(['topic_state'=>$data['topic_state']+1], "id={$data['id']}");
  81. } else {
  82. continue;
  83. }
  84. if (isset($topics[$i - 1])) {
  85. $topics[$i-1]['topic_state'] = $data['topic_state']+2;
  86. $id = $topics[$i-1]['id'];
  87. m('meeting_topics')->update(['topic_state'=>$data['topic_state']+2], "id={$id}");
  88. }
  89. if (isset($topics[$i + 1])) {
  90. $topics[$i+1]['topic_state'] = 1;
  91. $id = $topics[$i+1]['id'];
  92. m('meeting_topics')->update(['topic_state'=>1], "id={$id}");
  93. }
  94. break;
  95. }
  96. }
  97. if (!$have_state && $topics[0]['topic_state'] < 1) {
  98. m('meeting_topics')->update(['topic_state'=>1], "id={$topics[0]['id']}");
  99. } else if (!$have_state && $data['topic_state'] == 2) {
  100. m('meeting_topics')->update(['topic_state'=>3], "id={$data['id']}");
  101. }
  102. }
  103. }
  104. //删除单据时调用
  105. public function flowdeletebill($sm) {
  106. // m('meet_sys')->deleteMeetingRoom($this->rs);
  107. }
  108. //流程全部完成后调用
  109. public function flowcheckfinsh($sm) {
  110. // 获取议题信息
  111. $topics = $this->db->getall("select `id`, `topic_title`, `topic_attendee`, `topic_attendee_id`, `topic_state` from `[Q]meeting_topics` where mid = {$this->id} order by sort");
  112. if (isset($topics['id'])) {
  113. m('meeting')->update(['topic_state'=>'1'], "id={$topics[0]['id']}");
  114. }
  115. }
  116. //提交时调用
  117. protected function flowsubmit($na, $sm) {
  118. if ($this->id == null) {
  119. return ;
  120. }
  121. }
  122. }