query( 'SELECT id, name FROM users WHERE active = 1 ORDER BY name ASC' )->fetchAll(); $now = new DateTimeImmutable('today'); $year = isset($_GET['year']) ? (int)$_GET['year'] : (int)$now->format('Y'); $month = isset($_GET['month']) ? (int)$_GET['month'] : (int)$now->format('n'); $year = max(2020, min(2099, $year)); $month = max(1, min(12, $month)); // Resolve selected user $selected_id = isset($_GET['user_id']) ? (int)$_GET['user_id'] : 0; $selected_user = null; foreach ($users as $u) { if ((int)$u['id'] === $selected_id) { $selected_user = $u; break; } } if (!$selected_user && !empty($users)) { $selected_user = $users[0]; $selected_id = (int)$selected_user['id']; } $first = new DateTimeImmutable(sprintf('%04d-%02d-01', $year, $month)); $month_start = $first->format('Y-m-d'); $month_end = $first->modify('last day of this month')->format('Y-m-d'); $days = (int)$first->format('t'); $prev = $first->modify('-1 month'); $next = $first->modify('+1 month'); $prev_url = '?user_id=' . $selected_id . '&year=' . $prev->format('Y') . '&month=' . $prev->format('n'); $next_url = '?user_id=' . $selected_id . '&year=' . $next->format('Y') . '&month=' . $next->format('n'); // Load shifts $schichten = []; if ($selected_id) { $stmt = db()->prepare( 'SELECT date, schicht FROM dienstplan WHERE user_id = ? AND date >= ? AND date <= ?' ); $stmt->execute([$selected_id, $month_start, $month_end]); foreach ($stmt->fetchAll() as $row) { $schichten[$row['date']] = $row['schicht']; } } // Load overlays $overlays = []; if ($selected_id) { $stmt = db()->prepare(" SELECT von, bis, 'urlaub' AS typ FROM requests_urlaubsantrag WHERE user_id = ? AND status = 'accepted' AND bis >= ? AND von <= ? UNION ALL SELECT von, bis, 'abwesenheit' AS typ FROM requests_abwesenheitsantrag WHERE user_id = ? AND status = 'accepted' AND bis >= ? AND von <= ? "); $stmt->execute([$selected_id, $month_start, $month_end, $selected_id, $month_start, $month_end]); foreach ($stmt->fetchAll() as $row) { $cursor = new DateTimeImmutable($row['von']); $end = new DateTimeImmutable($row['bis']); while ($cursor <= $end) { $key = $cursor->format('Y-m-d'); if ($key >= $month_start && $key <= $month_end) { $overlays[$key] = $row['typ']; } $cursor = $cursor->modify('+1 day'); } } } $today_str = $now->format('Y-m-d'); $schicht_labels = ['frueh' => 'Früh', 'spaet' => 'Spät', 'nacht' => 'Nacht']; $weekdays = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So']; $months_de = ['', 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember']; layout_start('Dienstpläne', 'admin-dienstplan'); ?>

Dienstpläne

format('N') - 1; for ($i = 0; $i < $lead; $i++): ?>

Keine aktiven Mitarbeiter vorhanden.