mode_dailyAction.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?php
  2. class mode_dailyClassAction extends inputAction{
  3. public $months,$ztdt;
  4. protected function savebefore($table, $arr, $id, $addbo){
  5. $type = arrvalue($arr, 'type');
  6. $uid = arrvalue($arr, 'uid');
  7. $dt = arrvalue($arr, 'dt');
  8. if(isempt($dt))return '';
  9. $enddt = arrvalue($arr, 'enddt');
  10. $where = "id<>$id and `uid`=$uid and `type`='$type' and `dt`='$dt'";
  11. if(!isempt($enddt))$where.=' and `enddt`='.$enddt.'';
  12. if($type==0 && $dt>$this->date)return '日期['.$dt.']还是个未来呢';
  13. $to = $this->mdb->rows($where);
  14. if($to>0)return '该类型日期['.$dt.']段已申请了';
  15. }
  16. protected function saveafter($table, $arr, $id, $addbo){
  17. }
  18. public function getdtstrAjax()
  19. {
  20. $type = (int)$this->post('type');
  21. $dt = $this->post('dt');
  22. $dta = explode('-', $dt);
  23. $dtobj = c('date');
  24. $startdt= $dt;
  25. $enddt = '';
  26. if($type==1){
  27. $dtw = $dtobj->getweekarr($dt);
  28. $startdt= $dtw[0];
  29. $enddt = $dtw[6];
  30. }
  31. if($type==2){
  32. $startdt= ''.$dta[0].'-'.$dta[1].'-01';
  33. $enddt= $dtobj->getenddt($dt);
  34. }
  35. if($type==3){
  36. $startdt= ''.$dta[0].'-01-01';
  37. $enddt = ''.$dta[0].'-12-31';
  38. }
  39. $a = array($startdt, $enddt);
  40. $this->returnjson($a);
  41. }
  42. public function anxyfxbeforershow($table)
  43. {
  44. $dt1 = $this->post('dt1', date('Y-m'));
  45. $this->months = $dt1;
  46. $key = $this->post('key');
  47. $atype = $this->post('atype');
  48. $isdaily= $this->post('isdaily','1');
  49. $dbs = m('admin');
  50. $s = $dbs->monthuwhere($dt1,'a.');
  51. if($atype=='my'){
  52. $s = 'and a.`id`='.$this->adminid.'';
  53. }else{
  54. if($isdaily=='1')$s.=" and a.`isdaily`=$isdaily";
  55. $s.= m('admin')->getcompanywhere(5,'a.');
  56. }
  57. if($atype=='down'){
  58. $dids = $dbs->getdown($this->adminid, 1);
  59. if(isempt($dids))$dids='0';
  60. $s.= ' and a.`id` in('.$dids.')';
  61. }
  62. if(!isempt($key))$s.=" and (a.`name` like '%$key%' or a.`ranking` like '%$key%' or a.`deptname` like '%$key%')";
  63. $table = "`[Q]userinfo` a left join `[Q]dailyfx` b on a.id=b.uid and b.`month`='$dt1'";
  64. $fields = 'a.id,a.name,a.deptname,a.ranking,a.workdate,a.state,b.*';
  65. return array(
  66. 'where' =>$s,
  67. 'fields'=>$fields,
  68. 'order'=>'a.`id`',
  69. 'table'=> $table
  70. );
  71. }
  72. public function anxyfxaftershow($table, $rows)
  73. {
  74. $zta = m('flow:userinfo');
  75. $maxjg = c('date')->getmaxdt($this->months);
  76. //0未写,1已写,2请假,3休息日,4没入职或已离职,5不需要写日报,时间还没到
  77. foreach($rows as $k=>$rs){
  78. if($rs['state']==5)$rows[$k]['ishui']=1;
  79. $rows[$k]['state'] = $zta->getuserstate($rs['state']);
  80. for($i=1;$i<=$maxjg;$i++){
  81. $zt = arrvalue($rs,'day'.$i.'');
  82. $oi = ($i<10)?'0'.$i.'':$i;
  83. $dt = $this->months.'-'.$oi;
  84. $str = '';
  85. if($dt<$this->date){
  86. if($zt=='0')$str='×';
  87. if($zt=='1')$str='<font color=green>√</font>';
  88. if($zt=='2')$str='<font color=#888888>假</font>';
  89. if($zt=='6')$str='<font color=green>◇</font>';
  90. }
  91. $rows[$k]['day'.$i.''] = $str;
  92. }
  93. }
  94. return array(
  95. 'rows' => $rows,
  96. 'maxjg'=> $maxjg,
  97. 'week' => date('w', strtotime($this->months.'-01'))
  98. );
  99. }
  100. //日报统计分析
  101. public function dailyfxAjax()
  102. {
  103. $dt = $this->post('dt');
  104. $atype = $this->post('atype');
  105. $uid = ($atype=='my') ? $this->adminid : 0;
  106. m('flow:daily')->dailyanay($uid, $dt);
  107. }
  108. //昨天未写显示
  109. public function ztweixiedatabefore($table)
  110. {
  111. $dt = c('date')->adddate($this->rock->date, 'd', -1);
  112. $dt = $this->post('dt', $dt);
  113. $this->ztdt = $dt;
  114. $dta = explode('-', $dt);
  115. $month = substr($dt, 0,7);
  116. $d = (int)$dta[2];
  117. $where = m('admin')->getcompanywhere(5,'a.');
  118. return array(
  119. 'table' => '`[Q]dailyfx` b left join `[Q]userinfo` a on a.`id`=b.`uid`',
  120. 'where' => "and b.`month`='$month' and b.`day".$d."`=0 ".$where."",
  121. 'fields'=> 'b.totalw,b.totalx,b.totaly,a.name,a.deptname'
  122. );
  123. }
  124. public function ztweixiedataafter($table, $rows)
  125. {
  126. return array(
  127. 'ztdt' => $this->ztdt.',周'.c('date')->cnweek($this->ztdt).''
  128. );
  129. }
  130. //部门统计
  131. public function bmztweixiedatabefore($table)
  132. {
  133. $dt = c('date')->adddate($this->rock->date, 'd', -1);
  134. $dt = $this->post('dt', $dt);
  135. $this->ztdt = $dt;
  136. $dta = explode('-', $dt);
  137. $month = substr($dt, 0,7);
  138. $d = (int)$dta[2];
  139. $where = m('admin')->getcompanywhere(5,'a.');
  140. return array(
  141. 'table' => '`[Q]dailyfx` b left join `[Q]userinfo` a on a.`id`=b.`uid`',
  142. 'where' => "and b.`month`='$month' and b.`day".$d."`=0 $where",
  143. 'fields'=> 'count(1) as value,a.deptname as name',
  144. 'order' => '`value`',
  145. 'group' => 'a.deptname'
  146. );
  147. }
  148. public function bmztweixiedataafter($table, $rows)
  149. {
  150. return array(
  151. 'rows' => $rows
  152. );
  153. }
  154. }
粤ICP备19079148号