} $role = trim((string) ($session->get('role') ?? '')); if ($role === '') { return false; } $excluded = array_map( fn ($value) => strtolower(trim((string) $value)), service('adminNotificationSettings')->excludedRoles() ); return !in_array(strtolower($role), $excluded, true); } public function administratorDashboard() { helper('url'); $searchData = service('administratorDashboard')->search((string) $this->request->getGet('query')); return view('administrator/administratordashboard', array_merge($searchData, [ 'dashboardEndpoint' => site_url('api/administrator/dashboard'), 'schoolYear' => $this->schoolYear, ])); } public function dashboardMetrics() { return $this->response->setJSON( service('administratorDashboard')->metrics((string) $this->schoolYear, (string) $this->semester) ); } public function userSearch() { $data = service('administratorDashboard')->search((string) $this->request->getGet('query')); return view('administrator/search_results', $data); } public function teacherSubmissionsReport() { $semester = (string) ($this->semester !== '' ? $this->semester : (getSemester() ?? $this->semester ?? '')); $schoolYear = trim((string) ($this->request->getGet('school_year') ?? '')); if ($schoolYear === '') { $schoolYear = $this->currentSchoolYearName((string) ($this->schoolYear ?? '')); } $lowProgressRaw = (string) $this->request->getGet('low_progress_sections'); $lowProgressSectionIds = array_values(array_unique(array_filter(array_map( 'intval', preg_split('/\s*,\s*/', $lowProgressRaw, -1, PREG_SPLIT_NO_EMPTY) )))); return view( 'administrator/teacher_submissions', service('teacherSubmissionReport')->buildReport($semester, $schoolYear, $lowProgressSectionIds) ); } public function sendTeacherSubmissionNotifications() { $result = service('teacherSubmissionReport')->sendNotifications( (array) $this->request->getPost(), (string) ($this->semester !== '' ? $this->semester : (getSemester() ?? '')), (int) (session()->get('user_id') ?? 0) ); if (($result['redirect'] ?? '') === 'login') { return redirect()->to('/login'); } return redirect()->back()->with((string) ($result['type'] ?? 'info'), (string) ($result['message'] ?? '')); } public function notificationsAlerts() { if (!$this->canManageAdminNotifications()) { return redirect()->to('/login'); } return view('administrator/notifications_alerts', service('adminNotificationSettings')->alertsPage()); } public function saveNotificationSubjects() { if (!$this->canManageAdminNotifications()) { return redirect()->to('/login'); } $result = service('adminNotificationSettings')->saveSubjects($this->request->getPost('subjects')); return redirect()->to('/administrator/notifications_alerts') ->with((string) ($result['type'] ?? 'info'), (string) ($result['message'] ?? '')); } public function printNotificationRecipients() { if (!$this->canManageAdminNotifications()) { return redirect()->to('/login');