update event charge at the invoice

This commit is contained in:
root
2026-04-13 01:38:40 -04:00
parent 4e2d12e524
commit 821e9cdc81
11 changed files with 537 additions and 32 deletions
+49
View File
@@ -143,12 +143,61 @@ $deadline = parseDbDateTime($dueDate, 'UTC', $displayTz); // format either DATE
</tbody>
</table>
</div>
<?php if (!empty($invoiceEventCharges)): ?>
<?php foreach ($invoices as $invoice): ?>
<?php $charges = $invoiceEventCharges[(int)($invoice['id'] ?? 0)] ?? []; ?>
<?php if (empty($charges)): ?>
<?php continue; ?>
<?php endif; ?>
<div class="card mb-3 shadow-sm">
<div class="card-header">
<strong>Event charges for Invoice #<?= esc($invoice['invoice_number'] ?? '#'.$invoice['id']) ?></strong>
</div>
<div class="card-body p-0">
<div class="table-responsive mb-0">
<table class="table table-sm table-bordered mb-0">
<thead class="table-light">
<tr>
<th>Event</th>
<th>Student</th>
<th>Fee</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php foreach ($charges as $charge): ?>
<?php
$studentName = trim(($charge['student_firstname'] ?? '') . ' ' . ($charge['student_lastname'] ?? ''));
$eventName = $charge['event_name'] ?? '—';
$paid = !empty($charge['event_paid']) || ((float)($charge['charged'] ?? 0) <= 0);
$badgeClass = $paid ? 'success' : 'danger';
?>
<tr>
<td><?= esc($eventName) ?></td>
<td><?= esc($studentName ?: '—') ?></td>
<td>$<?= number_format((float)($charge['event_amount'] ?? 0), 2) ?></td>
<td>
<span class="badge bg-<?= $badgeClass ?>">
<?= $paid ? 'Paid' : 'Unpaid' ?>
</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
<?php else: ?>
<div class="alert alert-info mb-3 d-inline-block">
No invoice found for the selected school year.
</div>
<?php endif; ?>
<?php $invoiceEventCharges = $invoiceEventCharges ?? []; ?>
<?= $this->endSection() ?>
<?= $this->section('scripts') ?>