Skip to content

Commit

Permalink
Merge pull request #116 from go-faustino/calendar-week-bug
Browse files Browse the repository at this point in the history
Calendar week bug
  • Loading branch information
go-faustino authored Jan 5, 2018
2 parents 7b99c33 + 57b8ea7 commit e8ec44e
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand Down

0 comments on commit e8ec44e

Please sign in to comment.