meeting_keyModel.php 4.7 KB

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