diff --git a/application/modules/timemanagement/controllers/EmptimesheetsController.php b/application/modules/timemanagement/controllers/EmptimesheetsController.php index b5429225f..ef7b857ef 100644 --- a/application/modules/timemanagement/controllers/EmptimesheetsController.php +++ b/application/modules/timemanagement/controllers/EmptimesheetsController.php @@ -406,6 +406,13 @@ public function emptimesheetweeklyAction(){ $calenderWeek = array(); $calenderWeeksArray = range($firstCalWeek, $lastCalWeek); + + if($calenderWeeksArray[0] == 0) { + $prevYear = $year - 1; + $lastWeekPrevYear = strftime('%U',strtotime($prevYear.'-12-31')); + $calenderWeeksArray[0] = (int)$lastWeekPrevYear; + } + $calWeek = $calenderWeeksArray[$week-1]; if($calWeek == null || $calWeek == '' || $calWeek == '0') { @@ -476,6 +483,13 @@ public function enabletimesheetAction (){ $lastCalWeek = strftime('%U',strtotime($selYrMon.'-'.$lastday)); $calenderWeek = array(); $calenderWeeksArray = range($firstCalWeek, $lastCalWeek); + + if($calenderWeeksArray[0] == 0) { + $prevYear = $year - 1; + $lastWeekPrevYear = strftime('%U',strtotime($prevYear.'-12-31')); + $calenderWeeksArray[0] = (int)$lastWeekPrevYear; + } + if($type == 'month'){ $calenderWeek = $calenderWeeksArray; } @@ -508,6 +522,13 @@ public function approvetimesheetAction (){ $calenderWeek = array(); $calenderWeeksArray = range($firstCalWeek, $lastCalWeek); + + if($calenderWeeksArray[0] == 0) { + $prevYear = $year - 1; + $lastWeekPrevYear = strftime('%U',strtotime($prevYear.'-12-31')); + $calenderWeeksArray[0] = (int)$lastWeekPrevYear; + } + if($type == 'month'){ $calenderWeek = $calenderWeeksArray; } @@ -542,6 +563,13 @@ public function rejecttimesheetAction (){ $calenderWeek = array(); $calenderWeeksArray = range($firstCalWeek, $lastCalWeek); + + if($calenderWeeksArray[0] == 0) { + $prevYear = $year - 1; + $lastWeekPrevYear = strftime('%U',strtotime($prevYear.'-12-31')); + $calenderWeeksArray[0] = (int)$lastWeekPrevYear; + } + if($type == 'month'){ $calenderWeek = $calenderWeeksArray; } @@ -573,6 +601,12 @@ public function approvedaytimesheetAction(){ $calweek=strftime('%U',strtotime($approvedDate)); + if($calweek == 0) { + $prevYear = $year - 1; + $lastWeekPrevYear = strftime('%U',strtotime($prevYear.'-12-31')); + $calweek = (int)$lastWeekPrevYear; + } + $result = $empTSModel->updateEmployeeDayTimesheet($emp_id,$calweek,$year,$month,$approvedDate_day,$approvedDate, "approve", "",$emplistflag); $this->_helper->json(array('saved'=>$result)); @@ -599,6 +633,13 @@ public function rejectdaytimesheetAction(){ $approvedDate = date('Y-m-d', $approvedDateTimestamp); $calweek=strftime('%U',strtotime($approvedDate)); + + if($calweek == 0) { + $prevYear = $year - 1; + $lastWeekPrevYear = strftime('%U',strtotime($prevYear.'-12-31')); + $calweek = (int)$lastWeekPrevYear; + } + $result = $empTSModel->updateEmployeeDayTimesheet($emp_id,$calweek,$year,$month,$approvedDate_day,$approvedDate, "reject",$rejnote,$emplistflag); $this->_helper->json(array('saved'=>$result));