meeting_keyModel.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. class flow_meeting_keyClassModel extends flowModel
  3. {
  4. //删除单据时调用
  5. public function flowdeletebill($sm) {
  6. }
  7. //流程全部完成后调用
  8. public function flowcheckfinsh($sm) {
  9. }
  10. //提交时调用
  11. protected function flowsubmit($na, $sm) {
  12. if ($na == '编辑') {
  13. } else {
  14. m('meeting_topics')->update(["topic_state"=>0], '1=1');
  15. $topic = m('meeting_topics')->getone("mid={$this->id}",'id, topic_state', 'sort');
  16. if (isset($topic['id']) && $topic['topic_state']<2) {
  17. m('meeting')->firstMeetingTopicStart($this->id);
  18. }
  19. }
  20. }
  21. // 初始化单据可替换其他属性,$lx,0默认,1详情展示,2列表显示,3打印页,4外部详情页
  22. public function flowrsreplace($rs, $lx=0)
  23. {
  24. // m('log')->addlog('会议单据', json_encode($rs, true));
  25. $zt = $rs['meet_state'];
  26. $is_hand = $rs['is_hand'] ?? 1;
  27. $nzt = $zt;
  28. $time = time();
  29. $stime = strtotime($rs['start_time']);
  30. $etime = strtotime($rs['end_time']);
  31. if($is_hand != 2){
  32. if($etime < $time){
  33. $nzt = 2;
  34. } else if ($stime > $time){
  35. $nzt = 0;
  36. } else {
  37. $nzt = 1;
  38. $topic = m('meeting_topics')->getone("mid={$this->id}",'id, topic_state', 'sort');
  39. if (isset($topic['id']) && $topic['topic_state']<2) {
  40. m('meeting')->firstMeetingTopicStart($this->id);
  41. }
  42. }
  43. }
  44. if ($stime <= $time && $nzt != 2) {
  45. $nzt = 1;
  46. }
  47. // 更新数据状态
  48. if($zt != $nzt){
  49. $this->update('meet_state='.$nzt.'', $rs['id']);
  50. $zt = $nzt;
  51. }
  52. // 将id转换为文字
  53. $rs['meet_state'] = m("meeting")->getstatezt($zt);
  54. return $rs;
  55. }
  56. // $ors当前单据操作信息,$crs提交过来的信息
  57. public function flowoptmenu($ors, $crs)
  58. {
  59. // 切换会议议题
  60. if ($ors['num'] == 'changeTopic') {
  61. $topics = $this->db->getall("select * from `[Q]meeting_topics` where mid = {$this->id} order by sort");
  62. for ($i = 0; $i < count($topics); $i++) {
  63. if (isset($topics[$i]['topic_state']) && $topics[$i]['topic_state'] == 2) {
  64. $id = $topics[$i]['id'];
  65. $data = ['topic_state' => $topics[$i]['topic_state'] + 1];
  66. m('meeting_topics')->update($data, "id={$id}");
  67. if (isset($topics[$i + 1]['topic_state'])) {
  68. $id = $topics[$i + 1]['id'];
  69. $data = ['topic_state' => 2];
  70. m('meeting_topics')->update($data, "id={$id}");
  71. }
  72. break;
  73. }
  74. }
  75. if (isset($topics[count($topics) - 1]) && $topics[count($topics) - 1]['topic_state'] == 2) {
  76. m('meeting_key')->update(['is_hand' => 2, 'meet_state' => 2], "id={$this->id}");
  77. }
  78. } else if ($ors['num'] == 'enableMeeting') {
  79. $time = time();
  80. $stime = strtotime($this->rs['start_time']);
  81. $etime = strtotime($this->rs['end_time']);
  82. if ($stime < $time){
  83. $data = [
  84. 'meet_state'=>1,
  85. 'is_hand'=>2
  86. ];
  87. } else if ($stime >= $time) {
  88. $data = [
  89. 'meet_state'=>0,
  90. 'is_hand'=>2
  91. ];
  92. }
  93. m('meeting_key')->update($data, "id={$this->id}");
  94. // $topic = m('meeting_topics')->getone("mid={$this->id}", "id", 'sort desc');
  95. // if (isset($topic['id'])) {
  96. // m('meeting_topics')->update(['topic_state'=>'2'], 'id='.$topic['id']);
  97. // }
  98. } else if ($ors['num'] == 'disenableMeeting') {
  99. // $data = [
  100. // 'meet_state'=>2,
  101. // 'is_hand'=>2
  102. // ];
  103. //
  104. // m('meeting_key')->update($data, "id={$this->id}");
  105. }
  106. }
  107. //子表数据替换处理$lx=0编辑时,1展示时
  108. protected function flowsubdata($rows, $lx=0){
  109. if ($lx == 1) {
  110. m('log')->addlog('编辑', $lx);
  111. for ($i = 0; $i < count($rows); $i++) {
  112. if (isset($rows[$i]['topic_state']) && !empty($rows[$i]['topic_state'])) {
  113. $index = $rows[$i]['topic_state'] ?? 1;
  114. $rows[$i]['topic_state'] = m('meeting')->ytarra[$index];
  115. } else {
  116. // $id = $rows[$i]['id'];
  117. // m('meeting_topics')->update(['topic_state'=>1], "id={$id}");
  118. }
  119. }
  120. }
  121. return $rows;
  122. }
  123. }