0,'total_amount'=>0,'paid_amount'=>0,'balance'=>0]; $canViewInvoices = !empty($f['can_view_invoices']); $selectedStudentId = (int)($f['selected_student_id'] ?? 0); $scoreDefaultStudentId = $selectedStudentId > 0 ? $selectedStudentId : (int)($f['students'][0]['id'] ?? 0); $displayValue = static function ($value, string $fallback = 'Not provided'): string { if ($value === null || trim((string)$value) === '') { return $fallback; } return (string)$value; }; $formatDate = static function ($value, bool $includeTime = false) use ($displayValue): string { if ($value === null || trim((string)$value) === '') { return 'Not provided'; } try { return $includeTime ? local_datetime((string)$value, 'm-d-Y g:i A') : (new \DateTime((string)$value))->format('m-d-Y'); } catch (\Throwable $e) { return $displayValue($value); } }; $formatScore = static function ($value): string { if ($value === null || $value === '' || !is_numeric($value)) { return '—'; } return rtrim(rtrim(number_format((float)$value, 2, '.', ''), '0'), '.'); }; // Title: prefer provided household_name unless it's generic like "Family of User 53" or empty. $titleRaw = trim((string)($f['household_name'] ?? '')); $title = $titleRaw; if ($title === '' || preg_match('/^\s*Family\s+of\s+User\s*\d+\s*$/i', $title)) { // Derive from primary guardian last name, else first guardian's last name $lastName = ''; $primary = null; foreach (($f['guardians'] ?? []) as $g) { if (!empty($g['is_primary'])) { $primary = $g; break; } } $pick = $primary ?: (($f['guardians'][0] ?? null) ?: null); if ($pick) { $ln = trim((string)($pick['lastname'] ?? '')); if ($ln !== '') $lastName = $ln; } $title = $lastName !== '' ? ('Family of ' . $lastName) : 'Family'; } $returnUrl = trim((string)service('request')->getServer('HTTP_REFERER')); if ($returnUrl === '') { $returnUrl = site_url('family'); } ?>
| School Year | Midterm S1 | Midterm Comment S1 | PTAP S1 | PTAP Comment S1 | Attendance S1 | Attendance Comment S1 | Final S2 | Final Comment S2 | PTAP S2 | PTAP Comment S2 | Attendance S2 | Attendance Comment S2 | Year Score |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| = esc($history['school_year'] ?? '—') ?> | = esc($formatScore($history['midterm_s1'] ?? null)) ?> | = esc($displayValue($history['midterm_comment_s1'] ?? null, '—')) ?> | = esc($formatScore($history['ptap_s1'] ?? null)) ?> | = esc($displayValue($history['ptap_comment_s1'] ?? null, '—')) ?> | = esc($formatScore($history['attendance_s1'] ?? null)) ?> | = esc($displayValue($history['attendance_comment_s1'] ?? null, '—')) ?> | = esc($formatScore($history['final_s2'] ?? null)) ?> | = esc($displayValue($history['final_comment_s2'] ?? null, '—')) ?> | = esc($formatScore($history['ptap_s2'] ?? null)) ?> | = esc($displayValue($history['ptap_comment_s2'] ?? null, '—')) ?> | = esc($formatScore($history['attendance_s2'] ?? null)) ?> | = esc($displayValue($history['attendance_comment_s2'] ?? null, '—')) ?> | = esc($formatScore($history['year_score'] ?? null)) ?> |
| Guardian | Contact | Address |
|---|---|---|
|
Relation: = esc($relLabel) ?>
|
= $gEmail !== '' ? ('' . esc($gEmail) . '') : '—' ?>
= !empty($g['cellphone']) ? (''.esc($g['cellphone']).'') : '—' ?>
|
trim((string)$x) !== ''); ?> = esc(implode(', ', $addrParts) ?: '—') ?> |
| Parent | Contact Name | Relation | Phone | Updated | |
|---|---|---|---|---|---|
| = esc($pl ?: ('Parent #'.$pid)) ?> | = esc($ec['emergency_contact_name'] ?? '') ?> | = esc($ec['relation'] ?? '') ?> | = $ph !== '' ? (''.esc($ph).'') : '—' ?> | = $em !== '' ? (''.esc($em).'') : '—' ?> | = esc($ud ? local_date($ud, 'm-d-Y') : '—') ?> |
| Parent | # | Status | Total | Paid | Balance | Issued | Due |
|---|---|---|---|---|---|---|---|
| = esc($iv['parent_name'] ?? ('Parent #' . (int)($iv['parent_id'] ?? 0))) ?> | = esc($iv['invoice_number']) ?> | = esc($iv['status']) ?> | $= number_format((float)($iv['total_amount'] ?? 0), 2) ?> | $= number_format((float)($iv['paid_amount'] ?? 0), 2) ?> | $= number_format((float)($iv['balance'] ?? 0), 2) ?> | = esc(!empty($iv['issue_date']) ? local_date($iv['issue_date'], 'm-d-Y') : '') ?> | = esc(!empty($iv['due_date']) ? local_date($iv['due_date'], 'm-d-Y') : '—') ?> |
| Parent | Invoice | Amount | Invoice Balance | Method | Date | Payment Status | Invoice Status |
|---|---|---|---|---|---|---|---|
| = esc($p['parent_name'] ?? ('Parent #' . (int)($p['parent_id'] ?? 0))) ?> | $= number_format((float)($p['paid_amount'] ?? 0), 2) ?> | $= number_format((float)($p['invoice_current_balance'] ?? 0), 2) ?> | = esc($p['payment_method'] ?? '') ?> | = esc(!empty($p['payment_date']) ? local_date($p['payment_date'], 'm-d-Y') : '') ?> | = esc($p['payment_status'] ?? '') ?> | = esc($p['invoice_status'] ?? '') ?> |