<?php $pageTitle = 'Payments'; ?>
<div class="mb-4"><p class="text-secondary">Manage student payments and proof of payment</p></div>
<div class="card-cix mb-4">
    <form method="GET" action="<?= base_url('admin/payments') ?>" class="row g-3 align-items-end">
        <div class="col-md-4"><label class="form-label-cix">Search</label><input type="text" name="search" class="form-control-cix" placeholder="Student #, name..." value="<?= e($search ?? '') ?>"></div>
        <div class="col-md-3"><label class="form-label-cix">Status</label><select name="status" class="form-control-cix"><option value="">All</option><?php foreach (['pending','awaiting_proof','submitted','approved','rejected','refunded','cancelled'] as $s): ?><option value="<?= $s ?>" <?= ($status ?? '') === $s ? 'selected' : '' ?>><?= ucfirst($s) ?></option><?php endforeach; ?></select></div>
        <div class="col-md-2"><button type="submit" class="btn-cix btn-cix-primary"><i class="fas fa-search"></i> Filter</button></div>
    </form>
</div>
<div class="card-cix">
    <div class="table-responsive">
        <table class="table-cix"><thead><tr><th>Student</th><th>Package</th><th>Amount</th><th>Status</th><th>Date</th><th>Action</th></tr></thead>
        <tbody><?php if (empty($payments)): ?><tr><td colspan="6" class="text-center text-secondary p-4">No payments</td></tr>
        <?php else: foreach ($payments as $p): ?>
        <tr><td><strong><?= e($p['first_name'] . ' ' . $p['last_name']) ?></strong><br><small class="text-secondary"><?= e($p['student_number']) ?></small></td>
        <td class="text-secondary"><?= e($p['package_name'] ?? '-') ?></td><td style="color:var(--secondary);font-weight:700;">R<?= number_format($p['amount'], 2) ?></td>
        <td><span class="badge-cix badge-<?= $p['status'] ?>"><?= ucfirst($p['status']) ?></span></td><td class="text-secondary small"><?= e($p['created_at']) ?></td>
        <td><a href="<?= base_url('admin/payment/' . $p['id']) ?>" class="btn-cix btn-cix-sm btn-cix-primary"><i class="fas fa-eye"></i> Review</a></td></tr>
        <?php endforeach; endif; ?></tbody></table>
    </div>
</div>
