From c39f7172679b55e03be9846ab5941f109206de98 Mon Sep 17 00:00:00 2001 From: Spitzer Daniel Date: Thu, 29 Feb 2024 21:52:52 +0100 Subject: [PATCH] Zeiterfassung Update * Fix Summe bei Urlauben und Feiertagen (Buchungen und Auswertungen) --- .../Timerecording/TimerecordingController.php | 27 ++++++++++++++----- .../TimerecordingReportController.php | 20 +++++++++----- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/application/Timerecording/TimerecordingController.php b/application/Timerecording/TimerecordingController.php index df79da385..248b6f1ea 100644 --- a/application/Timerecording/TimerecordingController.php +++ b/application/Timerecording/TimerecordingController.php @@ -538,6 +538,7 @@ class TimerecordingController extends mfBaseController $day = $daysgerm[date("w", $timerecording->start)]; $isSeconds = $isSeconds + $seconds; } else if ($timerecording->timerecordingCategory->hourday == 2 || ($timerecording->timerecordingCategory->hourday == 3 && $timerecording->end)) { + $date = date("d.m.", $timerecording->start) . " - " . $daysgerm[date("w", $timerecording->end)] . " " . date("d.m.Y", $timerecording->end); $datadate = date("Y-m-d", $timerecording->start); $enddate = date("Y-m-d", $timerecording->end); @@ -559,8 +560,11 @@ class TimerecordingController extends mfBaseController $savecounter = 0; for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) { $holidaycounter = $workingHours[date("w", $i)]; - $isSeconds = $isSeconds + $holidaycounter; - $summcounter = $summcounter + $holidaycounter; + $daycheck = date("Y-m-d", $i); + if (!$holiDay[$daycheck]) { + $isSeconds = $isSeconds + $holidaycounter; + $summcounter = $summcounter + $holidaycounter; + } if ($savecounter == 1000) { echo $savecounter; die(); @@ -575,14 +579,19 @@ class TimerecordingController extends mfBaseController } else if ($timerecording->timerecordingCategory->hourday == 3 && !$timerecording->end) { $date = date("d.m.Y", $timerecording->start) . " - " . $daysgerm[date("w", time())] . " " . date("d.m.Y", time());; $datadate = date("Y-m-d", $timerecording->start); + $enddatetemp = date("Y-m-d", time()); + $enddatetemp = strtotime($enddatetemp . " 23:59:59"); + $enddate = date("Y-m-d", $enddatetemp + 7200); $start = "-"; $end = "-"; $day = $daysgerm[date("w", $timerecording->start)]; - if ($lastdate < $timerecording->end) { + + if ($lastdate < time()) { $endtimecalc = $lastdate; } else { - $endtimecalc = $timerecording->end; + $endtimecalc = time(); } + $summcounter = 0; if ($firstdate > $timerecording->start) { $starttimecalc = $firstdate; } else { @@ -590,10 +599,14 @@ class TimerecordingController extends mfBaseController } $summcounter = 0; $savecounter = 0; +// echo $starttimecalc."
"; for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) { - $holidaycounter = $workingHours[date("w", $i)]; - $isSeconds = $isSeconds + $holidaycounter; - $summcounter = $summcounter + $holidaycounter; + $holidaycounter = $workingHours[$timerecording->user_id][date("w", $i)]; + $daycheck = date("Y-m-d", $i); + if (!$holiDay[$daycheck]) { + $isSeconds = $isSeconds + $holidaycounter; + $summcounter = $summcounter + $holidaycounter;; + } if ($savecounter == 1000) { echo $savecounter; die(); diff --git a/application/TimerecordingReport/TimerecordingReportController.php b/application/TimerecordingReport/TimerecordingReportController.php index 68a0333fc..923b37fbf 100644 --- a/application/TimerecordingReport/TimerecordingReportController.php +++ b/application/TimerecordingReport/TimerecordingReportController.php @@ -41,7 +41,7 @@ class TimerecordingReportController extends mfBaseController case "getTimerecordings": $return = $this->getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear); break; - case "getTimerecordingsTimes": + case "getTimerecordingsTimes": $return = $this->getTimerecordingsTimes($datatype, $dataweek, $datamonth, $datayear); break; default: @@ -103,7 +103,7 @@ class TimerecordingReportController extends mfBaseController $dDate = date('Y-m-d', $timestamp); $dDay = date('w', $timestamp); if (!$holiDay[$dDate]) { - // $mustSeconds = $mustSeconds + $workingHours[$dDay]; + // $mustSeconds = $mustSeconds + $workingHours[$dDay]; } $timestamp = $timestamp + 86400; @@ -120,7 +120,7 @@ class TimerecordingReportController extends mfBaseController $dDate = date('Y-m-d', $timestamp); $dDay = date('w', $timestamp); if (!$holiDay[$dDate]) { - // $mustSeconds = $mustSeconds + $workingHours[$dDay]; + // $mustSeconds = $mustSeconds + $workingHours[$dDay]; } $timestamp = $timestamp + 86400; } @@ -192,8 +192,11 @@ class TimerecordingReportController extends mfBaseController // echo $starttimecalc."
"; for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) { $holidaycounter = $workingHours[$timerecording->user_id][date("w", $i)]; - $isSeconds = $isSeconds + $holidaycounter; - $summcounter = $summcounter + $holidaycounter;; + $daycheck = date("Y-m-d", $i); + if (!$holiDay[$daycheck]) { + $isSeconds = $isSeconds + $holidaycounter; + $summcounter = $summcounter + $holidaycounter;; + } if ($savecounter == 1000) { echo $savecounter; die(); @@ -231,8 +234,11 @@ class TimerecordingReportController extends mfBaseController // echo $starttimecalc."
"; for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) { $holidaycounter = $workingHours[$timerecording->user_id][date("w", $i)]; - $isSeconds = $isSeconds + $holidaycounter; - $summcounter = $summcounter + $holidaycounter;; + $daycheck = date("Y-m-d", $i); + if (!$holiDay[$daycheck]) { + $isSeconds = $isSeconds + $holidaycounter; + $summcounter = $summcounter + $holidaycounter;; + } if ($savecounter == 1000) { echo $savecounter; die();