public function absenceFormAdmin() { $userId = (int)(session()->get('user_id') ?? 0); if ($userId <= 0) { return redirect()->to('login')->with('error', 'Please log in first.'); } $admin = $this->userModel->find($userId); $displayName = $admin ? trim(($admin['firstname'] ?? '') . ' ' . ($admin['lastname'] ?? '')) : 'Administrator'; $semester = (string)($this->semester ?? ''); $schoolYear = (string)($this->schoolYear ?? ''); $existing = $this->staffAttendanceModel ->where('user_id', $userId) ->where('semester', $semester) ->where('school_year', $schoolYear) ->orderBy('date', 'DESC') ->findAll(); return view('administrator/absence_vacation', [ 'admin_name' => $displayName, 'semester' => $semester, 'schoolYear' => $schoolYear, 'existing' => $existing, 'availableDates' => $this->allowedAbsenceDates(), ]); } /** * Handle admin absence submission (upserts staff_attendance like the teacher flow) */