| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 | <?php/** * @author darkredz */class HolidayController extends DooController {	public $staff;	function __construct() {		if(isset($_COOKIE["staff"])){			if(!empty($_COOKIE["staff"])){				Doo::loadModel ( 'staff' );				$staff = new staff ();				$this->staff=$staff->getUserByIdList($_COOKIE["staff"]);				return "/";			}		}		Doo::loadCore ( 'uri/DooUriRouter' );		$router = new DooUriRouter ();		$routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );		if($routeRs['1']!="login"){			header ( 'Content-Type:text/html;charset=utf-8' );			@header ( "Location: /login"  );		}	}	public function myList(){		Doo::loadModel('holidayday');		$hday = new HDay();		$thisyear = date('Y',1572624000);		$num = intval($thisyear)-2017;		$html = '';		for($i = $num; $i >= 0; $i--){			$html .= '<option value="'.(2017+$i).'">'.(2017+$i).'</option>';		}		$data['option'] = $html;		$yeartime = isset($this->params['yearnum']) && is_numeric($this->params['yearnum']) ? $this->getYearMonthTime($this->params['yearnum']) : $this->getYearMonthTime($thisyear);		$holidaymsg = array('shijia'=> array(), 'bingjia' => array(), 'jiaban' => array(), 'zhiban' => array(), 'buxiu' => array(), 'tiaoxiu' => array());		foreach(array(1,2,4,5,10,11) as $k => $v){					}		$data ['memu'] = 'holiday';		$data ['holidaymenu'] = 'mylist';		$data ['staff'] = $this->staff;		$this->render ( "/holiday-myList", $data );	}	public function holidayBorad(){		Doo::loadModel('holiday');		Doo::loadModel('holidayday');		Doo::loadModel('holidaystaff');		Doo::loadModel('holidaytype');		$lastmonthstart = strtotime(date("Y-m-01",strtotime("last month")));		$lastmonthend = strtotime(date('Y-m-01',time()))-1;		$data['countmonth'] = date("Y年m月",strtotime("last month"));		$holiday = new Holiday();		$hday  = new HDay();		$hstaff = new HStaff();		$type = new HType();		$holidaycount =array();		foreach(array(1,2,4,5) as $k => $v){			$typeholiday = $hday->find(array('where' => 'type='.$v.' and uid='.$this->staff[0]['sid'].' and UNIX_TIMESTAMP(daytime) between '.$lastmonthstart.' and '.$lastmonthend,'asArray' => TRUE));			$holidaycount[$k] = 0;			if(!empty($typeholiday)){				foreach($typeholiday as $tk => $tv){					$holidaycount[$k] += floatval($tv['daymsg']);				}			}		}		$hstaffmsg = $hstaff->getOne(array('where' => 'uid='.$this->staff[0]['sid'], 'asArray' => TRUE));		$holidaycount[4] = floatval($hstaffmsg['yearnum']);		$holidaycount[5] = floatval($hstaffmsg['addnum']);		$data['holidaycount'] = $holidaycount;		$holidaymsg = $holiday->find(array('where' => 'uid='.$this->staff[0]['sid'], 'limit' => 3, 'desc' => 'id', 'asArray' => TRUE));		if(!empty($holidaymsg)){			foreach($holidaymsg as $k => $v){				$holidaymsg[$k]['typename'] = $type->getTypeNamebyid($v['type']);				$holidaymsg[$k]['daynum'] = floatval($v['daynum']);				$holidaymsg[$k]['approvetime'] = !empty($v['approvetime']) ? date('Y-m-d H:i:s',$v['approvetime']) : '';				$msg = '';				if(in_array($v['type'],array(1,2,3,4,5,10,11,12))){					$dayjson = json_decode($v['dayjson']);					if($v['type'] != 11){						$holidaydays = $this->geyDayMsg($dayjson->holiday);						foreach($holidaydays as $hk => $hv){							$msg .= $hv['daytime'].' '.$hv['daymsg'].',';						}						$msg = substr($msg,0,strlen($msg)-1);					}else{						$msg .= '休假时间:';						$holidaydays = $this->geyDayMsg($dayjson->holiday);						foreach($holidaydays as $hk => $hv){							$msg .= $hv['daytime'].' '.$hv['daymsg'].',';						}						$msg = substr($msg,0,strlen($msg)-1);						$msg .= '加班时间:';						$overtimedays = $this->geyDayMsg($dayjson->overtime);						foreach($overtimedays as $ok => $ov){							$msg .= $ov['daytime'].' '.$ov['daymsg'].',';						}						$msg = substr($msg,0,strlen($msg)-1);					}				}else{					$msg .= $v['starttime']. ' 至 '.$v['endtime'];				}				$holidaymsg[$k]['daymsg'] = $msg;			}			$data['holidaylist'] = $holidaymsg;		}		$data ['memu'] = 'holiday';		$data ['holidaymenu'] = 'borad';		$data ['staff'] = $this->staff;		$this->render ( "/holiday-borad", $data );	}	public function allList(){		Doo::loadModel('holiday');		Doo::loadModel('holidaytype');		$holiday = new Holiday();		$type = new HType();		if(isset($this->params['type'])){			if($this->params['type'] == 4 ){//加班、值班				$sql = ' and (type=4 or type=5)';			}elseif($this->params['type'] == 6){//其他长假				$sql = ' and type in(6,7,8,9)';			}else{				$sql = ' and type='.$this->params['type'];			}			$pagemsg = '/type/'.$this->params['type'];			$data['thistype'] = $this->params['type'];		}else{			$sql = '';			$pagemsg = '';			$data['thistype'] = '';		}		Doo::loadHelper('DooPager');		$totalArchive = $holiday->count(array('where' => 'uid='.$this->staff[0]['sid'].$sql, 'asArray' => TRUE));		$pager = new DooPager(Doo::conf()->APP_URL . "holidayallList".$pagemsg."/page", $totalArchive, 10, 10);		if (isset($this->params['pindex']))			$pager->paginate(intval($this->params['pindex']));		else			$pager->paginate(1);		if ($pager->limit != ' -10,10')			$holidaymsg = $holiday->find(array('where' => 'uid='.$this->staff[0]['sid'].$sql, 'limit' => $pager->limit, 'desc' => 'id', 'asArray' => TRUE));		if(isset($holidaymsg) && !empty($holidaymsg)){			foreach($holidaymsg as $k => $v){				$holidaymsg[$k]['typename'] = $type->getTypeNamebyid($v['type']);				$holidaymsg[$k]['daynum'] = floatval($v['daynum']);				$holidaymsg[$k]['approvetime'] = !empty($v['approvetime']) ? date('Y-m-d H:i:s',$v['approvetime']) : '';				$msg = '';				if(in_array($v['type'],array(1,2,3,4,5,10,11,12))){					$dayjson = json_decode($v['dayjson']);					if($v['type'] != 11){						$holidaydays = $this->geyDayMsg($dayjson->holiday);						foreach($holidaydays as $hk => $hv){							$msg .= $hv['daytime'].' '.$hv['daymsg'].',';						}						$msg = substr($msg,0,strlen($msg)-1);					}else{						$msg .= '休假时间:';						$holidaydays = $this->geyDayMsg($dayjson->holiday);						foreach($holidaydays as $hk => $hv){							$msg .= $hv['daytime'].' '.$hv['daymsg'].',';						}						$msg = substr($msg,0,strlen($msg)-1);						$msg .= '<br>加班时间:';						$overtimedays = $this->geyDayMsg($dayjson->overtime);						foreach($overtimedays as $ok => $ov){							$msg .= $ov['daytime'].' '.$ov['daymsg'].',';						}						$msg = substr($msg,0,strlen($msg)-1);					}				}else{					$msg .= $v['starttime']. ' 至 '.$v['endtime'];				}				$holidaymsg[$k]['daymsg'] = $msg;			}			$data['holidaylist'] = $holidaymsg;		}		$data['pager'] = $pager->output;		$data ['memu'] = 'holiday';		$data ['holidaymenu'] = 'borad';		$data ['staff'] = $this->staff;		$this->render ( "/holiday-allList", $data );	}	private function geyDayMsg($dayjson){		$holidayday = array();		foreach($dayjson as $dk => $dv){			$oneday = explode('_',$dv);			if($oneday[1] != 0){				$holidayday[$dk]['daytime'] = $oneday[0];				$holidayday[$dk]['daymsg'] = $oneday[1] == 1 ? '' : ($oneday[1] == 2 ? '上午' : '下午');			}		}		return $holidayday;	}	//获取本年的每个月的时间戳	private function getYearMonthTime($thisyear){		$monthdata = array();		for($i = 0; $i < 12; $i++){			$j = $i+1;			$j = $j < 10 ? '0'.$j : $j;			$nowmonth = $thisyear.'-'.$j.'-01';			$monthdata[$i]['starttime'] = strtotime($nowmonth);			$monthdata[$i]['endtime'] = strtotime("+1 months", strtotime($nowmonth))-1;		}		return $monthdata;	}}?>
 |