<?php $e=static fn($v)=>htmlspecialchars((string)$v,ENT_QUOTES,'UTF-8'); ?>
<section class="page-header"><div><p class="eyebrow">Billing · Receipt</p><h1><?= $e($receiptNumber??'Receipt') ?></h1><p><?= $e($pageDescription??'') ?></p></div><div class="form-actions"><a class="btn btn-secondary" href="/crm/public/payments/<?= (int)$payment['id'] ?>/receipt/pdf" target="_blank">View / Print PDF</a><a class="btn btn-secondary" href="/crm/public/payments">Payments</a><button class="btn btn-primary" type="button" onclick="window.print()">Print</button></div></section>
<?php if(!empty($message)): ?><div class="alert alert-success"><?= $e($message) ?></div><?php endif; ?><?php if(!empty($error)): ?><div class="alert alert-error"><?= $e($error) ?></div><?php endif; ?>
<section class="card"><div class="card-header"><div><p class="eyebrow">Grow Tool Therapies</p><h2>Payment Receipt</h2></div><strong><?= $e($receiptNumber??'—') ?></strong></div><div class="grid grid-2"><div><strong>Patient</strong><br><?= $e($invoice['first_name'].' '.$invoice['last_name']) ?><br><?= $e($invoice['patient_reference']) ?></div><div><strong>Invoice</strong><br><?= $e($invoice['invoice_number']) ?><br>Payment date: <?= $e($payment['payment_date']) ?></div></div><div class="table-wrap" style="margin-top:1.5rem"><table class="data-table"><tbody><tr><th>Amount received</th><td><strong>KSh <?= number_format((float)$payment['amount'],2) ?></strong></td></tr><tr><th>Method</th><td><?= $e($payment['payment_method']) ?></td></tr><tr><th>Reference</th><td><?= $e($payment['payment_reference']??'—') ?></td></tr><tr><th>Invoice balance after payment</th><td>KSh <?= number_format((float)$invoice['balance'],2) ?></td></tr><tr><th>Status</th><td><?= $e(ucfirst($payment['status']??'posted')) ?></td></tr></tbody></table></div></section>
