| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123 | <?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(){		$checkadmin = $this->checkisadmin();		if($checkadmin){			$data['cansee'] = 1;		}		Doo::loadModel('holidayday');		Doo::loadModel('holiday');		Doo::loadModel('holidaystaff');		$hday = new HDay();		$holiday = new Holiday();		$hstaff = new HStaff();		$thisyear = date('Y',time());//		$thisyear = date('Y',1546358400);		$num = intval($thisyear)-2017;		$html = '';		$yearnum = isset($this->params['yearnum']) && is_numeric($this->params['yearnum']) ? $this->params['yearnum'] : '';		for($i = $num; $i >= 0; $i--){			if($yearnum == (2017+$i)){				$html .= '<option value="'.(2017+$i).'" selected>'.(2017+$i).'</option>';			}else{				$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('1'=> array(), '2' => array(), '3' => array(), '4' => array(), '5' => array(), '10' => array(), '11' => array());		foreach(array(1,2,3,4,5,10,11) as $k => $v){			$all = 0;			for($i = 0; $i < 12; $i++){				if($v == 11){					$typeholiday = $holiday->find(array('where' => 'status=1 and type='.$v.' and uid='.$this->staff[0]['sid'].' and addtime between '.$yeartime[$i]['starttime'].' and '.$yeartime[$i]['endtime'],'asArray' => TRUE));					$holidaymsg[$v][$i+1] = 0;					if(!empty($typeholiday)){						foreach($typeholiday as $tk => $tv){							$holidaymsg[$v][$i+1] += floatval($tv['daynum']);							$all += floatval($tv['daynum']);						}					}					$holidaymsg[$v][$i+1] = $holidaymsg[$v][$i+1] != 0 ? $holidaymsg[$v][$i+1] : '';				}else{					$typeholiday = $hday->find(array('where' => 'type='.$v.' and uid='.$this->staff[0]['sid'].' and UNIX_TIMESTAMP(daytime) between '.$yeartime[$i]['starttime'].' and '.$yeartime[$i]['endtime'],'asArray' => TRUE));					$holidaymsg[$v][$i+1] = 0;					if(!empty($typeholiday)){						foreach($typeholiday as $tk => $tv){							$holidaymsg[$v][$i+1] += floatval($tv['daymsg']);							$all += floatval($tv['daymsg']);						}					}					$holidaymsg[$v][$i+1] = $holidaymsg[$v][$i+1] != 0 ? $holidaymsg[$v][$i+1] : '';				}			}			$holidaymsg[$v]['all'] = $all != 0 ? $all : '';		}		$hstaffmsg = $hstaff->getOne(array('where' => 'uid='.$this->staff[0]['sid'], 'asArray' => TRUE));		$data['yearnum'] = floatval($hstaffmsg['yearnum']);		$data['overtimetnum'] = floatval($holidaymsg[4]['all'])+floatval($holidaymsg[5]['all']);		$data['addnum'] = floatval($hstaffmsg['addnum']);		$data['hunjianum'] = floatval($hstaffmsg['hunjianum']);		$data['chanjianum'] = floatval($hstaffmsg['chanjianum']);		$data['sangjianum'] = floatval($hstaffmsg['sangjianum']);		$data['gongjianum'] = floatval($hstaffmsg['gongjianum']);		$data['yearround'] = $this->getYearRoundtime($hstaffmsg['hadyear'],$this->staff[0]['hiredate']);//		var_dump($holidaymsg);//		exit;		$data['holidaymsg'] = $holidaymsg;		$data ['memu'] = 'holiday';		$data ['holidaymenu'] = 'mylist';		$data ['staff'] = $this->staff;		$data['noindexjs'] = 'noindexjs';		$this->render ( "/holiday-myList", $data );	}	public function holidayBorad(){		$checkadmin = $this->checkisadmin();		if($checkadmin){			$data['cansee'] = 1;		}		Doo::loadModel('holiday');		Doo::loadModel('holidayday');		Doo::loadModel('holidaystaff');		Doo::loadModel('holidaytype');		$thismonth = $this->getMonthTime(date('Y-m-d',time()));		$data['countmonth'] = date("Y年m月",time());		$holiday = new Holiday();		$hday  = new HDay();		$hstaff = new HStaff();		$type = new HType();		$holidaycount =array();		foreach(array(1,2,3,4,5) as $k => $v){			$typeholiday = $hday->find(array('where' => 'type='.$v.' and uid='.$this->staff[0]['sid'].' and UNIX_TIMESTAMP(daytime) between '.$thismonth['start'].' and '.$thismonth['end'],'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[5] = floatval($hstaffmsg['yearnum']);		$holidaycount[6] = floatval($hstaffmsg['addnum']);		$data['holidaycount'] = $holidaycount;		$holidaymsg = $holiday->find(array('where' => 'uid='.$this->staff[0]['sid'], 'limit' => 10, 'desc' => 'approvetime', '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);					}				}elseif(in_array($v['type'],array(6,7,8,9))){					$msg .= $v['starttime']. ' 至 '.$v['endtime'];				}elseif(in_array($v['type'],array(13,14,15,16,17,18,19))){					$msg .= date('Y-m-d H:i:s',$v['addtime']);				}				$holidaymsg[$k]['daymsg'] = $msg;			}			$data['holidaylist'] = $holidaymsg;		}		$data ['memu'] = 'holiday';		$data ['holidaymenu'] = 'borad';		$data ['staff'] = $this->staff;		$data['noindexjs'] = 'noindexjs';		//公司每日考勤内容		if($hstaffmsg['isadmin'] == 1 || $hstaffmsg['iscc'] == 1){			$data['youcantseeme'] = 0;			//今日请假人员,区分总部和办事处			Doo::loadModel('staff');			$staff = new staff();			$headquarters = $branch = $leaves = array();			$today = date('Y-m-d',time());			$data['today'] = date('m月d日',time());			//短假的			$hdayarr = $hday->find(array('where' => 'daytime=?', 'param' => array($today), 'asArray' => TRUE));			if(!empty($hdayarr)){				foreach($hdayarr as $hk => $hv){					$onearr = array();					$onehmsg = $holiday->getOne(array('where' => 'id=?', 'param' => array($hv['hid']), 'asArray' => TRUE));					$staffmsg = $staff->getOne(array('where' => 'sid=?', 'param' => array($hv['uid']), 'asArray' => TRUE));					$onearr['type'] = $type->getTypeNamebyid($onehmsg['type']);					$onearr['staff'] = $staffmsg['username'];					$onearr['day'] = floatval($onehmsg['daynum']);					if($staffmsg['cid'] == 12){						array_push($headquarters,$onearr);					}else{						array_push($branch,$onearr);					}					array_push($leaves,$hv['uid']);				}			}			//长假的			$hdayarr2 = $holiday->find(array('where' => 'status=1 and type in (6,7,8,9) and UNIX_TIMESTAMP(starttime)<=UNIX_TIMESTAMP(?) and UNIX_TIMESTAMP(endtime)>=UNIX_TIMESTAMP(?)', 'param' => array($today,$today), 'asArray' => TRUE));			if(!empty($hdayarr2)){				foreach($hdayarr2 as $hk2 => $hv2){					$onearr = array();					$staffmsg = $staff->getOne(array('where' => 'sid=?', 'param' => array($hv2['uid']), 'asArray' => TRUE));					$onearr['type'] = $type->getTypeNamebyid($hv2['type']);					$onearr['staff'] = $staffmsg['username'];					$onearr['day'] = floatval($hv2['daynum']);					if($staffmsg['cid'] == 12){						array_push($headquarters,$onearr);					}else{						array_push($branch,$onearr);					}					array_push($leaves,$hv2['uid']);				}			}			$data['headquarters'] = $headquarters;			$data['branch'] = $branch;			//今天在勤人员名单			$hqstaffarr = $staff->find(array('where' => 'cid=12 and departmentID=0', 'asArray' => TRUE));			$onlinehq = array();			foreach($hqstaffarr as $hqk => $hqv){				if(!in_array($hqv['sid'],$leaves)){					array_push($onlinehq,$hqv['username']);				}			}			$onlinebr = array();			Doo::loadModel('L_category');			$lcate = new L_category();			$catearr = $lcate->find(array('where' => 'cid!=34', 'asArray' => TRUE));			foreach($catearr as $ck => $cv){				if($cv['cid'] == 12){					$brstaffarr = $staff->find(array('where' => 'cid=? and departmentID=1', 'param' => array($cv['cid']), 'asArray' => TRUE));				}else{					$brstaffarr = $staff->find(array('where' => 'cid=?', 'param' => array($cv['cid']), 'asArray' => TRUE));				}				$brsarr = array();				if(!empty($brstaffarr)){					foreach($brstaffarr as $brk => $brv){						if(!in_array($brv['sid'],$leaves)) {							array_push($brsarr, $brv['username']);						}					}				}				$brstaffstr = !empty($brsarr) ? implode('、', $brsarr) : '';				$title = $cv['cid'] == 12 ? '总部-造价研究中心' : $cv['title'];				$onebrarr = array('title' => $title,'online' => $brstaffstr);				array_push($onlinebr,$onebrarr);			}//			var_dump($onlinebr);//			$brstaffarr = $staff->find(array('where' => ''));			$data['onlineheadquarters'] = implode('、',$onlinehq);			$data['onlinebranch'] = $onlinebr;//			var_dump(array_unique($leaves));		}else{			$data['youcantseeme'] = 1;		}		$this->render ( "/holiday-borad", $data );	}	public function allList(){		$checkadmin = $this->checkisadmin();		if($checkadmin){			$data['cansee'] = 1;		}		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(3,6,7,8,9,13,14,15,16,17,18,19)';			}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);					}				}elseif(in_array($v['type'],array(6,7,8,9))){					$msg .= $v['starttime']. ' 至 '.$v['endtime'];				}elseif(in_array($v['type'],array(13,14,15,16,17,18,19))){					$msg .= date('Y-m-d H:i:s',$v['addtime']);				}				$holidaymsg[$k]['daymsg'] = $msg;			}			$data['holidaylist'] = $holidaymsg;		}		$data['pager'] = $pager->output;		$data ['memu'] = 'holiday';		$data ['holidaymenu'] = 'borad';		$data ['staff'] = $this->staff;		$data['noindexjs'] = 'noindexjs';		$this->render ( "/holiday-allList", $data );	}	public function holidayClose(){		$checkadmin = $this->checkisadmin();		if(!$checkadmin){			exit('非假期管理员无法访问此页面');		}		$data['cansee'] = 1;	//获取办事处列表		Doo::loadModel('staff');		Doo::loadModel('holidaystaff');		Doo::loadModel('holidayday');		Doo::loadModel('holiday');		$staff = new staff();		$hstaff = new HStaff();		$hday = new HDay();		$holiday = new Holiday();		$sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid where `CLD_staff`.nature=1 group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';		$query = Doo::db ()->query ( $sql );		$result = $query->fetchAll ();		$data['category'] = $result;		$thisyear = date('Y',time());//		$thisyear = date('Y',1546358400);		$data['thismonth'] = intval(date('m',time()));		$num = intval($thisyear)-2017;		$html = '';		$yearnum = isset($this->params['year']) && is_numeric($this->params['year']) ? $this->params['year'] : '';		for($i = $num; $i >= 0; $i--){			if($yearnum == (2017+$i)){				$html .= '<option value="'.(2017+$i).'" selected>'.(2017+$i).'</option>';			}else{				$html .= '<option value="'.(2017+$i).'">'.(2017+$i).'</option>';			}		}		$data['option'] = $html;		if(isset($this->params['year']) && isset($this->params['month'])){			$month = intval($this->params['month']) < 10 ? '0'.$this->params['month'] : $this->params['month'];			$date = $this->params['year'].'-'.$month.'-01';			$thismonth = $this->getMonthTime($date);			$data['thismonth'] = $this->params['month'];		}else{			$thismonth = $this->getMonthTime(date('Y-m-d',time()));		}		foreach($result as $k => $v){			$stafflist[$k]['categoryname'] = $v['title'];			$stafflist[$k]['count'] = $v['count'];			$cidstafflist = $staff->find(array('where' => 'cid='.$v['cid'].' and nature=1', 'asArray' => TRUE));			foreach($cidstafflist as $ck => $cv) {				foreach (array(1, 2, 3) as $tk => $tv) {					$typeholiday = $hday->find(array('where' => 'type=' . $tv . ' and uid=' . $cv['sid'] . ' and UNIX_TIMESTAMP(daytime) between ' . $thismonth['start'] . ' and ' . $thismonth['end'], 'asArray' => TRUE));					$cidstafflist[$ck][$tv] = 0;					if (!empty($typeholiday)) {						foreach ($typeholiday as $thk => $thv) {							$cidstafflist[$ck][$tv] += floatval($thv['daymsg']);						}					}					$cidstafflist[$ck][$tv] = $cidstafflist[$ck][$tv] != 0 ? $cidstafflist[$ck][$tv] : '';				}				$cidstafflist[$ck]['first'] = $ck == 0 ? 1 : ''; // 是否第一个			}			$stafflist[$k]['cidstafflist'] = $cidstafflist;		}		$data['stafflist'] = $stafflist;		$zongbu = $staff->find(array('where' => 'cid=12 and nature=1', 'asArray' => TRUE));		$data['zongbu'] = $zongbu;		$data ['memu'] = 'holiday';		$data ['holidaymenu'] = 'close';		$data ['staff'] = $this->staff;		$data['noindexjs'] = 'noindexjs';		$this->render ( "/holiday-close", $data );	}	public function holidayClose2(){		$checkadmin = $this->checkisadmin();		if(!$checkadmin){			exit('非假期管理员无法访问此页面');		}		$data['cansee'] = 1;		//获取办事处列表		Doo::loadModel('staff');		Doo::loadModel('holidaystaff');		Doo::loadModel('holidayday');		Doo::loadModel('holiday');		$staff = new staff();		$hstaff = new HStaff();		$hday = new HDay();		$holiday = new Holiday();		$sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid where `CLD_staff`.nature=2 group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';		$query = Doo::db ()->query ( $sql );		$result = $query->fetchAll ();		$data['category'] = $result;		$thisyear = date('Y',time());//		$thisyear = date('Y',1546358400);		$data['thismonth'] = intval(date('m',time()));		$num = intval($thisyear)-2017;		$html = '';		$yearnum = isset($this->params['year']) && is_numeric($this->params['year']) ? $this->params['year'] : '';		for($i = $num; $i >= 0; $i--){			if($yearnum == (2017+$i)){				$html .= '<option value="'.(2017+$i).'" selected>'.(2017+$i).'</option>';			}else{				$html .= '<option value="'.(2017+$i).'">'.(2017+$i).'</option>';			}		}		$data['option'] = $html;		if(isset($this->params['year']) && isset($this->params['month'])){			$month = intval($this->params['month']) < 10 ? '0'.$this->params['month'] : $this->params['month'];			$date = $this->params['year'].'-'.$month.'-01';			$thismonth = $this->getMonthTime($date);			$data['thismonth'] = $this->params['month'];		}else{			$thismonth = $this->getMonthTime(date('Y-m-d',time()));		}		$stafflist = array();		foreach($result as $k => $v){			$stafflist[$k]['categoryname'] = $v['title'];			$stafflist[$k]['count'] = $v['count'];			$cidstafflist = $staff->find(array('where' => 'cid='.$v['cid'].' and nature=2', 'asArray' => TRUE));			foreach($cidstafflist as $ck => $cv) {				foreach (array(1, 2, 3, 14) as $tk => $tv) {					if($tv == 14){						$typeholiday = $holiday->getOne(array('where' => 'status=3 and type='.$tv.' and uid='.$cv['sid'].' and starttime="'.$thismonth['start'].'" and endtime="'.$thismonth['end'].'"', 'desc' => 'id', 'asArray' => TRUE));						$cidstafflist[$ck][$tv] = $typeholiday['daynum'] != 0 ? floatval($typeholiday['daynum']) : '';					}else{						$typeholiday = $hday->find(array('where' => 'type=' . $tv . ' and uid=' . $cv['sid'] . ' and UNIX_TIMESTAMP(daytime) between ' . $thismonth['start'] . ' and ' . $thismonth['end'], 'asArray' => TRUE));						$cidstafflist[$ck][$tv] = 0;						if (!empty($typeholiday)) {							foreach ($typeholiday as $thk => $thv) {								$cidstafflist[$ck][$tv] += floatval($thv['daymsg']);							}						}						$cidstafflist[$ck][$tv] = $cidstafflist[$ck][$tv] != 0 ? $cidstafflist[$ck][$tv] : '';					}				}				$cidstafflist[$ck]['first'] = $ck == 0 ? 1 : ''; // 是否第一个			}			$stafflist[$k]['cidstafflist'] = $cidstafflist;		}		$data['stafflist'] = $stafflist;		$data['internstafflist'] = $staff->find(array('where' => 'nature=2', 'asArray' => TRUE));		//获取上月和本月,录用 实习生上班天数		$nowmonth = intval(date('m',time()));		$nowday = date('Y-m-d',time());		$lastmonth = intval(date('m',strtotime("-1 month")));		$lastmonthday = date('Y-m-d',strtotime("-1 month"));		$data['monthlist'] = '<option value="0">选择月份</option><option value="'.$lastmonthday.'">'.$lastmonth.'月</option><option value="'.$nowday.'">'.$nowmonth.'月</option>';		$data ['memu'] = 'holiday';		$data ['holidaymenu'] = 'close';		$data ['staff'] = $this->staff;		$data['noindexjs'] = 'noindexjs';		$this->render ( "/holiday-close2", $data );	}	public function addHoliday2(){		if(isset($_POST['uid']) && is_numeric($_POST['uid']) && isset($_POST['type']) && is_numeric($_POST['type'])){			Doo::loadModel('holiday');			$holiday = new Holiday();			if(in_array($_POST['type'],array(1,2,3))){				$day = $_POST['day'];				$dayjson = array('holiday' => [$day.'_1']);				$holiday->uid = $_POST['uid'];				$holiday->type = $_POST['type'];				$holiday->dayjson = json_encode($dayjson);				$holiday->daynum = 1.0;				$holiday->status = 3;				$holiday->addtime = time();				$holiday->approvetime = time();				$holiday->description = $_POST['description'];				$id = $holiday->insert();				Doo::loadModel('holidayday');				$hday = new HDay();				$hday->hid = $id;				$hday->uid = $_POST['uid'];				$hday->type = $_POST['type'];				$hday->daytime = $day;				$hday->daymsg = 1.0;				$hday->insert();				if(isset($_POST['close2'])){					return '/holidayclose2';				}else{					return '/holidayclose';				}			}elseif($_POST['type'] == 14){				$thismonth = $this->getMonthTime($_POST['monthselect']);				$holiday->uid = $_POST['uid'];				$holiday->type = $_POST['type'];				$holiday->starttime = $thismonth['start'];				$holiday->endtime = $thismonth['end'];				$holiday->daynum = $_POST['daynum'];				$holiday->status = 3;				$holiday->addtime = time();				$holiday->approvetime = time();				$holiday->description = $_POST['description'];				$holiday->insert();				return '/holidayclose2';			}		}		exit('添加事病假、旷工出错');	}	public function holidayOvertime(){		$checkadmin = $this->checkisadmin();		if(!$checkadmin){			exit('非假期管理员无法访问此页面');		}		$data['cansee'] = 1;		//获取办事处列表		Doo::loadModel('staff');		Doo::loadModel('holidaystaff');		Doo::loadModel('holidayday');		Doo::loadModel('holiday');		$staff = new staff();		$hstaff = new HStaff();		$hday = new HDay();		$holiday = new Holiday();		$sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';		$query = Doo::db ()->query ( $sql );		$result = $query->fetchAll ();		$data['category'] = $result;		$thisyear = date('Y',time());//		$thisyear = date('Y',1546358400);		$data['thismonth'] = intval(date('m',time()));		$num = intval($thisyear)-2017;		$html = '';		$yearnum = isset($this->params['year']) && is_numeric($this->params['year']) ? $this->params['year'] : '';		for($i = $num; $i >= 0; $i--){			if($yearnum == (2017+$i)){				$html .= '<option value="'.(2017+$i).'" selected>'.(2017+$i).'</option>';			}else{				$html .= '<option value="'.(2017+$i).'">'.(2017+$i).'</option>';			}		}		$data['option'] = $html;		if(isset($this->params['year']) && isset($this->params['month'])){			$month = intval($this->params['month']) < 10 ? '0'.$this->params['month'] : $this->params['month'];			$date = $this->params['year'].'-'.$month.'-01';			$thismonth = $this->getMonthTime($date);			$data['thismonth'] = $this->params['month'];		}else{			$thismonth = $this->getMonthTime(date('Y-m-d',time()));		}		$stafflist = array();		if(isset($this->params['cid']) && is_numeric($this->params['cid'])){			$data['thiscid'] = $this->params['cid'];			foreach($result as $k => $v){				if($this->params['cid'] == $v['cid']){					$stafflist[0]['categoryname'] = $v['title'];					$stafflist[0]['count'] = $v['count'];					$cidstafflist = $staff->getStaffByCid($v['cid']);					foreach($cidstafflist as $ck => $cv){						$hstaffmsg = $hstaff->getOne(array('where' => 'uid='.$cv['sid'], 'asArray' => TRUE));						$cidstafflist[$ck]['addnum'] = $hstaffmsg['addnum'] != 0.0 ? floatval($hstaffmsg['addnum']) : '';						foreach(array(4,5,10,11) as $tk => $tv){							if($tv == 11){								$typeholiday = $holiday->find(array('where' => 'status=1 and type='.$tv.' and uid='.$cv['sid'].' and addtime between '.$thismonth['start'].' and '.$thismonth['end'],'asArray' => TRUE));								$cidstafflist[$ck][$tv] = 0;								if(!empty($typeholiday)){									foreach($typeholiday as $thk => $thv){										$cidstafflist[$ck][$tv] += floatval($thv['daynum']);									}								}								$cidstafflist[$ck][$tv] = $cidstafflist[$ck][$tv] != 0 ? $cidstafflist[$ck][$tv] : '';							}else{								$typeholiday = $hday->find(array('where' => 'type='.$tv.' and uid='.$cv['sid'].' and UNIX_TIMESTAMP(daytime) between '.$thismonth['start'].' and '.$thismonth['end'],'asArray' => TRUE));								$cidstafflist[$ck][$tv] = 0;								if(!empty($typeholiday)){									foreach($typeholiday as $thk => $thv){										$cidstafflist[$ck][$tv] += floatval($thv['daymsg']);									}								}								$cidstafflist[$ck][$tv] = $cidstafflist[$ck][$tv] != 0 ? $cidstafflist[$ck][$tv] : '';							}						}						$cidstafflist[$ck]['countnum'] = floatval($cidstafflist[$ck][4])+floatval($cidstafflist[$ck][5]) != 0 ? floatval($cidstafflist[$ck][4]) + floatval($cidstafflist[$ck][5]) : '';						$cidstafflist[$ck]['first'] = $ck == 0 ? 1 : ''; // 是否第一个					}					$stafflist[0]['cidstafflist'] = $cidstafflist;					break;				}			}		}else{			foreach($result as $k => $v){				$stafflist[$k]['categoryname'] = $v['title'];				$stafflist[$k]['count'] = $v['count'];				$cidstafflist = $staff->getStaffByCid($v['cid']);				foreach($cidstafflist as $ck => $cv) {					$hstaffmsg = $hstaff->getOne(array('where' => 'uid=' . $cv['sid'], 'asArray' => TRUE));					$cidstafflist[$ck]['addnum'] = $hstaffmsg['addnum'] != 0.0 ? floatval($hstaffmsg['addnum']) : '';					foreach (array(4, 5, 10, 11) as $tk => $tv) {						if ($tv == 11) {							$typeholiday = $holiday->find(array('where' => 'status=1 and type=' . $tv . ' and uid=' . $cv['sid'] . ' and addtime between ' . $thismonth['start'] . ' and ' . $thismonth['end'], 'asArray' => TRUE));							$cidstafflist[$ck][$tv] = 0;							if (!empty($typeholiday)) {								foreach ($typeholiday as $thk => $thv) {									$cidstafflist[$ck][$tv] += floatval($thv['daynum']);								}							}							$cidstafflist[$ck][$tv] = $cidstafflist[$ck][$tv] != 0 ? $cidstafflist[$ck][$tv] : '';						} else {							$typeholiday = $hday->find(array('where' => 'type=' . $tv . ' and uid=' . $cv['sid'] . ' and UNIX_TIMESTAMP(daytime) between ' . $thismonth['start'] . ' and ' . $thismonth['end'], 'asArray' => TRUE));							$cidstafflist[$ck][$tv] = 0;							if (!empty($typeholiday)) {								foreach ($typeholiday as $thk => $thv) {									$cidstafflist[$ck][$tv] += floatval($thv['daymsg']);								}							}							$cidstafflist[$ck][$tv] = $cidstafflist[$ck][$tv] != 0 ? $cidstafflist[$ck][$tv] : '';						}					}					$cidstafflist[$ck]['countnum'] = floatval($cidstafflist[$ck][4])+floatval($cidstafflist[$ck][5]) != 0 ? floatval($cidstafflist[$ck][4]) + floatval($cidstafflist[$ck][5]) : '';					$cidstafflist[$ck]['first'] = $ck == 0 ? 1 : ''; // 是否第一个				}				$stafflist[$k]['cidstafflist'] = $cidstafflist;			}		}		$data['stafflist'] = $stafflist;		$zongbu = $staff->getStaffByCid(12);		$data['zongbu'] = $zongbu;		$data ['memu'] = 'holiday';		$data ['holidaymenu'] = 'overtime';		$data ['staff'] = $this->staff;		$data['noindexjs'] = 'noindexjs';		$this->render ( "/holiday-overtime", $data );	}	public function addHoliday(){		if(isset($_POST['uid']) && is_numeric($_POST['uid']) && isset($_POST['type']) && is_numeric($_POST['type'])){			Doo::loadModel('holidaystaff');			Doo::loadModel('holiday');			$holiday = new Holiday();			$hstaff = new HStaff();			$hstaffmsg = $hstaff->getOne(array('where' => 'uid='.$_POST['uid'], 'asArray' => TRUE));			if(($_POST['type'] == 4 || $_POST['type'] == 5) && isset($_POST['daytype']) && is_numeric($_POST['daytype'])){				$day = $_POST['day'];				$hstaff->uid = $_POST['uid'];				$daytype = $_POST['daytype'];				$adddaynum = $daytype != 1 ? 0.5 : 1.0;				$hstaff->addnum = floatval($hstaffmsg['addnum'])+$adddaynum;				$result = $hstaff->update();				if($result){					$dayjson = array('holiday' => [$day.'_'.$daytype]);					$holiday->uid = $_POST['uid'];					$holiday->type = $_POST['type'];					$holiday->dayjson = json_encode($dayjson);					$holiday->daynum = $adddaynum;					$holiday->status = 3;					$holiday->addtime = time();					$holiday->approvetime = time();					$holiday->description = $_POST['description'];					$id = $holiday->insert();					Doo::loadModel('holidayday');					$hday = new HDay();					$hday->hid = $id;					$hday->uid = $_POST['uid'];					$hday->type = $_POST['type'];					$hday->daytime = $day;					$hday->daymsg = $adddaynum;					$hday->insert();					return '/holidayovertime';				}else{					exit('添加到holidaystaff出错');				}			}elseif($_POST['type'] == 13){				$daynum = $_POST['tixian'];				if($daynum > $hstaffmsg['addnum']){					exit('提现天数超过存假天数了');				}else{					$hstaff->uid = $_POST['uid'];					$hstaff->addnum = $hstaffmsg['addnum']-$daynum;					$result = $hstaff->update();					if($result){						$holiday->uid = $_POST['uid'];						$holiday->type = 13;						$holiday->daynum = $daynum;						$holiday->status = 3;						$holiday->addtime = time();						$holiday->approvetime = time();						$holiday->description = $_POST['description'];						$holiday->insert();						return '/holidayovertime';					}else{						exit('添加到holidaystaff出错');					}				}			}		}		exit('添加加值班或提现出错');	}	public function holidayVacation(){		$checkadmin = $this->checkisadmin();		if(!$checkadmin){			exit('非假期管理员无法访问此页面');		}		$data['cansee'] = 1;		//获取办事处列表		Doo::loadModel('staff');		Doo::loadModel('holidaystaff');		$staff = new staff();		$hstaff = new HStaff();		$sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';		$query = Doo::db ()->query ( $sql );		$result = $query->fetchAll ();		$data['category'] = $result;		$stafflist = array();		if(isset($this->params['cid']) && is_numeric($this->params['cid'])){			$data['thiscid'] = $this->params['cid'];			foreach($result as $k => $v){				if($this->params['cid'] == $v['cid']){					$stafflist[0]['categoryname'] = $v['title'];					$stafflist[0]['count'] = $v['count'];					$cidstafflist = $staff->getStaffByCid($v['cid']);					foreach($cidstafflist as $ck => $cv){						$hstaffmsg = $hstaff->getOne(array('where' => 'uid='.$cv['sid'], 'asArray' => TRUE));						$yearnum = $this->CheckAnnualLeave($cv);						$cidstafflist[$ck]['yearnum'] = floatval($yearnum) != 0 ? floatval($yearnum) : '';						$cidstafflist[$ck]['addnum'] = $hstaffmsg['addnum'] != 0.0 ? floatval($hstaffmsg['addnum']) : '';						$cidstafflist[$ck]['hunjianum'] = $hstaffmsg['hunjianum'] != 0.0 ? floatval($hstaffmsg['hunjianum']) : '';						$cidstafflist[$ck]['chanjianum'] = $hstaffmsg['chanjianum'] != 0.0 ? floatval($hstaffmsg['chanjianum']) : '';						$cidstafflist[$ck]['sangjianum'] = $hstaffmsg['sangjianum'] != 0.0 ? floatval($hstaffmsg['sangjianum']) : '';						$cidstafflist[$ck]['gongjianum'] = $hstaffmsg['gongjianum'] != 0.0 ? floatval($hstaffmsg['gongjianum']) : '';						$cidstafflist[$ck]['yearround'] = $cv['nature'] == 1 ? $this->getYearRoundtime($hstaffmsg['hadyear'],$cv['hiredate']) : '';						$cidstafflist[$ck]['first'] = $ck == 0 ? 1 : ''; // 是否第一个					}					$stafflist[0]['cidstafflist'] = $cidstafflist;					break;				}			}		}else{			foreach($result as $k => $v){				$stafflist[$k]['categoryname'] = $v['title'];				$stafflist[$k]['count'] = $v['count'];				$cidstafflist = $staff->getStaffByCid($v['cid']);				foreach($cidstafflist as $ck => $cv){					$hstaffmsg = $hstaff->getOne(array('where' => 'uid='.$cv['sid'], 'asArray' => TRUE));					$yearnum = $this->CheckAnnualLeave($cv);					$cidstafflist[$ck]['yearnum'] = floatval($yearnum) != 0 ? floatval($yearnum) : '';					$cidstafflist[$ck]['addnum'] = $hstaffmsg['addnum'] != 0.0 ? floatval($hstaffmsg['addnum']) : '';					$cidstafflist[$ck]['hunjianum'] = $hstaffmsg['hunjianum'] != 0.0 ? floatval($hstaffmsg['hunjianum']) : '';					$cidstafflist[$ck]['chanjianum'] = $hstaffmsg['chanjianum'] != 0.0 ? floatval($hstaffmsg['chanjianum']) : '';					$cidstafflist[$ck]['sangjianum'] = $hstaffmsg['sangjianum'] != 0.0 ? floatval($hstaffmsg['sangjianum']) : '';					$cidstafflist[$ck]['gongjianum'] = $hstaffmsg['gongjianum'] != 0.0 ? floatval($hstaffmsg['gongjianum']) : '';					$cidstafflist[$ck]['yearround'] = $cv['nature'] == 1 ? $this->getYearRoundtime($hstaffmsg['hadyear'],$cv['hiredate']) : '';					$cidstafflist[$ck]['first'] = $ck == 0 ? 1 : ''; // 是否第一个				}				$stafflist[$k]['cidstafflist'] = $cidstafflist;			}		}		$zongbu = $staff->getStaffByCid(12);		$data['zongbu'] = $zongbu;		$hstaff2 = new HStaff();		$hstaffmsg2 = $hstaff2->getOne(array('select' => 'yearnum', 'where' => 'uid='.$zongbu[0]['sid'], 'asArray' => TRUE));		$data['thisnum'] = floatval($hstaffmsg2['yearnum']);		$data['stafflist'] = $stafflist;		$data ['memu'] = 'holiday';		$data ['holidaymenu'] = 'vacation';		$data ['staff'] = $this->staff;		$data['noindexjs'] = 'noindexjs';		$this->render ( "/holiday-vacation", $data );	}	public function setStaffHoliday(){		if(isset($_POST['uid']) && is_numeric($_POST['uid']) && isset($_POST['typeholiday']) && isset($_POST['addnum'])){			Doo::loadModel('holidaystaff');			$hstaff = new HStaff();			$hstaffmsg = $hstaff->getOne(array('where' => 'uid='.$_POST['uid'], 'asArray' => TRUE));			$hstaff->uid = $_POST['uid'];			$type = '';			switch($_POST['typeholiday']){				case 'yearnum':					$hstaff->yearnum = $hstaffmsg['yearnum']+$_POST['addnum'];					$type = 15;					break;				case 'hunjianum':					$hstaff->hunjianum = $hstaffmsg['hunjianum']+$_POST['addnum'];					$type = 16;					break;				case 'chanjianum':					$hstaff->chanjianum = $hstaffmsg['chanjianum']+$_POST['addnum'];					$type = 17;					break;				case 'sangjianum':					$hstaff->sangjianum = $hstaffmsg['sangjianum']+$_POST['addnum'];					$type = 18;					break;				case 'gongjianum':					$hstaff->gongjianum = $hstaffmsg['gongjianum']+$_POST['addnum'];					$type = 19;					break;			}			$hstaff->update();			Doo::loadModel('holiday');			$holiday = new Holiday();			$holiday->uid = $_POST['uid'];			$holiday->type = $type;			$holiday->daynum = $_POST['addnum'];			$holiday->status = 3;			$holiday->addtime = time();			$holiday->approvetime = time();			$holiday->description = $_POST['description'];			$holiday->insert();			return '/holidayvacation';		}else{			exit('增加出错');		}	}	public function getStaffCategory(){		if(isset($_POST['cid']) && is_numeric($_POST['cid'])){			Doo::loadModel('staff');			$staff = new staff();			$stafflist = $staff->getStaffByCid($_POST['cid']);			Doo::loadModel('holidaystaff');			$hstaff = new HStaff();			$hstaffmsg = $hstaff->getOne(array('select' => 'yearnum', 'where' => 'uid='.$stafflist[0]['sid'], 'asArray' => TRUE));			exit(json_encode(array('code' => 200, 'stafflist' => $stafflist, 'thisnum' => floatval($hstaffmsg['yearnum']))));		}		exit(json_encode(array('code' => 400)));	}	public function getHolidayStaff(){		if(isset($_POST['uid']) && is_numeric($_POST['uid']) && isset($_POST['type'])){			Doo::loadModel('holidaystaff');			$hstaff = new HStaff();			$staffmsg = $hstaff->getOne(array('select' => $_POST['type'], 'where' => 'uid='.$_POST['uid'], 'asArray' => TRUE));			exit(json_encode(array('code' => 200, 'thisnum' => floatval($staffmsg[$_POST['type']]))));		}		exit(json_encode(array('code' => 400)));	}	public function holidayAttendance(){		$checkadmin = $this->checkisadmin();		if($checkadmin){			$data['cansee'] = 1;		}		Doo::loadModel('holidayday');		Doo::loadModel('holiday');		Doo::loadModel('holidaystaff');		Doo::loadModel('holidaytype');		Doo::loadModel('staff');		$hday = new HDay();		$holiday = new Holiday();		$hstaff = new HStaff();		$type = new HType();		$staff = new staff();		$sqlstr = '';		$pagestr = '';		if(isset($this->params['day'])){			$today = $this->params['day'];			$todayarr = explode('~',$today);			if(count($todayarr) != 2){				$sqlstr .= ' and ((UNIX_TIMESTAMP(starttime)<=UNIX_TIMESTAMP("'.$todayarr[0].'") and UNIX_TIMESTAMP(endtime)>=UNIX_TIMESTAMP("'.$todayarr[0].'")) OR (id in (select hid From `holiday_day` where daytime="'.$todayarr[0].'")))';			}else{				$sqlstr .= ' and ((UNIX_TIMESTAMP(starttime)<=UNIX_TIMESTAMP("'.$todayarr[0].'") and UNIX_TIMESTAMP(endtime)>=UNIX_TIMESTAMP("'.$todayarr[0].'")) OR (UNIX_TIMESTAMP(starttime)<=UNIX_TIMESTAMP("'.$todayarr[1].'") and UNIX_TIMESTAMP(endtime)>=UNIX_TIMESTAMP("'.$todayarr[1].'")) OR (id in (select hid From `holiday_day` where UNIX_TIMESTAMP(daytime) between UNIX_TIMESTAMP("'.$todayarr[0].'") and UNIX_TIMESTAMP("'.$todayarr[1].'"))))';			}		}else{			$today = date('Y-m-d',time());			$sqlstr .= ' and ((UNIX_TIMESTAMP(starttime)<=UNIX_TIMESTAMP("'.$today.'") and UNIX_TIMESTAMP(endtime)>=UNIX_TIMESTAMP("'.$today.'")) OR (id in (select hid from `holiday_day` where daytime="'.$today.'")))';		}		$pagestr .= '/day/'.$today;		$data['today'] = $today;		if(isset($this->params['cate'])){			$cate = 'headquarters';			$pagestr .= '/cate/'.$cate;			$data['cate'] = 1;			$sqlstr .= ' and uid in (select sid from `CLD_staff` where cid=12 and departmentID=0)';		}else{			$data['cate'] = 0;		}		$data['typeurl'] = $pagestr;		if(isset($this->params['type'])){			$data['type'] = $this->params['type'];			$pagestr .= '/type/'.$this->params['type'];			if($this->params['type'] == 4 ){//加班、值班				$sqlstr .= ' and (type=4 or type=5)';			}elseif($this->params['type'] == 6){//其他长假				$sqlstr .= ' and type in(3,6,7,8,9)';			}else{				$sqlstr .= ' and type='.$this->params['type'];			}		}else{			$data['type'] = '';		}		Doo::loadHelper('DooPager');		$totalArchive = $holiday->count(array('where' => 'status=1'.$sqlstr, 'asArray' => TRUE));		$pager = new DooPager(Doo::conf()->APP_URL . "holidayattendance".$pagestr."/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' => 'status=1'.$sqlstr, 'limit' => $pager->limit, 'asArray' => TRUE));		if(isset($holidaymsg) && !empty($holidaymsg)){			foreach($holidaymsg as $k => $v){				$staffmsg = $staff->getOne(array('where' => 'sid=?', 'param' => array($v['uid']), 'asArray' => TRUE));				$holidaymsg[$k]['username'] = $staffmsg['username'];				$holidaymsg[$k]['category'] = $staffmsg['cid'] == 12 && $staffmsg['departmentID'] == 1 ? '总部(造价研究中心)' : $staffmsg['category'];				$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);					}				}elseif(in_array($v['type'],array(6,7,8,9))){					$msg .= $v['starttime']. ' 至 '.$v['endtime'];				}elseif(in_array($v['type'],array(13,14,15,16,17,18,19))){					$msg .= date('Y-m-d H:i:s',$v['addtime']);				}				$holidaymsg[$k]['daymsg'] = $msg;			}			$data['holidaylist'] = $holidaymsg;		}		$data['pager'] = $pager->output;		$data ['memu'] = 'holiday';		$data ['holidaymenu'] = 'borad';		$data ['staff'] = $this->staff;		$data['noindexjs'] = 'noindexjs';		$this->render ( "/holiday-allList2", $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 getMonthTime($time){		$starttime = strtotime(date('Y-m-01',strtotime($time)));		$endtime = strtotime("+1 months", strtotime(date('Y-m-01',strtotime($time))))-1;		return array('start' => $starttime, 'end' => $endtime);	}	//获取本年的每个月的时间戳	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;	}	//获取本年当事人的年假周期	private function getYearRoundtime($hadyear,$hiredate){		$month = date('m', strtotime($hiredate));		$date = date('d', strtotime($hiredate));		$monthday = intval($month).'月'.intval($date).'日';		$year = date('Y',time());		//每隔4年加一天		if(date('Y',(strtotime($hiredate)+(86400*365*$hadyear)+intval($hadyear/4)*86400)) < $year){			$lastyear = intval($year)-1;			return intval($lastyear).'年'.$monthday.'~'.intval($year).'年'.$monthday;		}else{			$nextyear = intval($year)+1;			return intval($year).'年'.$monthday.'~'.intval($nextyear).'年'.$monthday;		}	}	private function checkisadmin(){		Doo::loadModel('holidayadmin');		$admin = new HAdmin();		$adminmsg = $admin->getOne(array('where' => 'uid='.$this->staff[0]['sid'], 'asArray' => TRUE));		if(!empty($adminmsg)){			return TRUE;		}else{			return FALSE;		}	}	//检查年假是否过期并更新年假	private function CheckAnnualLeave($staff){		if($staff['nature'] == 2){			return 0;		}		$hiredate = $staff['hiredate'];		if($hiredate == ''){			return 0;		}		Doo::loadModel('holidaystaff');		$hstaff = new HStaff();		$hstaffmsg = $hstaff->getOne(array('where' => 'uid='.$staff['sid'],'asArray' => TRUE));		$hadyear = intval((time()-strtotime($hiredate))/(86400*365));		if($hadyear != $hstaffmsg['hadyear']){			$hstaff->uid = $staff['sid'];			$hstaff->hadyear = $hadyear;			$hstaff->yearnum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15));			$hstaff->update();			$daynum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15));		}else{			$daynum = $hstaffmsg['yearnum'];		}		return $daynum;	}}?>
 |