} return view('administrator/print_notification_admins', service('adminNotificationSettings')->printRecipientsPage()); } public function savePrintNotificationRecipients() { if (!$this->canManageAdminNotifications()) { return redirect()->to('/login'); } $result = service('adminNotificationSettings')->savePrintRecipients((array) $this->request->getPost('notify')); return redirect()->to('/administrator/print-notifications') ->with((string) ($result['type'] ?? 'info'), (string) ($result['message'] ?? '')); } public function studentProfiles() { $selectedYear = $this->currentSchoolYearName((string) ($this->schoolYear ?? '')); return view( 'administrator/student_profiles', service('administratorDirectory')->studentProfiles($selectedYear) ); } public function parentProfiles() { if ($redirect = $this->redirectWithoutLegacyTermFilters('administrator/parent_profiles')) { return $redirect; } return view('administrator/parent_profile', service('administratorDirectory')->parentProfiles()); } public function showEnrollmentWithdrawalPage() { try { $schoolYearContext = $this->resolveSchoolYearContext(); $selectedYear = $schoolYearContext->yearName(); $payload = service('enrollmentWithdrawal')->buildRoster($selectedYear, (string) $this->semester); return view('enroll_withdraw/enrollment_withdrawal', [ 'students' => $payload['students'], 'classes' => $payload['classes'], 'selectedYear' => $selectedYear, 'currentYear' => $selectedYear, 'isCurrentYear' => ! $schoolYearContext->isReadonly(), 'missingYear' => $selectedYear === '', ]); } catch (\Throwable $e) { log_message('error', 'Enrollment/Withdrawal page error: {msg}', ['msg' => $e->getMessage()]); return view('errors/html/error_500'); } } public function enrollmentWithdrawalData() { try { $selectedYear = $this->currentSchoolYearName((string) ($this->schoolYear ?? '')); $payload = service('enrollmentWithdrawal')->buildRoster($selectedYear, (string) $this->semester); return $this->response->setJSON([ 'students' => $payload['students'], 'classes' => $payload['classes'], 'csrfHash' => csrf_hash(), 'semester' => (string) $this->semester, 'school_year' => (string) $selectedYear, ]); } catch (\Throwable $e) { log_message('error', 'enrollmentWithdrawalData error: {msg}', ['msg' => $e->getMessage()]); return $this->response->setStatusCode(500)->setJSON(['error' => 'Server error']); } } public function showNewStudents() { return view( 'enroll_withdraw/new-students', service('enrollmentWithdrawal')->newStudents((string) $this->schoolYear) ); } public function adminEnrollmentWithdrawalHandler() { $result = service('enrollmentWithdrawal')->updateStatuses( $this->request->getPost('enrollment_status'), (string) $this->schoolYear, (string) $this->semester, (int) (session()->get('user_id') ?? 0) ?: null ); return redirect()->to(base_url('enroll_withdraw/enrollment_withdrawal')) ->with(!empty($result['ok']) ? 'success' : 'error', (string) ($result['message'] ?? '')); } }