fix parent and teacher pages to follow year filter
Tests / PHPUnit (push) Failing after 1m15s

This commit is contained in:
root
2026-07-15 20:03:36 -04:00
parent feb1b29a32
commit 5f27dccd0f
32 changed files with 582 additions and 364 deletions
@@ -58,7 +58,7 @@ class ParentAttendanceReportController extends BaseController
[$sundays, $defaultDate] = $this->computeSundays();
// Load upcoming reports for preview/edit (today and forward within this school year)
$schoolYear = (string) $this->configModel->getConfig('school_year');
$schoolYear = $this->currentSchoolYearName((string) ($this->configModel->getConfig('school_year') ?? ''));
$todayYmd = local_date(utc_now(), 'Y-m-d');
$previewRows = $this->reportModel->builder()
->select('parent_attendance_reports.*, s.firstname, s.lastname')
@@ -141,6 +141,7 @@ class ParentAttendanceReportController extends BaseController
$dismissTime = $post['dismiss_time'] ?? null;
$reasonRaw = $post['reason'] ?? null;
$reason = is_string($reasonRaw) ? trim($reasonRaw) : null;
$schoolYear = $this->currentSchoolYearName((string) ($this->configModel->getConfig('school_year') ?? ''));
// Enforce Sunday-only and future-or-today selection
$todayCheck = new \DateTime('today');
@@ -157,7 +158,7 @@ class ParentAttendanceReportController extends BaseController
}
$validDates = [];
$cap = $this->firstSundayOfJune((string) $this->configModel->getConfig('school_year'));
$cap = $this->firstSundayOfJune($schoolYear);
$lateCutoff = null;
$lateNow = null;
@@ -236,7 +237,6 @@ class ParentAttendanceReportController extends BaseController
// Upper bound already enforced by $validDates building
$semester = (string) $this->configModel->getConfig('semester');
$schoolYear = (string) $this->configModel->getConfig('school_year');
$semesterResolver = new SemesterRangeService($this->configModel);
$inserted = 0;
@@ -493,7 +493,7 @@ class ParentAttendanceReportController extends BaseController
}
// Upper bound: first Sunday of June (school year end)
$schoolYear = (string) $this->configModel->getConfig('school_year');
$schoolYear = $this->currentSchoolYearName((string) ($this->configModel->getConfig('school_year') ?? ''));
$cap = $this->firstSundayOfJune($schoolYear);
$dates = [];
@@ -1458,12 +1458,15 @@ class ParentAttendanceReportController extends BaseController
return $this->response->setJSON(['ok' => true, 'students' => []]);
}
$schoolYear = $this->currentSchoolYearName((string) ($this->configModel->getConfig('school_year') ?? ''));
// Fetch existing submissions for these students on this date
$rows = $this->reportModel->builder()
->select('parent_attendance_reports.student_id, parent_attendance_reports.type, parent_attendance_reports.report_date, s.firstname, s.lastname')
->join('students s', 's.id = parent_attendance_reports.student_id', 'left')
->whereIn('parent_attendance_reports.report_date', $dateValues)
->whereIn('parent_attendance_reports.student_id', $studentIds)
->where('parent_attendance_reports.school_year', $schoolYear)
->get()->getResultArray();
$map = [];