merge prod to main

This commit is contained in:
root
2026-05-16 13:44:12 -04:00
parent 663c0cdbda
commit b32fb853f6
901 changed files with 11241 additions and 1340 deletions
View File
Regular → Executable
View File
View File
+24 -4
View File
@@ -54,6 +54,11 @@
<button class="btn btn-primary" onclick="window.print()">Print Report</button>
<a id="summaryReportLink" href="<?= base_url('financial-report/financialReportSummary') ?>" class="btn btn-info">Display Summary Report</a>
</div>
<?php if (isset($eventFeesTotal)): ?>
<div class="alert alert-info mb-3">
<strong>Event fees total:</strong> $<?= number_format((float)$eventFeesTotal, 2) ?>
</div>
<?php endif; ?>
<div class="table-responsive">
<table id="invoicesTable" class="table table-bordered table-striped align-middle w-100">
<thead>
@@ -95,8 +100,16 @@
$balanceCalc = (float)$totalAmount - (float)$discounted - (float)$paid - (float)$refunded;
if ($balanceCalc < 0) $balanceCalc = 0.0;
$balance = $balanceCalc;
$status = ($balanceCalc === 0.0) ? 'Paid' : 'Unpaid';
$statusClass = ($status === 'Paid') ? 'bg-success' : 'bg-danger';
if ($balanceCalc <= 0.00001) {
$status = 'Paid';
$statusClass = 'bg-success';
} elseif ($paid > 0.00001) {
$status = 'Partially Paid';
$statusClass = 'bg-warning text-dark';
} else {
$status = 'Unpaid';
$statusClass = 'bg-danger';
}
?>
<tr>
<td><?= esc($inv['invoice_number']) ?></td>
@@ -371,8 +384,15 @@
const total = Number(inv.total_amount || 0);
let balance = total - paid - discounted - refunded;
if (!Number.isFinite(balance) || balance < 0) balance = 0;
const status = balance === 0 ? 'Paid' : 'Unpaid';
const statusClass = balance === 0 ? 'bg-success' : 'bg-danger';
let status = 'Unpaid';
let statusClass = 'bg-danger';
if (balance <= 0.00001) {
status = 'Paid';
statusClass = 'bg-success';
} else if (paid > 0.00001) {
status = 'Partially Paid';
statusClass = 'bg-warning text-dark';
}
const tr = document.createElement('tr');
const parentHtml = (inv.parent_id && Number(inv.parent_id) > 0) ?
`<a href="<?= site_url('family') ?>?guardian_id=${encodeURIComponent(inv.parent_id)}" class="text-decoration-none" data-family-guardian-id="${inv.parent_id}">${inv.parent_name||''}</a>` :
+10 -5
View File
@@ -32,6 +32,7 @@
</thead>
<tbody id="summaryBody">
<tr><td>Total Charges</td><td class="text-right" id="sumCharges">$0.00</td></tr>
<tr><td>Event Fees</td><td class="text-right" id="sumEventFees">$0.00</td></tr>
<tr><td>Total Extra Charges</td><td class="text-right" id="sumExtraCharges">$0.00</td></tr>
<tr><td>Total Discounts</td><td class="text-right" id="sumDiscounts">$0.00</td></tr>
<tr><td>Total Refunds</td><td class="text-right" id="sumRefunds">$0.00</td></tr>
@@ -98,6 +99,9 @@ function loadSummary(){
if (!d || d.ok !== true) return;
document.getElementById('summaryPeriod').textContent = 'Report for School Year: ' + (d.schoolYear||'');
document.getElementById('sumCharges').textContent = fmt(d.totalCharges);
if (document.getElementById('sumEventFees')) {
document.getElementById('sumEventFees').textContent = fmt(d.totalEventFees || 0);
}
if (document.getElementById('sumExtraCharges')) {
document.getElementById('sumExtraCharges').textContent = fmt(d.totalExtraCharges || 0);
}
@@ -127,10 +131,10 @@ function renderCharts(d){
const summaryCtx = document.getElementById('summaryChart').getContext('2d');
window._summaryChart = new Chart(summaryCtx, {
type: 'bar',
data: { labels: ['Charges','Paid','Unpaid','Discounts','Refunds','Expenses','Reimbursements','Net'],
data: { labels: ['Charges','Event Fees','Paid','Unpaid','Discounts','Refunds','Expenses','Reimbursements','Net'],
datasets: [{ label:'Amount (USD)', data:[
d.totalCharges||0, d.totalPaid||0, d.totalUnpaid||0, d.totalDiscounts||0, d.totalRefunds||0, d.totalExpenses||0, d.totalReimbursements||0, d.netAmount||0
], backgroundColor: ['#007bff','#28a745','#ffc107','#17a2b8','#ffc107','#dc3545','#6f42c1','#20c997']}] },
d.totalCharges||0, d.totalEventFees||0, d.totalPaid||0, d.totalUnpaid||0, d.totalDiscounts||0, d.totalRefunds||0, d.totalExpenses||0, d.totalReimbursements||0, d.netAmount||0
], backgroundColor: ['#007bff','#6610f2','#28a745','#ffc107','#17a2b8','#ffc107','#dc3545','#6f42c1','#20c997']}] },
options: { responsive:true, scales:{ y:{ beginAtZero:true }}}
});
@@ -177,11 +181,12 @@ document.addEventListener("DOMContentLoaded", function() {
window._summaryChart = new Chart(summaryCtx, {
type: 'bar',
data: {
labels: ['Charges', 'Paid', 'Unpaid', 'Discounts', 'Refunds', 'Expenses', 'Reimbursements', 'Net'],
labels: ['Charges', 'Event Fees', 'Paid', 'Unpaid', 'Discounts', 'Refunds', 'Expenses', 'Reimbursements', 'Net'],
datasets: [{
label: 'Amount (USD)',
data: [
<?= (float)$totalCharges ?>,
<?= (float)($totalEventFees ?? 0) ?>,
<?= (float)$totalPaid ?>,
<?= (float)$totalUnpaid ?>,
<?= (float)$totalDiscounts ?>,
@@ -191,7 +196,7 @@ document.addEventListener("DOMContentLoaded", function() {
<?= (float)$netAmount ?>
],
backgroundColor: [
'#007bff', '#28a745', '#ffc107', '#17a2b8', '#ffc107', '#dc3545', '#6f42c1', '#20c997'
'#007bff', '#6610f2', '#28a745', '#ffc107', '#17a2b8', '#ffc107', '#dc3545', '#6f42c1', '#20c997'
]
}]
},
Regular → Executable
View File
View File
View File
View File
+18 -15
View File
@@ -1,7 +1,7 @@
<?php
/** @var string $school_year */
/** @var array<string> $schoolYears */
/** @var array<int,array{parent_id:int,parent_name:string,email:string,total_invoice:float,total_balance:float,total_discount:float,total_paid:float,remaining_installments:int,installment_amount:float,type:string,has_installment?:int,next_installment?:string}> $rows */
/** @var array<int,array{parent_id:int,parent_name:string,email:string,total_invoice:float,total_balance:float,total_discount:float,total_paid:float,payment_count:int,remaining_installments:int,installment_amount:float,type:string,has_installment?:int,next_installment?:string}> $rows */
?>
<?= $this->extend('layout/management_layout') ?>
@@ -15,8 +15,6 @@
.table thead th { background: var(--mgmt-thead-bg, #f1f3f5); }
.actions { white-space: nowrap; }
.actions .btn { --bs-btn-padding-y: .25rem; --bs-btn-padding-x: .5rem; }
.email-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 576px){ .email-cell { max-width: 180px; } }
/* Disable sticky header for this table to avoid overlap */
table.no-mgmt-sticky thead th { position: static !important; }
</style>
@@ -49,13 +47,15 @@
<button class="btn btn-primary btn-sm" type="submit">Send Reminders (All)</button>
</form>
</div>
<?php $sumEventFees = 0.0; ?>
<div class="table-responsive">
<table id="unpaidTable" class="table table-sm align-middle no-mgmt-sticky" data-no-mgmt-sticky>
<thead>
<tr>
<th>Parent</th>
<th>Email</th>
<th class="text-center">Nbr of Installements</th>
<th>Type</th>
<th class="text-end">Event Fees</th>
<th class="text-end">Invoice Amount</th>
<th class="text-end">Applied Discount</th>
<th class="text-end">Paid Amount</th>
@@ -69,7 +69,7 @@
</thead>
<tbody>
<?php if (empty($rows)): ?>
<tr><td colspan="12" class="text-center text-muted py-4">No parents with outstanding balance.</td></tr>
<tr><td colspan="13" class="text-center text-muted py-4">No parents with outstanding balance.</td></tr>
<?php else: ?>
<?php
$sumInvoice = 0.0;
@@ -86,20 +86,22 @@
</a>
<small class="text-muted">#<?= (int)$r['parent_id'] ?></small>
</td>
<td class="email-cell"><a href="mailto:<?= esc($r['email']) ?>"><?= esc($r['email']) ?></a></td>
<td class="text-center"><?= (int)($r['payment_count'] ?? 0) ?></td>
<td>
<?php if (($r['type'] ?? '') === 'no_payment'): ?>
<span class="badge bg-danger badge-type">no payment</span>
<?php else: ?>
<span class="badge bg-success badge-type">installment</span>
<?php endif; ?>
</td>
<?php $sumInvoice += (float)($r['total_invoice'] ?? 0); ?>
<?php $sumPaid += (float)($r['total_paid'] ?? 0); ?>
<?php if (($r['type'] ?? '') === 'no_payment'): ?>
<span class="badge bg-danger badge-type">no payment</span>
<?php else: ?>
<span class="badge bg-success badge-type">installment</span>
<?php endif; ?>
</td>
<?php $sumInvoice += (float)($r['total_invoice'] ?? 0); ?>
<?php $sumEventFees += (float)($r['event_fees'] ?? 0); ?>
<?php $sumPaid += (float)($r['total_paid'] ?? 0); ?>
<?php $sumDisc += (float)($r['total_discount'] ?? 0); ?>
<?php $sumInstAmt += (float)($r['installment_amount'] ?? 0); ?>
<?php $sumBal += (float)($r['total_balance'] ?? 0); ?>
<td class="text-end">$<?= number_format((float)($r['total_invoice'] ?? 0), 2) ?></td>
<td class="text-end">$<?= number_format((float)($r['event_fees'] ?? 0), 2) ?></td>
<td class="text-end">$<?= number_format((float)($r['total_invoice'] ?? 0), 2) ?></td>
<td class="text-end text-success">-$<?= number_format((float)($r['total_discount'] ?? 0), 2) ?></td>
<td class="text-end">$<?= number_format((float)($r['total_paid'] ?? 0), 2) ?></td>
<td class="text-center"><?= (int)($r['remaining_installments'] ?? 0) ?></td>
@@ -131,6 +133,7 @@
<tfoot>
<tr>
<th colspan="3" class="text-end">Totals:</th>
<th class="text-end">$<?= number_format($sumEventFees, 2) ?></th>
<th class="text-end">$<?= number_format($sumInvoice, 2) ?></th>
<th class="text-end text-success">-$<?= number_format($sumDisc, 2) ?></th>
<th class="text-end">$<?= number_format($sumPaid, 2) ?></th>