fix enrollment logic, add financial aid, fix class distribution
Tests / PHPUnit (push) Failing after 1m6s

This commit is contained in:
root
2026-08-15 15:07:16 -04:00
parent c12bb59372
commit 4603d9ced2
95 changed files with 6892 additions and 1295 deletions
@@ -0,0 +1,84 @@
<?php
namespace App\Controllers\View;
use App\Controllers\BaseController;
use App\Models\ConfigurationModel;
use App\Models\FinancialAidRequestModel;
use App\Models\StudentModel;
class ParentFinancialAidController extends BaseController
{
public function index()
{
$parentId = (int) session()->get('user_id');
if ($parentId <= 0) {
return redirect()->to('/login');
}
$schoolYear = (string) ((new ConfigurationModel())->getConfig('school_year') ?? '');
$model = new FinancialAidRequestModel();
$requests = $model
->where('parent_id', $parentId)
->where('school_year', $schoolYear)
->orderBy('id', 'DESC')
->findAll();
$students = (new StudentModel())
->where('parent_id', $parentId)
->orderBy('lastname', 'ASC')
->orderBy('firstname', 'ASC')
->findAll();
return view('parent/financial_aid', [
'schoolYear' => $schoolYear,
'students' => $students,
'requests' => $requests,
'openRequest' => $model->openRequestForParent($parentId, $schoolYear),
]);
}
public function submit()
{
$parentId = (int) session()->get('user_id');
if ($parentId <= 0) {
return redirect()->to('/login');
}
$schoolYear = (string) ((new ConfigurationModel())->getConfig('school_year') ?? '');
$model = new FinancialAidRequestModel();
if ($model->openRequestForParent($parentId, $schoolYear) !== null) {
return redirect()->back()->with('error', 'You already have an open financial aid request for this school year.');
}
$studentIds = array_values(array_unique(array_filter(array_map('intval', (array) $this->request->getPost('student_ids')))));
$linkedIds = array_map('intval', array_column(
(new StudentModel())->select('id')->where('parent_id', $parentId)->findAll(),
'id'
));
$studentIds = array_values(array_intersect($studentIds, $linkedIds));
if ($studentIds === []) {
return redirect()->back()->withInput()->with('error', 'Select at least one of your students.');
}
$needStatement = trim((string) $this->request->getPost('need_statement'));
if ($needStatement === '') {
return redirect()->back()->withInput()->with('error', 'Please describe why you are requesting financial aid.');
}
$householdSize = (int) $this->request->getPost('household_size');
$requestedAmount = trim((string) $this->request->getPost('requested_amount'));
$model->insert([
'parent_id' => $parentId,
'school_year' => $schoolYear,
'student_ids_json' => json_encode($studentIds),
'household_size' => $householdSize > 0 ? $householdSize : null,
'need_statement' => $needStatement,
'requested_amount' => $requestedAmount !== '' ? (float) $requestedAmount : null,
'status' => 'submitted',
]);
return redirect()->to('/parent/financial-aid')->with('success', 'Your financial aid request was submitted.');
}
}