fix is_active student flag and apply it in all pages
This commit is contained in:
@@ -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'] ?? ''));
|
||||
|
||||
Reference in New Issue
Block a user