38960-vm/includes/pages/billing.php
2026-03-04 04:42:54 +00:00

62 lines
3.1 KiB
PHP

<?php
$bills_sql = "
SELECT b.*, p.name as patient_name
FROM bills b
JOIN patients p ON b.patient_id = p.id
ORDER BY b.created_at DESC";
$bills = $db->query($bills_sql)->fetchAll();
?>
<div class="card shadow-sm">
<div class="card-header py-3 d-flex justify-content-between align-items-center">
<h5 class="mb-0 fw-bold"><i class="bi bi-receipt me-2 text-primary"></i> <?php echo __('billing'); ?></h5>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead>
<tr>
<th>ID</th>
<th><?php echo __('date'); ?></th>
<th><?php echo __('patient'); ?></th>
<th><?php echo __('total'); ?></th>
<th><?php echo __('insurance_covered'); ?></th>
<th><?php echo __('patient_payable'); ?></th>
<th><?php echo __('status'); ?></th>
<th><?php echo __('actions'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($bills as $b): ?>
<tr>
<td>#<?php echo $b['id']; ?></td>
<td><?php echo date('Y-m-d H:i', strtotime($b['created_at'])); ?></td>
<td><?php echo htmlspecialchars($b['patient_name']); ?></td>
<td>$<?php echo number_format($b['total_amount'], 2); ?></td>
<td class="text-primary">$<?php echo number_format($b['insurance_covered'], 2); ?></td>
<td class="fw-bold">$<?php echo number_format($b['patient_payable'], 2); ?></td>
<td>
<span class="badge <?php echo $b['status'] === 'Paid' ? 'bg-success' : 'bg-warning'; ?>">
<?php echo __($b['status']); ?>
</span>
</td>
<td>
<?php if ($b['status'] === 'Pending'): ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?section=billing" method="POST" class="d-inline">
<input type="hidden" name="action" value="mark_paid">
<input type="hidden" name="bill_id" value="<?php echo $b['id']; ?>">
<button type="submit" class="btn btn-sm btn-success">
<i class="bi bi-check-circle"></i> <?php echo __('mark_as_paid'); ?>
</button>
</form>
<?php endif; ?>
</td>
</tr>
<?php endforeach; if (empty($bills)): ?>
<tr><td colspan="8" class="text-center py-4 text-muted">No bills found.</td></tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>