Zeiterfassung Update

* automatische Berechnung und BMD Import für NachtZulagen + Migration
This commit is contained in:
Daniel Spitzer
2025-11-30 15:00:14 +01:00
parent e117a37b40
commit 515063a03b
4 changed files with 61 additions and 22 deletions

View File

@@ -177,7 +177,6 @@ class TimerecordingReportController extends mfBaseController
}
} else if ($datatype == 5) {
$firstdate = strtotime(date("Y-01-01", $datayear));
$lastdate = strtotime(date("Y-12-31 23:59:59", $datayear));
@@ -200,7 +199,6 @@ class TimerecordingReportController extends mfBaseController
}
}
@@ -235,7 +233,7 @@ class TimerecordingReportController extends mfBaseController
$datadate = date("Y-m-d", $timerecording->start);
$enddate = date("Y-m-d", $timerecording->end + 7200);
$enddate2= date("Y-m-d", $timerecording->end);
$enddate2 = date("Y-m-d", $timerecording->end);
$start = "-";
$end = "-";
$day = $daysgerm[date("w", $timerecording->start)];
@@ -439,13 +437,13 @@ class TimerecordingReportController extends mfBaseController
$seconds = $timerecording->end - $timerecording->start;
$minutes = floor(($seconds % 3600) / 60);
$hours = floor($seconds / 3600);
$sum = "-" .sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
$sum = "-" . sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
$day = $daysgerm[date("w", $timerecording->start)];
}
if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0 )|| ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 0)) {
if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) || ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 0)) {
$state = '<i class="fa-regular fa-clock mr-1"></i>';
} else if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) || ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 1 )) {
} else if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) || ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 1)) {
$state = '<i class="fa-regular fa-circle-check mr-1"></i>';
}
$edit = "";
@@ -471,7 +469,7 @@ class TimerecordingReportController extends mfBaseController
if ($timerecording->completed == 0):
if ($timerecording->approved == 0 || $timerecording->approved == 1) :
if ($timerecording->approved == 0 || $timerecording->approved == 1) :
$ddays = $timerecording->days;
if ($timerecording->timerecordingCategory->hourday == 8) {
$ddays = round($timerecording->hours_bpa / 60 / 60, 2);
@@ -574,7 +572,7 @@ class TimerecordingReportController extends mfBaseController
die();
}
private function checkOvertime($timerecording,$night_allowance=0)
private function checkOvertime($timerecording, $night_allowance = 0)
{
$start = $timerecording->start;
$end = $timerecording->end;
@@ -584,6 +582,7 @@ class TimerecordingReportController extends mfBaseController
$O100pfl = 0;
$O100end = strtotime(date('Y-m-d', $start) . " 06:00:00");
$O100start = strtotime(date('Y-m-d', $start) . " 22:00:00");
$nightAllowance = 0;
foreach ($this->holidays as $holiday) {
@@ -593,10 +592,10 @@ class TimerecordingReportController extends mfBaseController
$end = $timerecording->end;
$startday = date('Y-m-d', $start);
if ((date('w', $start) == 0 || $holiDay[$startday]) && $night_allowance==0) {
if ((date('w', $start) == 0 || $holiDay[$startday]) && $night_allowance == 0) {
$O100free = $O100free + $timerecording->end - $timerecording->start;
} else {
if (($start < $O100end || $start > $O100start || $end < $O100end || $end > $O100start) && $night_allowance==0) {
if (($start < $O100end || $start > $O100start || $end < $O100end || $end > $O100start) && $night_allowance == 0) {
$sum = $end - $start;
if ($sum >= 10800) {
if ($start < $O100end) {
@@ -626,16 +625,20 @@ class TimerecordingReportController extends mfBaseController
// }
// }
// }
} else {
// if (date('w', $start) == 6) {
// $O50free = $O50free + $end - $start;
// }
} else if (($start < $O100end || $start > $O100start || $end < $O100end || $end > $O100start) && $night_allowance == 1) {
if ($start < $O100end) {
$nightAllowance = $nightAllowance + $O100end - $start;
}
if ($end >= $O100start) {
$nightAllowance = $nightAllowance + $end - $O100start;
}
}
}
$response['O100free'] = $O100free;
$response['O100pfl'] = $O100pfl;
$response['O50free'] = $O50free;
$response['O50pfl'] = $O50pfl;
$response['nightAllowance'] = $nightAllowance;
$response['sum'] = $O100free + $O100pfl + $O50free + $O50pfl;
return $response;
}
@@ -663,7 +666,7 @@ class TimerecordingReportController extends mfBaseController
$plusHours_now = $employee[0]->plushours_now;
$overtime_now = $employee[0]->overtime_now;
$auto_workinghours = $employee[0]->auto_workinghours;
$night_allowance= $employee[0]->night_allowance;
$night_allowance = $employee[0]->night_allowance;
$startdate = $employee[0]->startdate;
if ($employee[0]->enddate) {
$enddate = strtotime(date('Y-m-d', $employee[0]->enddate) . " 23:59:59");
@@ -828,6 +831,7 @@ class TimerecordingReportController extends mfBaseController
$O50free = 0;
$O50pfl = 0;
$Osum = 0;
$nightAllowance = 0;
foreach ($timerecordings as $timerecording):
$state = "";
@@ -896,7 +900,7 @@ class TimerecordingReportController extends mfBaseController
$nlzTimes[$timerecording->id]['category'] = $timerecording->timerecordingCategory->name;
$nlzTimes[$timerecording->id]['categoryshort'] = $timerecording->timerecordingCategory->short;
} else {
$overtimes = $this->checkOvertime($timerecording,$night_allowance);
$overtimes = $this->checkOvertime($timerecording, $night_allowance);
$isSecondscleanarray[$timerecording->timerecordingCategory->short] = $isSecondscleanarray[$timerecording->timerecordingCategory->short] - $overtimes['sum'];
if ($employee->only_admin != 1) {
@@ -907,6 +911,7 @@ class TimerecordingReportController extends mfBaseController
$O100free = $O100free + $overtimes['O100free'];
$O50free = $O50free + $overtimes['O50free'];
$O50pfl = $O50pfl + $overtimes['O50pfl'];
$nightAllowance = $nightAllowance + $overtimes['nightAllowance'];
$Osum = $Osum + $overtimes['sum'];
}
} else if ($timerecording->timerecordingCategory->hourday == 2 || ($timerecording->timerecordingCategory->hourday == 3 && $timerecording->end)) {
@@ -1176,7 +1181,7 @@ class TimerecordingReportController extends mfBaseController
$json['time']['daysum'] = $daysum;
$json['recordsFiltered'] = $responsecount;
$json['recordsTotal'] = $responsecount;
$json['time']['overtimes'] = ['O100free' => $O100free, 'O100pfl' => $O100pfl, 'O50free' => $O50free, 'O50pfl' => $O50pfl, 'Osum' => $Osum];
$json['time']['overtimes'] = ['O100free' => $O100free, 'O100pfl' => $O100pfl, 'O50free' => $O50free, 'O50pfl' => $O50pfl,'nightAllowance' => $nightAllowance, 'Osum' => $Osum];
if ($ajax == 1) {
$json = json_encode($json);