<?php
$page = isset($_GET['p']) ? (int)$_GET['p'] : 1;
$limit = 10;
$offset = ($page - 1) * $limit;
$withdrawals = $pdo->query("SELECT * FROM withdrawal_requests WHERE withdrawal_status = 'Accepted' ORDER BY accepted_at DESC LIMIT $limit OFFSET $offset")->fetchAll();
?>
<div class="glass-card rounded-2xl border border-slate-800 bg-slate-950/50 p-6">
    <h3 class="mb-4 font-bold uppercase text-xs text-slate-400">Accepted Withdrawals</h3>
    <table class="w-full text-left">
        <thead><tr class="text-[10px] text-slate-500 uppercase"><th>User</th><th>Amount</th><th>Method</th><th>Date</th></tr></thead>
        <tbody>
            <?php foreach($withdrawals as $w): ?>
            <tr class="border-t border-slate-800 text-xs">
                <td class="p-3"><?=$w['user_name']?></td>
                <td class="p-3 text-rose-400 font-mono">$<?=$w['withdrawal_amount']?></td>
                <td class="p-3"><?=$w['withdrawal_method']?></td>
                <td class="p-3"><?=date('M d, Y', strtotime($w['accepted_at']))?></td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
    </div>