fix pages and add distribution system
Tests / PHPUnit (push) Failing after 1m13s

This commit is contained in:
root
2026-07-15 23:03:51 -04:00
parent 7f3b24e47f
commit ba87598d3a
38 changed files with 1362 additions and 658 deletions
+30 -4
View File
@@ -365,13 +365,33 @@ class StudentModel extends Model
$schoolYear = trim((string) $schoolYear);
$studentClassJoin = 'student_class.student_id = students.id';
$enrollmentJoin = 'enrollments.student_id = students.id';
$selectedYearFilter = '';
if ($schoolYear !== '') {
$studentClassJoin .= ' AND student_class.school_year = ' . $this->db->escape($schoolYear);
$enrollmentJoin .= ' AND enrollments.school_year = ' . $this->db->escape($schoolYear);
$escapedSchoolYear = $this->db->escape($schoolYear);
$studentClassJoin .= ' AND student_class.school_year = ' . $escapedSchoolYear;
$enrollmentJoin .= ' AND enrollments.school_year = ' . $escapedSchoolYear;
$selectedYearFilter = "
(
student_class.student_id IS NOT NULL
OR enrollments.student_id IS NOT NULL
OR (
NOT EXISTS (
SELECT 1
FROM student_class sc_history
WHERE sc_history.student_id = students.id
)
AND NOT EXISTS (
SELECT 1
FROM enrollments e_history
WHERE e_history.student_id = students.id
)
)
)
";
}
return $this->select('
$builder = $this->select('
students.*,
student_class.class_section_id,
enrollments.enrollment_status,
@@ -381,7 +401,13 @@ class StudentModel extends Model
')
->join('student_class', $studentClassJoin, 'left')
->join('enrollments', $enrollmentJoin, 'left')
->join('users u', 'u.id = students.parent_id', 'left')
->join('users u', 'u.id = students.parent_id', 'left');
if ($selectedYearFilter !== '') {
$builder->where($selectedYearFilter, null, false);
}
return $builder
// keep your original grouping as-is so behavior doesn't change
->groupBy('students.id, student_class.class_section_id, enrollments.enrollment_status, enrollments.admission_status')
->findAll();