fix is_new issue with enrollment fixes
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 48s
Tests / PHPUnit (push) Failing after 1m22s

This commit is contained in:
root
2026-08-20 19:57:25 -04:00
parent 127098b87c
commit 889c037660
29 changed files with 77306 additions and 293 deletions
+11 -3
View File
@@ -542,7 +542,7 @@ class StudentController extends BaseController
// Retrieve students with an enrollment in the selected year (any status)
$students = $this->studentModel
->select('students.id, students.firstname, students.lastname, students.registration_date, students.is_new, students.age, students.parent_id, students.registration_grade')
->select('students.id, students.firstname, students.lastname, students.registration_date, students.age, students.parent_id, students.registration_grade')
->join('enrollments e', 'e.student_id = students.id', 'inner')
->where('e.school_year', $selectedYear)
->groupBy('students.id')
@@ -552,11 +552,13 @@ class StudentController extends BaseController
// Fallback: if none found (data inconsistency), include students even without an enrollment row
if (empty($students)) {
$students = $this->studentModel
->select('students.id, students.firstname, students.lastname, students.registration_date, students.is_new, students.age, students.parent_id, students.registration_grade')
->select('students.id, students.firstname, students.lastname, students.registration_date, students.age, students.parent_id, students.registration_grade')
->orderBy('students.lastname', 'ASC')
->findAll();
}
service('studentYearStatus')->attachToStudents($students, $selectedYear);
$studentData = [];
foreach ($students as $student) {
$sectionNames = $this->studentClassModel->getClassSectionsByStudentIdWithFlags((int)$student['id'], $selectedYear, true);
@@ -2608,7 +2610,6 @@ class StudentController extends BaseController
'school_year' => $in['school_year'] ?: null,
'rfid_tag' => $in['rfid_tag'] ?: null,
'semester' => $in['semester'] ?: null,
'is_new' => (int) ($in['is_new'] === '1'),
];
// Normalize health lists (server-side safety)
@@ -2631,6 +2632,13 @@ class StudentController extends BaseController
->with('errors', $this->studentModel->errors() ?: []);
}
$statusYear = $in['school_year'] !== ''
? $in['school_year']
: (string) ($this->currentSchoolYearName((string) ($this->schoolYear ?? '')) ?: '');
if ($statusYear !== '') {
service('studentYearStatus')->upsert($id, $statusYear, $in['is_new'] === '1');
}
// Only sync health lists when user actually changed them (touched=1)
// Fallback: if no touch flag but a non-empty value was explicitly posted, also sync.
$medTouched = ($in['medical_touched'] === '1');