Kalender: Abwesenheiten als eigene Zeilen mit dunklen Balken, kollidierende Buchungen blinken
This commit is contained in:
parent
e83d6dc606
commit
87fd553464
6 changed files with 128 additions and 3 deletions
|
|
@ -492,6 +492,7 @@ function page_calendar(array $user): void
|
|||
$bars[] = [
|
||||
'booking' => $booking,
|
||||
'geo' => calendar_geometry($booking, $from, $to, $lanes),
|
||||
'absent' => booking_absent_hits($booking, $absences) !== [],
|
||||
];
|
||||
}
|
||||
$rows[] = [
|
||||
|
|
@ -527,6 +528,31 @@ function page_calendar(array $user): void
|
|||
|
||||
$employees = employees_all();
|
||||
$absences = absence_list($from, $to);
|
||||
|
||||
// Abwesenheiten als eigene Zeilen unterhalb der Anhänger.
|
||||
$absencesByEmployee = [];
|
||||
foreach ($absences as $absence) {
|
||||
$absencesByEmployee[(int) $absence['employee_id']][] = $absence;
|
||||
}
|
||||
$absenceRows = [];
|
||||
foreach ($absencesByEmployee as $employeeAbsences) {
|
||||
$laneInfo = calendar_lanes($employeeAbsences);
|
||||
$bars = [];
|
||||
foreach ($laneInfo['bookings'] as $absence) {
|
||||
$bars[] = [
|
||||
'absence' => $absence,
|
||||
'geo' => calendar_geometry($absence, $from, $to, $laneInfo['lanes']),
|
||||
];
|
||||
}
|
||||
$absenceRows[] = [
|
||||
'employee_name' => (string) $employeeAbsences[0]['employee_name'],
|
||||
'employee_id' => (int) $employeeAbsences[0]['employee_id'],
|
||||
'bars' => $bars,
|
||||
'count' => count($employeeAbsences),
|
||||
'height' => max($rowMin, $barBase * $laneInfo['lanes'] + 16),
|
||||
];
|
||||
}
|
||||
|
||||
render_page('calendar', [
|
||||
'view' => $view,
|
||||
'date' => $date,
|
||||
|
|
@ -544,6 +570,7 @@ function page_calendar(array $user): void
|
|||
'employees' => $employees,
|
||||
'bookingCount' => count($bookings),
|
||||
'absences' => $absences,
|
||||
'absenceRows' => $absenceRows,
|
||||
'urlFor' => static function (string $d) use ($view, $employeeId, $showCancelled): string {
|
||||
return calendar_url($d, $view, $employeeId, $showCancelled);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue