fix enrollment for the new school-year
Tests / PHPUnit (push) Successful in 1m26s

This commit is contained in:
root
2026-08-07 23:43:31 -04:00
parent b6f3b14e7b
commit 1ef2800f12
66 changed files with 8997 additions and 498 deletions
+29 -4
View File
@@ -59,6 +59,31 @@ if (!function_exists('parseDbDateTime')) {
}
}
}
if (!function_exists('formatCalendarDateOnly')) {
function formatCalendarDateOnly($raw): ?string
{
if (!$raw) return null;
if ($raw instanceof DateTimeInterface) {
return $raw->format('m-d-Y');
}
$s = trim((string)$raw);
if ($s === '' || preg_match('/^0{4}-0{2}-0{2}/', $s)) return null;
if (preg_match('/^(\d{4})-(\d{2})-(\d{2})/', $s, $m)) {
return $m[2] . '-' . $m[3] . '-' . $m[1];
}
if (preg_match('/^(\d{1,2})[-\/](\d{1,2})[-\/](\d{4})/', $s, $m)) {
return sprintf('%02d-%02d-%04d', (int)$m[1], (int)$m[2], (int)$m[3]);
}
$ts = strtotime($s);
return $ts === false ? null : date('m-d-Y', $ts);
}
}
?>
<div class="container my-5">
@@ -71,14 +96,14 @@ if (!function_exists('parseDbDateTime')) {
<!-- Display Payment Notice / Deadline -->
<?php
$displayTz = user_timezone();
$deadline = parseDbDateTime($dueDate, 'UTC', $displayTz); // format either DATE or DATETIME safely
$deadlineDisplay = formatCalendarDateOnly($dueDate);
?>
<div class="alert alert-info mb-3 d-inline-block" style="display: inline-block; width: auto; padding: 10px;">
<ul class="mb-0">
<li>
This website release version does not have an option to pay your invoice online.
All payments this school year will be made in person on first day of school
(<strong><?= esc($deadline ? $deadline->format('m-d-Y') : 'TBD') ?></strong>).
(<strong><?= esc($deadlineDisplay ?: 'TBD') ?></strong>).
</li>
<li>
Cash, checks and debit/credit cards are all accepted forms of payment. However, if you elect to pay in
@@ -109,7 +134,7 @@ $deadline = parseDbDateTime($dueDate, 'UTC', $displayTz); // format either DATE
<?php foreach ($invoices as $index => $invoice): ?>
<?php
$issueDt = parseDbDateTime($invoice['issue_date'] ?? null, 'UTC', $displayTz); // assume stored UTC
$dueDt = parseDbDateTime($invoice['due_date'] ?? null, 'UTC', $displayTz, '12:00:00'); // if date-only, set noon
$dueDateDisplay = formatCalendarDateOnly($invoice['due_date'] ?? null);
$lastPay = parseDbDateTime($invoice['last_payment_date'] ?? null, 'UTC', $displayTz);
?>
@@ -117,7 +142,7 @@ $deadline = parseDbDateTime($dueDate, 'UTC', $displayTz); // format either DATE
<td><?= (int)$index + 1 ?></td>
<td><?= esc($invoice['invoice_number']) ?></td>
<td><?= $issueDt ? esc($issueDt->format('m-d-Y h:i A')) : '—' ?></td>
<td><?= $dueDt ? esc($dueDt->format('m-d-Y')) : '—' ?></td>
<td><?= $dueDateDisplay ? esc($dueDateDisplay) : '—' ?></td>
<td><?= esc($invoice['description'] ?? '') ?: '—' ?></td>
<td>$<?= number_format((float)($invoice['balance'] ?? 0), 2) ?></td>
<td>$<?= number_format((float)($invoice['last_paid_amount'] ?? 0), 2) ?></td>