Skip to content

Commit

Permalink
Merge pull request #117 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 7, 2018
2 parents 5fda4d1 + 0293e94 commit 67ed67b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ demos/
extras/documentation
/*.bak
logs/xdebug.log
logs/application.log
.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,14 @@ public function weekAction()
if($timeFlag == 'time' && $selYrMon == $now->format('Y-m') && ($calWeek == '' || $calWeek == '0')) {

$calWeek = strftime('%U',strtotime($selYrMon.'-'.$now->format('d')));
$startCalWeek = strftime('%U',strtotime($selYrMon.'-01'));
$startCalWeek = strftime('%U',strtotime($selYrMon.'-01'));
$week = ($calWeek- $startCalWeek) +1;

if($startCalWeek == "00") {
$prevYear = $yrMon[0] - 1;
$startCalWeek = strftime('%U',strtotime($prevYear.'-12-31'));
$week = 1;
}
}

$empDoj = $usersModel->getEmployeeDoj($data->id);
Expand All @@ -627,9 +633,20 @@ public function weekAction()
$calWeek = strftime('%U',strtotime($selYrMon.'-'.$selDay));
$startCalWeek = strftime('%U',strtotime($selYrMon.'-01'));
$week = ($calWeek- $startCalWeek) +1;

if($startCalWeek == "00") {
$prevYear = $year - 1;
$startCalWeek = strftime('%U',strtotime($prevYear.'-12-31'));
$week = 1;
}
} else {
if($calWeek == '' || $calWeek == '0')
$calWeek = strftime('%U',strtotime($selYrMon.'-01'));

if($calWeek == "00") {
$prevYear = $year - 1;
$calWeek = strftime('%U',strtotime($prevYear.'-12-31'));
}
}
// }
$myTsModel = new Timemanagement_Model_MyTimesheet();
Expand Down Expand Up @@ -1490,6 +1507,13 @@ public function submitAction() {
$calWeek = strftime('%U',strtotime($selYrMon.'-'.$selDay));
$startCalWeek = strftime('%U',strtotime($selYrMon.'-01'));
$week = ($calWeek- $startCalWeek) +1;

if($startCalWeek == "00") {
$prevYear = $year - 1;
$startCalWeek = strftime('%U',strtotime($prevYear.'-12-31'));
$week = 1;
}

$dayName = strtolower(date('D', strtotime($selYrMon.'-'.$selDay)));
}
$statusData = array('emp_id'=>$sessionData->id,
Expand Down
32 changes: 28 additions & 4 deletions application/modules/timemanagement/models/Projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,20 @@ public function prev_weeksubmit_status($prevweeks,$emp_id,$emp_details)

$resultData = array();
$savedTimeSheets = array();
$resultData = $notificationModel->getTimesheetStatus($emp_id,$hidendweek_date);
$savedTimeSheets = $notificationModel->getSavedTimesheets($emp_id,$hidendweek_date);

$startCalWeek = strftime('%U',strtotime($yr_mnth.'-01'));

if($startCalWeek == "00") {
$year = date('Y',strtotime($hidendweek_date));
$prevYear = $year - 1;
$prev_year_hidendweek_date = $prevYear.'-12-31';

$resultData = $notificationModel->getTimesheetStatus($emp_id,$prev_year_hidendweek_date);
$savedTimeSheets = $notificationModel->getSavedTimesheets($emp_id,$prev_year_hidendweek_date);
} else {
$resultData = $notificationModel->getTimesheetStatus($emp_id,$hidendweek_date);
$savedTimeSheets = $notificationModel->getSavedTimesheets($emp_id,$hidendweek_date);
}

//End
if(count($resultData)>0)
Expand Down Expand Up @@ -826,8 +838,20 @@ public function getPreviousDaysTSStatus($prevweeks,$emp_id,$emp_details)
$emp_dept_id = $emp_details['department_id'];
$join_date=new DateTime($emp_details['date_of_joining']);
$join_date=$join_date->format('Y-m-d');
$resultData = $notificationModel->getpreviousTimesheetStatus($emp_id,$hidendweek_date,$mnth,$year);
$savedTimeSheets = $notificationModel->getpreviousSavedTimesheets($emp_id,$hidendweek_date,$mnth,$year);

$startCalWeek = strftime('%U',strtotime($yr_mnth.'-01'));

if($startCalWeek == "00") {
$prevYear = $year - 1;
$prev_year_hidendweek_date = $prevYear.'-12-31';

$resultData = $notificationModel->getpreviousTimesheetStatus($emp_id,$prev_year_hidendweek_date,$mnth,$year);
$savedTimeSheets = $notificationModel->getpreviousSavedTimesheets($emp_id,$prev_year_hidendweek_date,$mnth,$year);
} else {
$resultData = $notificationModel->getpreviousTimesheetStatus($emp_id,$hidendweek_date,$mnth,$year);
$savedTimeSheets = $notificationModel->getpreviousSavedTimesheets($emp_id,$hidendweek_date,$mnth,$year);
}

//End
if(count($resultData)>0)
{
Expand Down
6 changes: 6 additions & 0 deletions application/modules/timemanagement/models/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ public function checkweekdaysdatacron($hidstartweek_date,$hidendweek_date,$hidem

$calWeekVal = strftime('%U',strtotime($loopDate));
$dateYearVal = strftime('%Y',strtotime($loopDate));

if($calWeekVal == "00") {
$prevYear = $dateYearVal - 1;
$calWeekVal = strftime('%U',strtotime($prevYear.'-12-31'));
}

if(!in_array($calWeekVal,$cal_weekArray)){
$cal_weekArray[] = $calWeekVal;
$yearCalWeekArray[$calWeekVal][] = $dateYearVal;
Expand Down

0 comments on commit 67ed67b

Please sign in to comment.