From 5a6224df9f080db7ed5463787f573e928a1b70eb Mon Sep 17 00:00:00 2001 From: Spitzer Daniel Date: Fri, 26 Apr 2024 12:29:01 +0200 Subject: [PATCH] =?UTF-8?q?Zeiterfassung=20Update=20=20*=20Berechnungen=20?= =?UTF-8?q?f=C3=BCr=20Austritte=20implementiert.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Timerecording/TimerecordingController.php | 20 +++++++++++++++---- .../TimerecordingReportController.php | 9 +++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/application/Timerecording/TimerecordingController.php b/application/Timerecording/TimerecordingController.php index 20b4889a0..e7d311669 100644 --- a/application/Timerecording/TimerecordingController.php +++ b/application/Timerecording/TimerecordingController.php @@ -553,7 +553,13 @@ class TimerecordingController extends mfBaseController $overtime_timestamp = $employee->startdate; $overtime_now = $overtime; } - $endtime = time() - 86400; + if ($employee->enddate && $employee->enddate < time() - 86400) { + $endtime = strtotime(date("Y-m-d", $employee->enddate) . " 23:59:00"); + } else { + $endtime = time() - 86400; + } + + $endtime = date("Y-m-d", $endtime); $endtime = strtotime($endtime . " 23:59:00"); @@ -608,6 +614,12 @@ class TimerecordingController extends mfBaseController $plusHours = $employee[0]->plushours_now; $auto_workinghours = $employee[0]->auto_workinghours; $startdate = $employee[0]->startdate; + if ($employee[0]->enddate) { + $enddate = strtotime(date('Y-m-d', $employee[0]->enddate) . " 23:59:59"); + } else { + $enddate = 2208985200; + } + $overtime = $employee[0]->overtime_now; } $workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $userid]); @@ -641,7 +653,7 @@ class TimerecordingController extends mfBaseController for ($i = 1; $i <= 7; $i++) { $dDate = date('Y-m-d', $timestamp); $dDay = date('w', $timestamp); - if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate)) { + if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) { $mustSeconds = $mustSeconds + $workingHours[$dDay]; } @@ -658,7 +670,7 @@ class TimerecordingController extends mfBaseController for ($i = 1; $i <= $daycount; $i++) { $dDate = date('Y-m-d', $timestamp); $dDay = date('w', $timestamp); - if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate)) { + if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) { $mustSeconds = $mustSeconds + $workingHours[$dDay]; } $timestamp = $timestamp + 86400; @@ -674,7 +686,7 @@ class TimerecordingController extends mfBaseController for ($i = 1; $i <= $daycount; $i++) { $dDate = date('Y-m-d', $timestamp); $dDay = date('w', $timestamp); - if (!$holiDay[$dDate]) { + if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) { $mustSeconds = $mustSeconds + $workingHours[$dDay]; } $timestamp = $timestamp + 86400; diff --git a/application/TimerecordingReport/TimerecordingReportController.php b/application/TimerecordingReport/TimerecordingReportController.php index 7e4b18f54..77f031ad4 100644 --- a/application/TimerecordingReport/TimerecordingReportController.php +++ b/application/TimerecordingReport/TimerecordingReportController.php @@ -411,6 +411,11 @@ class TimerecordingReportController extends mfBaseController $overtime_now = $employee[0]->overtime_now; $auto_workinghours = $employee[0]->auto_workinghours; $startdate = $employee[0]->startdate; + if ($employee[0]->enddate) { + $enddate = strtotime(date('Y-m-d', $employee[0]->enddate) . " 23:59:59"); + } else { + $enddate = 2208985200; + } $bpahours = $employee[0]->bpahours; } $workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $user_id]); @@ -445,7 +450,7 @@ class TimerecordingReportController extends mfBaseController $dDate = date('Y-m-d', $timestamp); $dDay = date('w', $timestamp); - if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate)) { + if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) { $mustSeconds = $mustSeconds + $workingHours[$dDay]; } @@ -466,7 +471,7 @@ class TimerecordingReportController extends mfBaseController for ($i = 1; $i <= $daycount; $i++) { $dDate = date('Y-m-d', $timestamp); $dDay = date('w', $timestamp); - if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate)) { + if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) { $mustSeconds = $mustSeconds + $workingHours[$dDay]; }