fix is_active student flag and apply it in all pages
This commit is contained in:
@@ -2783,13 +2783,23 @@ class StudentController extends BaseController
|
||||
return redirect()->back()->with('error', 'Invalid student id.');
|
||||
}
|
||||
|
||||
$roleRaw = session()->get('role');
|
||||
if (is_array($roleRaw)) {
|
||||
$roleRaw = $roleRaw[0] ?? 'guest';
|
||||
}
|
||||
$role = strtolower((string)($roleRaw ?? 'guest'));
|
||||
$isAdminScoreCardAccess = in_array($role, ['administrator', 'admin', 'principal', 'administrative staff'], true);
|
||||
|
||||
$student = $this->studentModel
|
||||
->select('id, firstname, lastname, school_id')
|
||||
->select('id, firstname, lastname, school_id, is_active')
|
||||
->where('id', $studentId)
|
||||
->first();
|
||||
if (!$student) {
|
||||
return $this->response->setStatusCode(404)->setBody('<div class="p-3 text-danger">Student not found.</div>');
|
||||
}
|
||||
if (!$isAdminScoreCardAccess && (int)($student['is_active'] ?? 0) !== 1) {
|
||||
return redirect()->to('/student/score-card/list')->with('error', 'Student score card is not available.');
|
||||
}
|
||||
|
||||
$rows = $this->db->table('semester_scores ss')
|
||||
->select([
|
||||
@@ -3011,14 +3021,14 @@ class StudentController extends BaseController
|
||||
$schoolYear = $this->currentSchoolYearName((string) ($this->schoolYear ?? ''));
|
||||
$parentId = (int)(session()->get('user_id') ?? 0);
|
||||
if ($parentId > 0 && $schoolYear !== '') {
|
||||
$students = $this->studentModel->getByParentAndYear($parentId, $schoolYear);
|
||||
$students = $this->studentModel->getActiveByParentAndYear($parentId, $schoolYear);
|
||||
}
|
||||
} elseif (in_array($role, ['teacher', 'teacher_assistant', 'teacher_dashboard'], true)) {
|
||||
$schoolYear = $this->currentSchoolYearName((string) ($this->schoolYear ?? ''));
|
||||
$classSectionId = (int)(session()->get('class_section_id') ?? 0);
|
||||
|
||||
if ($classSectionId > 0 && !empty($schoolYear)) {
|
||||
$students = $this->studentModel->getByClassAndYear($classSectionId, $schoolYear);
|
||||
$students = $this->studentModel->getActiveByClassAndYear($classSectionId, $schoolYear);
|
||||
}
|
||||
|
||||
if (empty($students)) {
|
||||
@@ -3039,10 +3049,10 @@ class StudentController extends BaseController
|
||||
$studentClassModel = new \App\Models\StudentClassModel();
|
||||
$rows = $studentClassModel->getStudentsByClassSectionIds($sectionIds, $schoolYear);
|
||||
$unique = [];
|
||||
foreach ($rows as $r) {
|
||||
$sid = (int)($r['student_id'] ?? 0);
|
||||
if ($sid > 0) {
|
||||
$unique[$sid] = [
|
||||
foreach ($rows as $r) {
|
||||
$sid = (int)($r['student_id'] ?? 0);
|
||||
if ($sid > 0 && (int)($r['is_active'] ?? 0) === 1) {
|
||||
$unique[$sid] = [
|
||||
'id' => $sid,
|
||||
'school_id' => $r['school_id'] ?? '',
|
||||
'firstname' => $r['firstname'] ?? '',
|
||||
|
||||
Reference in New Issue
Block a user