fix enrollment, invoice, payment and financila aid
This commit is contained in:
@@ -24,15 +24,8 @@ class ParentFinancialAidController extends BaseController
|
||||
->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),
|
||||
'existingRequest' => $model->requestForParentYear($parentId, $schoolYear),
|
||||
@@ -52,14 +45,27 @@ class ParentFinancialAidController extends BaseController
|
||||
return redirect()->back()->with('error', 'You can submit only one financial aid application per school year.');
|
||||
}
|
||||
|
||||
$studentIds = array_values(array_unique(array_filter(array_map('intval', (array) $this->request->getPost('student_ids')))));
|
||||
$linkedIds = array_map('intval', array_column(
|
||||
$studentIds = 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.');
|
||||
return redirect()->back()->withInput()->with('error', 'No students are linked to your account.');
|
||||
}
|
||||
|
||||
$householdIncomeRaw = trim((string) $this->request->getPost('household_income'));
|
||||
if ($householdIncomeRaw === '' || ! is_numeric($householdIncomeRaw) || (float) $householdIncomeRaw < 0) {
|
||||
return redirect()->back()->withInput()->with('error', 'Enter your household income.');
|
||||
}
|
||||
|
||||
$householdSize = (int) $this->request->getPost('household_size');
|
||||
if ($householdSize < 1) {
|
||||
return redirect()->back()->withInput()->with('error', 'Enter your household size.');
|
||||
}
|
||||
|
||||
$requestedAmountRaw = trim((string) $this->request->getPost('requested_amount'));
|
||||
if ($requestedAmountRaw === '' || ! is_numeric($requestedAmountRaw) || (float) $requestedAmountRaw <= 0) {
|
||||
return redirect()->back()->withInput()->with('error', 'Enter the amount you are requesting.');
|
||||
}
|
||||
|
||||
$needStatement = trim((string) $this->request->getPost('need_statement'));
|
||||
@@ -67,16 +73,14 @@ class ParentFinancialAidController extends BaseController
|
||||
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,
|
||||
'student_ids_json' => json_encode(array_values($studentIds)),
|
||||
'household_size' => $householdSize,
|
||||
'household_income' => round((float) $householdIncomeRaw, 2),
|
||||
'need_statement' => $needStatement,
|
||||
'requested_amount' => $requestedAmount !== '' ? (float) $requestedAmount : null,
|
||||
'requested_amount' => round((float) $requestedAmountRaw, 2),
|
||||
'status' => 'submitted',
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user