diff --git a/application/TimerecordingBilling/TimerecordingBillingController.php b/application/TimerecordingBilling/TimerecordingBillingController.php
index bfa6fd64e..0efb64ea8 100644
--- a/application/TimerecordingBilling/TimerecordingBillingController.php
+++ b/application/TimerecordingBilling/TimerecordingBillingController.php
@@ -908,8 +908,35 @@ class TimerecordingBillingController extends mfBaseController
$workingHours[$workinghour->day] = $workingHours[$workinghour->day] + $whend - $whstart;
}
}
+ $workinghourshistory = TimerecordingEmployeeWorkingHourHistoryModel::search(['user_id' => $userid]);
+ if ($workinghourshistory) {
+ $workingHoursHistory[2147483500] = $workingHours;
+ foreach ($workinghourshistory as $workinghourhistory) {
+ $whenddate = $workinghourhistory->enddate;
+ $workinghourhistoryhours = json_decode($workinghourhistory->workinghours, true);
+ foreach ($workinghourhistoryhours as $workinghourhistoryhour) {
+ $whstart = strtotime(date('Y-m-d', time()) . " " . $workinghourhistoryhour['start'] . ":00");
+ $whend = strtotime(date('Y-m-d', time()) . " " . $workinghourhistoryhour['end'] . ":00");
+ if (!$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']]) {
+ $workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] = $whend - $whstart;
+ } else {
+ $workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] = $workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] + $whend - $whstart;
+ }
+ }
+ }
+ }
+
//check if holiday is already in the list
foreach ($holidayDays as $key => $holidayDay) {
+ if ($workingHoursHistory) {
+ foreach ($workingHoursHistory as $whkey => $whdata) {
+ $whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
+ $timestamp = strtotime($key);
+ if ($whtimestamp >= $timestamp) {
+ $workingHours = $whdata;
+ }
+ }
+ }
if (($realholiDay[$key])) {
} else if ($workingHours[date('w', strtotime($key))]) {
diff --git a/application/TimerecordingReport/TimerecordingReportController.php b/application/TimerecordingReport/TimerecordingReportController.php
index aac0820dd..f494e4b17 100644
--- a/application/TimerecordingReport/TimerecordingReportController.php
+++ b/application/TimerecordingReport/TimerecordingReportController.php
@@ -96,6 +96,28 @@ class TimerecordingReportController extends mfBaseController
}
}
+ $workinghourshistory = TimerecordingEmployeeWorkingHourHistoryModel::getAll();
+ if ($workinghourshistory) {
+ $workingHoursHistory[2147483500] = $workingHours;
+ foreach ($workinghourshistory as $workinghourhistory) {
+ $workingHoursHistory[$workinghourshistory->user_id][2147483500] = $workingHours;
+ $whenddate = $workinghourhistory->enddate;
+ $workinghourhistoryhours = json_decode($workinghourhistory->workinghours, true);
+ foreach ($workinghourhistoryhours as $workinghourhistoryhour) {
+ $whstart = strtotime(date('Y-m-d', time()) . " " . $workinghourhistoryhour['start'] . ":00");
+ $whend = strtotime(date('Y-m-d', time()) . " " . $workinghourhistoryhour['end'] . ":00");
+ if (!$workingHoursHistory[$workinghourhistory->user_id][$whenddate][$workinghourhistoryhour['day']]) {
+ $workingHoursHistory[$workinghourhistory->user_id][$whenddate][$workinghourhistoryhour['day']] = $whend - $whstart;
+ } else {
+ $workingHoursHistory[$workinghourhistory->user_id][$whenddate][$workinghourhistoryhour['day']] = $workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] + $whend - $whstart;
+ }
+ }
+// echo $workinghourhistory->user_id."
";
+ }
+ }
+// var_dump($workingHoursHistory);
+// die();
+
foreach ($this->holidays as $holiday) {
$holiDay[date('Y-m-d', $holiday->timestamp)] = $holiday->timestamp;
@@ -218,7 +240,15 @@ class TimerecordingReportController extends mfBaseController
$hcounter = 0;
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
$hidedate .= date("d.m.Y", $i) . " ";
-
+ if ($workingHoursHistory[$timerecording->user_id]) {
+ foreach ($workingHoursHistory[$timerecording->user_id] as $whkey => $whdata) {
+ $whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
+ if ($whtimestamp >= $i) {
+ unset($workingHours[$timerecording->user_id]);
+ $workingHours[$timerecording->user_id] = $whdata;
+ }
+ }
+ }
$holidaycounter = $workingHours[$timerecording->user_id][date("w", $i)];
$daycheck = date("Y-m-d", $i);
if (!$holiDay[$daycheck]) {
@@ -271,11 +301,21 @@ class TimerecordingReportController extends mfBaseController
}
$summcounter = 0;
$savecounter = 0;
+
// echo $starttimecalc."
";
$hidedate = "";
$hcounter = 0;
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
$hidedate .= date("d.m.Y", $i) . " ";
+ if ($workingHoursHistory[$timerecording->user_id]) {
+ foreach ($workingHoursHistory[$timerecording->user_id] as $whkey => $whdata) {
+ $whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
+ if ($whtimestamp >= $i) {
+ unset($workingHours[$timerecording->user_id]);
+ $workingHours[$timerecording->user_id] = $whdata;
+ }
+ }
+ }
$holidaycounter = $workingHours[$timerecording->user_id][date("w", $i)];
$daycheck = date("Y-m-d", $i);
if (!$holiDay[$daycheck]) {