Kalender: Standardansicht auf 4 Kalenderwochen ab aktueller KW umgestellt

This commit is contained in:
torsten 2026-11-25 22:14:39 +01:00
parent b8fe34512d
commit 660cab1001
9 changed files with 38 additions and 25 deletions

View file

@ -407,9 +407,9 @@ function calendar_url(string $date, string $view, int $employeeId, bool $showCan
function page_calendar(array $user): void
{
$view = query_string('view', 'month');
if (!in_array($view, ['day', 'week', 'month'], true)) {
$view = 'month';
$view = query_string('view', 'weeks');
if (!in_array($view, ['day', 'weeks', 'month'], true)) {
$view = 'weeks';
}
$date = query_string('date');
if (!valid_date($date)) {
@ -424,8 +424,9 @@ function page_calendar(array $user): void
$from = month_start($date);
$to = month_end($date);
} else {
// Vier Kalenderwochen ab dem Montag der Woche, in der $date liegt.
$from = week_start($date);
$to = add_days($from, 6);
$to = add_days($from, CALENDAR_WEEKS * 7 - 1);
}
$bookings = booking_list($from, $to, $showCancelled, $employeeId);
@ -449,13 +450,14 @@ function page_calendar(array $user): void
'weekday' => fmt_weekday_short($cursor),
'is_today' => $cursor === today_iso(),
'is_weekend' => (int) date_obj($cursor)->format('N') >= 6,
'is_week_start' => date_obj($cursor)->format('N') === '1',
'is_first_of_month' => date_obj($cursor)->format('j') === '1',
];
$cursor = add_days($cursor, 1);
}
$barBase = ['day' => 76, 'week' => 48, 'month' => 34][$view];
$rowMin = ['day' => 104, 'week' => 64, 'month' => 44][$view];
$barBase = ['day' => 76, 'weeks' => 34, 'month' => 34][$view];
$rowMin = ['day' => 104, 'weeks' => 44, 'month' => 44][$view];
$rows = [];
foreach ($trailers as $trailer) {
@ -480,9 +482,9 @@ function page_calendar(array $user): void
if ($view === 'day') {
$prevDate = add_days($date, -1);
$nextDate = add_days($date, 1);
} elseif ($view === 'week') {
$prevDate = add_days($date, -7);
$nextDate = add_days($date, 7);
} elseif ($view === 'weeks') {
$prevDate = add_days($date, -CALENDAR_WEEKS * 7);
$nextDate = add_days($date, CALENDAR_WEEKS * 7);
} else {
$prevDate = date_obj(month_start($date))->modify('first day of previous month')->format('Y-m-d');
$nextDate = date_obj(month_start($date))->modify('first day of next month')->format('Y-m-d');
@ -490,8 +492,9 @@ function page_calendar(array $user): void
if ($view === 'day') {
$title = fmt_date_long($date);
} elseif ($view === 'week') {
$title = 'KW ' . date_obj($from)->format('W') . ' · ' . fmt_date_range($from, $to);
} elseif ($view === 'weeks') {
$title = 'KW ' . date_obj($from)->format('W') . '–' . date_obj($to)->format('W')
. ' · ' . fmt_date_range($from, $to);
} else {
$title = fmt_month($date);
}
@ -850,7 +853,7 @@ function page_booking_delete(array $user, int $id): void
}
booking_delete($id);
flash('success', 'Buchung von ' . $booking['customer_name'] . ' wurde endgültig gelöscht.');
redirect('/calendar?view=month&date=' . $booking['start_date']);
redirect('/calendar?date=' . $booking['start_date']);
}
function page_booking_move(array $user, int $id): void