|
@@ -7,8 +7,6 @@
|
|
|
class HolidayController extends DooController {
|
|
|
|
|
|
public $staff;
|
|
|
- public static $NEW = 0;
|
|
|
- public static $NEW2 = 0;
|
|
|
|
|
|
function __construct() {
|
|
|
if(isset($_COOKIE["staff"])){
|
|
@@ -16,11 +14,7 @@ class HolidayController extends DooController {
|
|
|
Doo::loadModel ( 'staff' );
|
|
|
$staff = new staff ();
|
|
|
$this->staff=$staff->getUserByIdList($_COOKIE["staff"]);
|
|
|
- self::$NEW= $this->getReceiptCount();
|
|
|
- self::$NEW2= $this->getExeCount();
|
|
|
- include './protected/controller/ReceiptController.php';
|
|
|
- ReceiptController::$NEW=self::$NEW;
|
|
|
- ReceiptController::$NEW2=self::$NEW2;
|
|
|
+
|
|
|
return "/";
|
|
|
}
|
|
|
}
|
|
@@ -36,35 +30,201 @@ class HolidayController extends DooController {
|
|
|
}
|
|
|
|
|
|
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 );
|
|
|
}
|
|
|
|
|
|
- private function getReceiptCount(){
|
|
|
+ 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']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- $status=2;
|
|
|
- $year=date('Y');
|
|
|
+ $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;
|
|
|
+ }
|
|
|
|
|
|
- Doo::loadModel('receipt');
|
|
|
- $receipt=new receipt();
|
|
|
+ $data ['memu'] = 'holiday';
|
|
|
+ $data ['holidaymenu'] = 'borad';
|
|
|
+ $data ['staff'] = $this->staff;
|
|
|
+ $this->render ( "/holiday-borad", $data );
|
|
|
+ }
|
|
|
|
|
|
- $dateCondition=" and Year(date) =".$year;
|
|
|
+ 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'] = '';
|
|
|
+ }
|
|
|
|
|
|
- $approvalCondition=' and nowStaff like "%'.$this->staff[0]['sid'].'%" ';
|
|
|
- $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
|
|
|
+ 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 );
|
|
|
+ }
|
|
|
|
|
|
- return count($receiptList);
|
|
|
+ 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 getExeCount(){
|
|
|
- Doo::loadModel('receipt');
|
|
|
- $receipt=new receipt();
|
|
|
- $receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$this->staff[0]['sid'].'%\' and executeStaff NOT LIKE \'%'.$this->staff[0]['sid'].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
|
|
|
|
|
|
- return count($receiptList);
|
|
|
+ //获取本年的每个月的时间戳
|
|
|
+ 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;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
?>
|