<?= $this->extend('admin/layouts/main') ?>
<?= $this->section('content') ?>

<p class="text-muted mb-3">Platform payment ledger — subscription charges collected from hotels, via Hubtel or recorded manually.</p>

<div class="card">
    <div class="table-responsive">
        <table class="table mb-0 align-middle">
            <thead>
            <tr><th>Date</th><th>Hotel</th><th>Amount</th><th>Type</th><th>Method</th><th>Status</th><th>Reference</th></tr>
            </thead>
            <tbody>
            <?php if (empty($transactions)): ?>
                <tr><td colspan="7" class="text-center text-muted py-4">No transactions yet.</td></tr>
            <?php endif; ?>
            <?php foreach ($transactions as $tx):
                $badge = (new \Config\Lookups())->transactionStatuses[$tx->status]['badge'] ?? 'secondary'; ?>
                <tr>
                    <td class="text-muted small"><?= esc(date('d M Y, g:i a', strtotime($tx->created_at))) ?></td>
                    <td><a href="<?= site_url('admin/tenants/' . $tx->tenant_id) ?>" class="text-decoration-none"><?= esc($tx->hotel_name) ?></a></td>
                    <td><?= format_money($tx->amount) ?></td>
                    <td class="text-muted"><?= esc(ucfirst($tx->type)) ?></td>
                    <td class="text-muted"><?= esc($tx->method ?: '—') ?></td>
                    <td><span class="badge bg-<?= $badge ?>"><?= esc(ucfirst($tx->status)) ?></span></td>
                    <td class="text-muted small"><?= esc($tx->reference ?: ($tx->client_reference ?: '—')) ?></td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</div>

<?= $this->endSection() ?>
