<?php $title = 'Payment Requests'; ?>
<div class="d-sm-flex align-items-center justify-content-between mb-4">
    <h1 class="h3 mb-0 text-white font-weight-bold"><i class="fas fa-link mr-2"></i>Payment Requests</h1>
    <a href="<?= $baseUrl ?>" class="glass-btn"><i class="fas fa-arrow-left mr-1"></i>Dashboard</a>
</div>
<div class="glass-card">
    <div class="glass-table">
        <table class="table table-sm">
            <thead><tr><th>#</th><th>User</th><th>Email</th><th>Amount</th><th>Due Date</th><th>Gateway</th><th>Status</th><th>Action</th></tr></thead>
            <tbody>
                <?php foreach ($requests as $r): ?>
                <tr>
                    <td><?= $r->id ?></td>
                    <td><?= htmlspecialchars($r->name ?? '') ?></td>
                    <td><?= htmlspecialchars($r->email ?? '') ?></td>
                    <td>GHS <?= number_format($r->amount,2) ?></td>
                    <td><?= htmlspecialchars($r->due_date ?? '') ?></td>
                    <td><?= htmlspecialchars($r->gateway ?? '') ?></td>
                    <td><?= htmlspecialchars($r->status) ?></td>
                    <td>
                        <?php if ($r->status === 'pending'): ?>
                        <form method="POST" action="<?= $baseUrl ?>/payments/requests/<?= $r->id ?>/resend" style="display:inline">
                            <button class="glass-btn" onclick="return confirm('Resend payment link?')">Resend</button>
                        </form>
                        <?php else: ?>
                        -
                        <?php endif; ?>
                    </td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</div>
