fix parent pages to adopt the school year logic
Tests / PHPUnit (push) Successful in 1m20s

This commit is contained in:
root
2026-07-17 00:02:53 -04:00
parent a5517b516a
commit 539d0eb220
12 changed files with 258 additions and 51 deletions
+19 -3
View File
@@ -1064,6 +1064,10 @@ class ParentController extends BaseController
$schoolIdService = new SchoolIdService();
$parentId = session()->get('user_id');
$schoolYearContext = $this->resolveSchoolYearContext();
$this->assertSchoolYearWritable($schoolYearContext);
$selectedSchoolYear = $schoolYearContext->yearName();
$this->schoolYear = $selectedSchoolYear;
if (!$this->lastDayOfRegistration || !strtotime($this->lastDayOfRegistration)) {
throw new \Exception('Invalid enrollment deadline date.');
@@ -1270,7 +1274,9 @@ class ParentController extends BaseController
private function getRegistrationData(int $parentId): array
{
$enrollments = $this->getEnrollmentsByParent($parentId, $this->schoolYear);
$schoolYearContext = $this->resolveSchoolYearContext();
$selectedSchoolYear = $schoolYearContext->yearName();
$enrollments = $this->getEnrollmentsByParent($parentId, $selectedSchoolYear);
$enrollmentMap = [];
if (!empty($enrollments)) {
@@ -1306,6 +1312,8 @@ class ParentController extends BaseController
'maxChilds' => $this->maxChilds,
'maxEmergency' => $this->maxEmergency,
'enrollments' => $enrollments,
'selectedYear' => $selectedSchoolYear,
'isEditable' => ! $schoolYearContext->isReadonly(),
];
}
@@ -1636,6 +1644,9 @@ $existing = $this->studentModel
public function editEmergencyContact($id = null)
{
$schoolYearContext = $this->resolveSchoolYearContext();
$this->assertSchoolYearWritable($schoolYearContext);
if ($id === null) {
$parentId = session()->get('user_id');
$contacts = $this->emergencyContactModel->where('parent_id', $parentId)->findAll();
@@ -1681,8 +1692,8 @@ $existing = $this->studentModel
}
$parentId = session()->get('user_id');
$semester = session()->get('active_semester');
$schoolYear = session()->get('active_school_year');
$semester = $this->semester;
$schoolYear = $schoolYearContext->yearName();
$this->saveEmergencyContact($parentId, $semester, $schoolYear, [
'first_name' => $this->request->getPost('emergency_first_name'),
@@ -1699,6 +1710,9 @@ $existing = $this->studentModel
public function editStudent($id)
{
$schoolYearContext = $this->resolveSchoolYearContext();
$this->assertSchoolYearWritable($schoolYearContext);
$this->schoolYear = $schoolYearContext->yearName();
$schoolIdService = new \App\Services\SchoolIdService();
if (strtolower($this->request->getMethod()) !== 'post') {
@@ -1752,6 +1766,8 @@ $existing = $this->studentModel
public function deleteStudent($id)
{
$this->assertSchoolYearWritable($this->resolveSchoolYearContext());
if (strtolower($this->request->getMethod()) !== 'post') {
return redirect()->back()->with('error', 'Invalid request method.');
}