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
+4 -31
View File
@@ -164,10 +164,7 @@ class ParentController extends BaseController
return redirect()->back()->with('error', 'Parent session not found.');
}
$currentSchoolYear = $this->currentSchoolYearName((string) ($this->schoolYear ?? ''));
// Get selected school year (no semester filter on parent view)
$selectedYear = $this->request->getVar('school_year') ?? $currentSchoolYear;
$selectedYear = $this->currentSchoolYearName((string) ($this->schoolYear ?? ''));
// Build query to retrieve attendance
$builder = $this->db->table('attendance_data');
@@ -180,19 +177,10 @@ class ParentController extends BaseController
$query = $builder->get();
$attendanceResults = $query->getResultArray();
// Get list of available school years
$schoolYears = $this->db->table('attendance_data')
->select('school_year')
->distinct()
->orderBy('school_year', 'DESC')
->get()
->getResultArray();
// If no records found, set a flag to show message in the view
if (empty($attendanceResults)) {
return view('/parent/attendance', [
'attendance' => null,
'schoolYears' => $schoolYears,
'selectedYear' => $selectedYear,
'selectedSemester' => null,
//'error' => 'No attendance records found for the selected school year and semester.'
@@ -202,7 +190,6 @@ class ParentController extends BaseController
// Return view with attendance results
return view('/parent/attendance', [
'attendance' => $attendanceResults,
'schoolYears' => $schoolYears,
'selectedYear' => $selectedYear,
'selectedSemester' => null,
'error' => null
@@ -212,7 +199,6 @@ class ParentController extends BaseController
return view('/parent/attendance', [
'attendance' => null,
'schoolYears' => [],
'selectedYear' => $selectedYear ?? null,
'selectedSemester' => null,
'error' => 'Failed to retrieve attendance data. Please try again later.'
@@ -269,9 +255,9 @@ class ParentController extends BaseController
return redirect()->back()->with('error', 'Configuration error: School year missing.');
}
// Get selected school year from request or fallback
$selectedYear = $this->request->getGet('school_year') ?? $this->schoolYear;
$isEditable = ($selectedYear === $this->schoolYear);
$context = $this->resolveSchoolYearContext();
$selectedYear = $context->yearName();
$isEditable = ! $context->isReadonly();
// Get parent ID from session
$parentId = session()->get('user_id');
@@ -370,22 +356,9 @@ class ParentController extends BaseController
);
}
// Fetch available school years
$schoolYears = $this->db->table('enrollments')
->select('school_year')
->distinct()
->orderBy('school_year', 'DESC')
->get()
->getResultArray();
if (empty($schoolYears)) {
$schoolYears[] = ['school_year' => $this->schoolYear];
}
// Render view
return view('/parent/enroll_classes', [
'students' => $students,
'schoolYears' => $schoolYears,
'selectedYear' => $selectedYear,
'isEditable' => $isEditable,
'withdrawalDeadline' => $this->withdrawalDeadline,