meetModel.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. class agent_meetClassModel extends agentModel
  3. {
  4. private $joinwhere='';
  5. public function initModel()
  6. {
  7. $this->dtobj = c('date');
  8. }
  9. //今日会议
  10. public function getstotal($uid, $dt)
  11. {
  12. if($this->joinwhere=='')$this->joinwhere = m('admin')->getjoinstr('joinid', $uid);
  13. $where = "`status`=1 and `type`=0 and `startdt` like '$dt%' and joinid is not null $this->joinwhere and `state`<2";
  14. $sto = m('meet')->rows($where);
  15. return $sto;
  16. }
  17. public function gettotal()
  18. {
  19. $stotal = $this->getstotal($this->adminid, $this->rock->date);
  20. return array('stotal'=>$stotal,'titles'=>'');
  21. }
  22. protected function agentrows($rows, $rowd, $uid)
  23. {
  24. $hyarra = $this->flow->hyarra;
  25. $hyarrb = $this->flow->hyarrb;
  26. if(!in_array($this->event, array('week','today'))){
  27. if($rowd)foreach($rowd as $k=>$rs){
  28. $nzt = $rs['nzt'];
  29. $rows[$k]['statustext'] = $hyarra[$nzt];
  30. $rows[$k]['statuscolor'] = $hyarrb[$nzt];
  31. }
  32. }
  33. return $rows;
  34. }
  35. protected function agentdata($uid, $lx)
  36. {
  37. $row = array();
  38. $dt = $this->rock->date;
  39. if($this->joinwhere=='')$this->joinwhere = m('admin')->getjoinstr('joinid', $uid);
  40. //本周
  41. if($lx=='week'){
  42. $warr = $this->dtobj->getweekarr($dt);
  43. foreach($warr as $dts){
  44. $rows = $this->getweek($dts, $uid);
  45. $row = array_merge($row, $rows);
  46. }
  47. //今日
  48. }else if($lx=='today'){
  49. $row = $this->getweek($dt, $uid);
  50. }else{
  51. return false;
  52. }
  53. $arr['rows'] = $row;
  54. return $arr;
  55. }
  56. protected function agenttotals($uid)
  57. {
  58. return array(
  59. 'today' => $this->getstotal($uid, $this->rock->date)
  60. );
  61. }
  62. //数据处理
  63. private function gethuiwdata($rows, $dbs)
  64. {
  65. $row = array();
  66. $hyarra = $this->flow->hyarra;
  67. $hyarrb = $this->flow->hyarrb;
  68. $time = time();
  69. foreach($rows as $k=>$rs){
  70. $zt = $rs['state'];
  71. $nzt = $zt;
  72. $stime = strtotime($rs['startdt']);
  73. $etime = strtotime($rs['enddt']);
  74. if($zt < 2){
  75. if($etime<$time){
  76. $nzt = 2;
  77. }else if($stime>$time){
  78. $nzt = 0;
  79. }else{
  80. $nzt = 1;
  81. }
  82. }
  83. $rows[$k]['statustext'] = $hyarra[$nzt];
  84. $rows[$k]['statuscolor'] = $hyarrb[$nzt];
  85. $cont = '会议室:'.$rs['hyname'].'';
  86. $cont .= '<br>发起人:'.$rs['optname'].'';
  87. if(!$this->isempt($rs['joinname']))$cont.= '<br>参会人:'.$rs['joinname'].'';
  88. $rows[$k]['cont'] = $cont;
  89. if($nzt>1){
  90. $rows[$k]['ishui'] = 1;
  91. }
  92. $rows[$k]['optdt'] = substr($rs['startdt'],11).'至'.substr($rs['enddt'],11);
  93. unset($rows[$k]['startdt']);
  94. unset($rows[$k]['enddt']);
  95. unset($rows[$k]['joinname']);
  96. unset($rows[$k]['optname']);
  97. unset($rows[$k]['hyname']);
  98. $row[] = $rows[$k];
  99. if($zt != $nzt)$dbs->update('state='.$nzt.'', $rs['id']);
  100. }
  101. return $row;
  102. }
  103. //获取今日和本周会议的个人
  104. private function getweek($dt, $uid)
  105. {
  106. $week = $this->dtobj->cnweek($dt);
  107. $dbs = m('meet');
  108. $rows = $dbs->getrows("`status`=1 and `type`=0 and `startdt` like '$dt%' and joinid is not null $this->joinwhere",'hyname,title,optid,startdt,enddt,state,joinname,optname,id','`startdt` asc');
  109. if($rows)$row[] = array(
  110. 'showtype' => 'line',
  111. 'title' => ''.$dt.'(周'.$week.')的会议'
  112. );
  113. return $this->gethuiwdata($rows, $dbs);
  114. }
  115. }
粤ICP备19079148号