fix is_active student flag and apply it in all pages
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 48s
Tests / PHPUnit (push) Successful in 1m17s

This commit is contained in:
root
2026-08-20 12:59:59 -04:00
parent 0a31aa1393
commit bfa343b69f
57 changed files with 820 additions and 240 deletions
@@ -2135,6 +2135,31 @@ class AdministratorController extends BaseController
->getResultArray();
}
$enrollmentStatusByStudentId = [];
$studentIds = array_values(array_unique(array_filter(array_map(
static fn (array $row): int => (int) ($row['id'] ?? 0),
$students
))));
if ($selectedYear !== '' && !empty($studentIds)) {
$enrollmentRows = $db->table('enrollments')
->select('student_id, enrollment_status')
->whereIn('student_id', $studentIds)
->where('school_year', $selectedYear)
->orderBy('student_id', 'ASC')
->orderBy('updated_at', 'DESC')
->orderBy('enrollment_date', 'DESC')
->orderBy('id', 'DESC')
->get()
->getResultArray();
foreach ($enrollmentRows as $enrollmentRow) {
$studentId = (int) ($enrollmentRow['student_id'] ?? 0);
if ($studentId > 0 && !isset($enrollmentStatusByStudentId[$studentId])) {
$enrollmentStatusByStudentId[$studentId] = (string) ($enrollmentRow['enrollment_status'] ?? '');
}
}
}
// === Inject current-year class_section_name from student_class and replace grade ===
foreach ($students as $i => $row) {
$sid = (int) ($row['id'] ?? 0);
@@ -2142,9 +2167,11 @@ class AdministratorController extends BaseController
$classSectionName = (string) ($this->studentClassModel->getClassSectionNameByStudentId($sid, $selectedYear) ?? '');
$students[$i]['class_section_name'] = $classSectionName;
$students[$i]['enrollment_status'] = $enrollmentStatusByStudentId[$sid] ?? '';
} else {
// Keep keys consistent even if id missing
$students[$i]['class_section_name'] = '';
$students[$i]['enrollment_status'] = '';
}
$studentYear = trim((string) ($row['school_year'] ?? ''));