1
0

meetModel.php 3.3 KB

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