From 45a07abf0e2b396634fe0b39b247393399921254 Mon Sep 17 00:00:00 2001 From: Spi Date: Mon, 29 Apr 2024 20:15:39 +0200 Subject: [PATCH] =?UTF-8?q?Zeiterfassung=20Update=20=20*=20Erstberechnung?= =?UTF-8?q?=20=C3=9Cberstunden=2050%/100%=20Steuerfrei/Steuerpflichtig=20?= =?UTF-8?q?=20*=20Feiertag=20werden=20nun=20in=20der=20Buchungs=C3=BCbersi?= =?UTF-8?q?cht=20angezeigt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Layout/default/Timerecording/Index.php | 4 ++ .../default/TimerecordingBilling/Detail.php | 2 +- .../Timerecording/TimerecordingController.php | 23 ++++++- .../TimerecordingReportController.php | 68 ++++++++++++++++++- public/js/pages/timerecordingReport/index.js | 4 -- 5 files changed, 93 insertions(+), 8 deletions(-) diff --git a/Layout/default/Timerecording/Index.php b/Layout/default/Timerecording/Index.php index f47d0270b..a5199b793 100644 --- a/Layout/default/Timerecording/Index.php +++ b/Layout/default/Timerecording/Index.php @@ -89,6 +89,10 @@ $years[time() - 31536000] = date('Y', time() - 31536000); .form-check-label { margin-top: 2px; } + .holiday-text + { + color: #d70000; + } diff --git a/Layout/default/TimerecordingBilling/Detail.php b/Layout/default/TimerecordingBilling/Detail.php index 1523b89a8..9d85df9ca 100644 --- a/Layout/default/TimerecordingBilling/Detail.php +++ b/Layout/default/TimerecordingBilling/Detail.php @@ -139,7 +139,7 @@ month: $.trim($('#month').data('month')), ajax: 1 }).done(function (data) { - window.location.href = " $month]) ?>"; + window.location.href = " $month]) ?>"; }); } diff --git a/application/Timerecording/TimerecordingController.php b/application/Timerecording/TimerecordingController.php index e7d311669..ee0a281fb 100644 --- a/application/Timerecording/TimerecordingController.php +++ b/application/Timerecording/TimerecordingController.php @@ -599,6 +599,7 @@ class TimerecordingController extends mfBaseController protected function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear, $startime = null, $endtime = null, $userid = null) { + $holidayrows = []; $mustSeconds = 0; $isSeconds = 0; $holiDays = 0; @@ -635,7 +636,7 @@ class TimerecordingController extends mfBaseController } } foreach ($holidays as $holiday) { - $holiDay[date('Y-m-d', $holiday->timestamp)] = $holiday->timestamp; + $holiDay[date('Y-m-d', $holiday->timestamp)] = $holiday->description; } if ($datatype == 1) { @@ -655,6 +656,8 @@ class TimerecordingController extends mfBaseController $dDay = date('w', $timestamp); if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) { $mustSeconds = $mustSeconds + $workingHours[$dDay]; + } elseif ($holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) { + $holidayrows[$timestamp] = $holiDay[$dDate]; } $timestamp = $timestamp + 86400; @@ -672,6 +675,8 @@ class TimerecordingController extends mfBaseController $dDay = date('w', $timestamp); if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) { $mustSeconds = $mustSeconds + $workingHours[$dDay]; + } elseif ($holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) { + $holidayrows[$timestamp] = $holiDay[$dDate]; } $timestamp = $timestamp + 86400; } @@ -683,11 +688,13 @@ class TimerecordingController extends mfBaseController $searchArray = ['user_id' => $userid, 'start' => $firstdate, 'end' => $lastdate]; $timestamp = $firstdate; - for ($i = 1; $i <= $daycount; $i++) { + for ($i = 1; $i <= 366; $i++) { $dDate = date('Y-m-d', $timestamp); $dDay = date('w', $timestamp); if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) { $mustSeconds = $mustSeconds + $workingHours[$dDay]; + } elseif ($holiDay[$dDate]) { + $holidayrows[$timestamp] = $holiDay[$dDate]; } $timestamp = $timestamp + 86400; } @@ -928,6 +935,18 @@ class TimerecordingController extends mfBaseController ); } endforeach; + foreach ($holidayrows as $key => $holidayrow) { + $day = $daysgerm[date("w", $key)]; + $rows[] = array( + 'date' => array('date' => ''.$day." ".date("d.m.Y",$key).'', 'order' => $key), + 'start' => array('start' => "-", 'order' => "-"), + 'end' => array('end' => "-", 'order' => "-"), + 'sum' => array('sum' => "-", 'order' => "-"), + 'category' => array('category' => 'Feiertag ', 'order' => 'Feiertag'), + 'comment' => array('comment' => ''.$holidayrow.'', 'order' => $holidayrow), + 'edit' => array('edit' => "", 'order' => ""), + ); + } if ($datatype == 5) { $response['is'] = $isSeconds; $response['must'] = $mustSeconds; diff --git a/application/TimerecordingReport/TimerecordingReportController.php b/application/TimerecordingReport/TimerecordingReportController.php index 77f031ad4..5c7886dc8 100644 --- a/application/TimerecordingReport/TimerecordingReportController.php +++ b/application/TimerecordingReport/TimerecordingReportController.php @@ -386,6 +386,69 @@ class TimerecordingReportController extends mfBaseController die(); } + private function checkOvertime($timerecording) + { + $start = $timerecording->start; + $end = $timerecording->end; + $O50free = 0; + $O50pfl = 0; + $O100free = 0; + $O100pfl = 0; + $O100end = strtotime(date('Y-m-d', $start) . " 06:00:00"); + $O100start = strtotime(date('Y-m-d', $start) . " 22:00:00"); + + $holidays = TimerecordingHolidayModel::getAll(); + foreach ($holidays as $holiday) { + $holiDay[date('Y-m-d', $holiday->timestamp)] = $holiday->timestamp; + } + $start = $timerecording->start; + $end = $timerecording->end; + $startday = date('Y-m-d', $start); + + if (date('w', $start) == 0 || $holiDay[$startday]) { + $O100free = $O100free + $timerecording->end - $timerecording->start; + } else { + if ($start < $O100end || $start > $O100start || $end < $O100end || $end > $O100start) { + $sum = $end - $start; + if ($sum >= 10800) { + if ($start < $O100end) { + $O100free = $O100free + $O100end - $start; + } + if ($end >= $O100start) { + $O100free = $O100free + $end - $O100start; + } + if (date('w', $start) == 6) { + if ($sum != $O100free) { + $O50free = $O50free + $sum - $O100free; + } + } + + } else { + if ($start < $O100end) { + $O100pfl = $O100pfl + $O100end - $start; + } + if ($end >= $O100start) { + $O100pfl = $O100pfl + $end - $O100start; + } + if (date('w', $start) == 6) { + if ($sum != $O100free) { + $O50free = $O50free + $sum - $O100free; + } + } + } + } else { + if (date('w', $start) == 6) { + $O50free = $O50free + $end - $start; + } + } + } + $response['O100free'] = $O100free; + $response['O100pfl'] = $O100pfl; + $response['O50free'] = $O50free; + $response['O50pfl'] = $O50pfl; + $response['sum'] = $O100free + $O100pfl + $O50free + $O50pfl; + return $response; + } public function getTimerecordingsTimes($datatype, $dataweek, $datamonth, $datayear, $user_id = NULL, $ajax = 1) { @@ -567,7 +630,6 @@ class TimerecordingReportController extends mfBaseController $isSecondscleanarray[$timerecording->timerecordingCategory->short] = $seconds; } - if ($timerecording->timerecordingCategory->short != "1000,1200,1400") { if (!$daysum[$timerecording->timerecordingCategory->name]) { $daysum[$timerecording->timerecordingCategory->name] = $seconds; @@ -581,6 +643,10 @@ class TimerecordingReportController extends mfBaseController $nlzTimes[$timerecording->id]['unpaid'] = $timerecording->timerecordingCategory->unpaid; $nlzTimes[$timerecording->id]['category'] = $timerecording->timerecordingCategory->name; $nlzTimes[$timerecording->id]['categoryshort'] = $timerecording->timerecordingCategory->short; + } else { + $overtimes = $this->checkOvertime($timerecording); + $isSecondscleanarray[$timerecording->timerecordingCategory->short] = $isSecondscleanarray[$timerecording->timerecordingCategory->short] - $overtimes['sum']; + $isSeconds = $isSeconds - $overtimes['sum']; } } 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); diff --git a/public/js/pages/timerecordingReport/index.js b/public/js/pages/timerecordingReport/index.js index 76f10a64d..009b27b21 100644 --- a/public/js/pages/timerecordingReport/index.js +++ b/public/js/pages/timerecordingReport/index.js @@ -87,10 +87,6 @@ table = $('#datatable').DataTable({ d.datayear = $('#datayear').val(); }, "dataSrc": function (json) { - $('#is-time').text(json.time.is); - $('#must-time').text(json.time.must); - $('#holidays').text(json.time.holidays); - $('#plushours').text(json.time.plushours); $('#selectsearch').change(); return json.data; }