mode_dailyAction.php 4.7 KB

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