12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121 |
- <?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){
- $day = $_POST['day'];
- $hstaff->uid = $_POST['uid'];
- $hstaff->addnum = floatval($hstaffmsg['addnum'])+1;
- $result = $hstaff->update();
- if($result){
- $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();
- 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;
- }
- }
- ?>
|