From df2dd9c5965d17ce75c5ed73c5fd5a95831f2fa8 Mon Sep 17 00:00:00 2001 From: Daniel Spitzer Date: Fri, 6 Jun 2025 09:29:25 +0200 Subject: [PATCH] Kalender Anpassungen - Anpassungen bei neuen Kalenderbenutzern --- .../Timerecording/TimerecordingController.php | 9 ++- .../Timerecording/TimerecordingModel.php | 5 +- .../TimerecordingCategoryModel.php | 2 +- .../TimerecordingReportController.php | 66 ++++++++++--------- public/js/pages/timerecordingReport/index.js | 21 ++++++ 5 files changed, 68 insertions(+), 35 deletions(-) diff --git a/application/Timerecording/TimerecordingController.php b/application/Timerecording/TimerecordingController.php index a2495ec5f..f48155475 100644 --- a/application/Timerecording/TimerecordingController.php +++ b/application/Timerecording/TimerecordingController.php @@ -292,7 +292,7 @@ class TimerecordingController extends mfBaseController } else if ($hourday == 3) { $starttime = strtotime($r->date . " 00:00:00"); $endtime = NULL; - } else if ($hourday == 5) { + } else if ($hourday == 5 || $hourday == 9) { $starttime = strtotime($r->date . " 00:00:00"); $endtime = strtotime($r->date . " 23:59:00"); } else if ($hourday == 8) { @@ -300,7 +300,7 @@ class TimerecordingController extends mfBaseController $endtime = strtotime($r->date . " 23:59:00"); } - if ($hourday != 5 && $hourday != 7 && $hourday != 8) { + if ($hourday != 5 && $hourday != 7 && $hourday != 8 && $hourday != 9) { $result = $this->checkTimerecording($starttime, $endtime, $id); } if ($result['state'] == "error") { @@ -342,9 +342,14 @@ class TimerecordingController extends mfBaseController if ($hourday == 8) { $data['days'] = 0; $data['hours_bpa'] = $r->days * 60 * 60; + } else if ($hourday == 9) { + $data['days'] = 0; + $data['hours'] = $r->days * 60 * 60; + $data['hours'] = 0 - $data['hours']; } else { $data['days'] = $r->days; } + $data['timerecordingCar_id'] = $r->timerecordingCar_id; $data['mileage_start'] = $r->mileage_start; $data['mileage_end'] = $r->mileage_end; diff --git a/application/Timerecording/TimerecordingModel.php b/application/Timerecording/TimerecordingModel.php index 1577a8005..d7f86a1da 100644 --- a/application/Timerecording/TimerecordingModel.php +++ b/application/Timerecording/TimerecordingModel.php @@ -74,12 +74,13 @@ class TimerecordingModel } return $item; } + public static function getAllHours($user_id) { $items = []; $db = FronkDB::singleton(); - $sql="SELECT SUM(`end` - `start`) AS gesamt_summe FROM Timerecording where user_id=$user_id AND `timerecordingCategory_id` =1"; + $sql = "SELECT SUM(`end` - `start`) AS gesamt_summe FROM Timerecording where user_id=$user_id AND `timerecordingCategory_id` =1"; $res = $db->query($sql); if ($db->num_rows($res)) { while ($data = $db->fetch_object($res)) { @@ -185,7 +186,7 @@ class TimerecordingModel if (array_key_exists("start", $filter) && array_key_exists("hours", $filter)) { $start = $filter['start']; if (is_numeric($start)) { - $where .= " AND `start` >= $start AND (`hours`>0 or `hours_overtime`>0) ORDER by start ASC"; + $where .= " AND `start` >= $start AND (`hours`>0 or `hours`<0 or `hours_overtime`>0) ORDER by start ASC"; } } if (array_key_exists("start", $filter) && array_key_exists("days", $filter)) { diff --git a/application/TimerecordingCategory/TimerecordingCategoryModel.php b/application/TimerecordingCategory/TimerecordingCategoryModel.php index dac2ffd14..e57ca7191 100644 --- a/application/TimerecordingCategory/TimerecordingCategoryModel.php +++ b/application/TimerecordingCategory/TimerecordingCategoryModel.php @@ -10,7 +10,7 @@ class TimerecordingCategoryModel private $only_admin; private $businesstrip; private $unpaid; - public static $hourday_definition = array(1 => "Uhrzeit (von/bis)", 2 => "Tage (von/bis)", 3 => "Startdatum", 4 => "Enddatum", 5 => "Anzahl Tage", 6 => "ZA Uhrzeit (von/bis)", 7 => "Fahrtenbuch (von/bis)",8 => "BP Stunden (Anzahl Stunden)"); + public static $hourday_definition = array(1 => "Uhrzeit (von/bis)", 2 => "Tage (von/bis)", 3 => "Startdatum", 4 => "Enddatum", 5 => "Anzahl Tage", 9 => "Anzahl Stunden", 6 => "ZA Uhrzeit (von/bis)", 7 => "Fahrtenbuch (von/bis)",8 => "BP Stunden (Anzahl Stunden)"); public static $approval_definition = array(0 => "Nein", 1 => "Ja"); public static $require_comment_definition = array(0 => "Nein", 1 => "Ja"); public static $businesstrip_definition = array(0 => "Nein", 1 => "Ja"); diff --git a/application/TimerecordingReport/TimerecordingReportController.php b/application/TimerecordingReport/TimerecordingReportController.php index 75bfec538..299b3e3b3 100644 --- a/application/TimerecordingReport/TimerecordingReportController.php +++ b/application/TimerecordingReport/TimerecordingReportController.php @@ -333,6 +333,22 @@ class TimerecordingReportController extends mfBaseController } else { $sum = $hoursbpa . " St"; } + } else if ($timerecording->timerecordingCategory->hourday == 9) { + $date = date("d.m.Y", $timerecording->start); + $start = "-"; + $end = "-"; + $datadate = date("Y-m-d", $timerecording->start); + $day = $daysgerm[date("w", $timerecording->start)]; +// $hours = number_format($timerecording->hours_bpa / 60 / 60, "2", ",", ''); + $timerecording->hours = $timerecording->hours * -1; + $hoursbpa = round($timerecording->hours / 60 / 60, 2); + $hoursbpa = str_replace(".", ",", $hoursbpa); + + if ($timerecording->hours > 0) { + $sum = "+" . $hoursbpa . " St"; + } else { + $sum = $hoursbpa . " St"; + } } else if ($timerecording->timerecordingCategory->hourday == 6) { $date = date("d.m.Y", $timerecording->start); $datadate = date("Y-m-d", $timerecording->start); @@ -389,6 +405,9 @@ class TimerecordingReportController extends mfBaseController $ddays = $timerecording->days; if ($timerecording->timerecordingCategory->hourday == 8) { $ddays = round($timerecording->hours_bpa / 60 / 60, 2); + } elseif ($timerecording->timerecordingCategory->hourday == 9) { + $ddays = round($timerecording->hours / 60 / 60, 2); +// $ddays = $ddays * -1; } $edit = ' $user_id]); if ($workinghourshistory) { - $workingHoursHistory[9732489200]=$workingHours; + $workingHoursHistory[9732489200] = $workingHours; foreach ($workinghourshistory as $workinghourhistory) { $whenddate = $workinghourhistory->enddate; $workinghourhistoryhours = json_decode($workinghourhistory->workinghours, true); @@ -600,14 +619,12 @@ class TimerecordingReportController extends mfBaseController } $dDate = date('Y-m-d', $timestamp + $WintertimeCompensation); $dDay = date('w', $timestamp + $WintertimeCompensation); - if ($workingHoursHistory) - { + if ($workingHoursHistory) { foreach ($workingHoursHistory as $whkey => $whdata) { - $whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey)); - if ($whtimestamp >= $timestamp) - { - $workingHours = $whdata; - } + $whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey)); + if ($whtimestamp >= $timestamp) { + $workingHours = $whdata; + } } } @@ -636,12 +653,10 @@ class TimerecordingReportController extends mfBaseController } $dDate = date('Y-m-d', $timestamp + $WintertimeCompensation); $dDay = date('w', $timestamp + $WintertimeCompensation); - if ($workingHoursHistory) - { + if ($workingHoursHistory) { foreach ($workingHoursHistory as $whkey => $whdata) { $whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey)); - if ($whtimestamp >= $timestamp) - { + if ($whtimestamp >= $timestamp) { $workingHours = $whdata; } } @@ -670,12 +685,10 @@ class TimerecordingReportController extends mfBaseController } $dDate = date('Y-m-d', $timestamp + $WintertimeCompensation); $dDay = date('w', $timestamp + $WintertimeCompensation); - if ($workingHoursHistory) - { + if ($workingHoursHistory) { foreach ($workingHoursHistory as $whkey => $whdata) { $whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey)); - if ($whtimestamp >= $timestamp) - { + if ($whtimestamp >= $timestamp) { $workingHours = $whdata; } } @@ -778,13 +791,10 @@ class TimerecordingReportController extends mfBaseController } else { $overtimes = $this->checkOvertime($timerecording); $isSecondscleanarray[$timerecording->timerecordingCategory->short] = $isSecondscleanarray[$timerecording->timerecordingCategory->short] - $overtimes['sum']; - if ($employee->only_admin!=1) - { + if ($employee->only_admin != 1) { - } - else - { - $isSeconds = $isSeconds - $overtimes['sum']; + } else { + $isSeconds = $isSeconds - $overtimes['sum']; } $O100pfl = $O100pfl + $overtimes['O100pfl']; $O100free = $O100free + $overtimes['O100free']; @@ -815,12 +825,10 @@ class TimerecordingReportController extends mfBaseController $sumdays = 0; for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) { - if ($workingHoursHistory) - { + if ($workingHoursHistory) { foreach ($workingHoursHistory as $whkey => $whdata) { $whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey)); - if ($whtimestamp >= $i) - { + if ($whtimestamp >= $i) { $workingHours = $whdata; } } @@ -881,12 +889,10 @@ class TimerecordingReportController extends mfBaseController $summcounter = 0; $savecounter = 0; for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) { - if ($workingHoursHistory) - { + if ($workingHoursHistory) { foreach ($workingHoursHistory as $whkey => $whdata) { $whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey)); - if ($whtimestamp >= $i) - { + if ($whtimestamp >= $i) { $workingHours = $whdata; } } diff --git a/public/js/pages/timerecordingReport/index.js b/public/js/pages/timerecordingReport/index.js index eab5931f9..6fcddcb54 100644 --- a/public/js/pages/timerecordingReport/index.js +++ b/public/js/pages/timerecordingReport/index.js @@ -310,6 +310,7 @@ $(document).ready(function () { $('#days-div').show(); $('#days-div').find('label').text('Anzahl Tage'); $('#days-div').find('input').attr("step", "1"); + $('#days-div').find('input').attr("min", ""); $('#days-div').find('input').val(""); $('#days').prop("required", true); @@ -346,6 +347,26 @@ $(document).ready(function () { $('#days-div').show(); $('#days-div').find('label').text('Anzahl Stunden'); $('#days-div').find('input').attr("step", "0.01"); + $('#days-div').find('input').attr("min", ""); + $('#days').prop("required", true); + $('#days-div').find('input').val(""); + } else if (parseInt($(this).find(':selected').data('hourday')) === 9) { + $("#endtime-div").hide(); + $("#endtime-div").find('input').each(function () { + $(this).prop("required", false); + $(this).prop("disabled", true); + + }); + $("#enddate-div").hide(); + $("#enddate-div").find('input').each(function () { + $(this).prop("required", false); + $(this).prop("min", ''); + $(this).val(''); + }); + $('#days-div').show(); + $('#days-div').find('label').text('Anzahl Stunden'); + $('#days-div').find('input').attr("step", "0.01"); + $('#days-div').find('input').attr("min", "0"); $('#days').prop("required", true); $('#days-div').find('input').val(""); }