<?php include app()->basePath('app/Views/partials/header.php'); ?>

<section class="panel">
    <p class="eyebrow">Administracao</p>
    <h1>Recibos emitidos</h1>

    <form method="get" action="/admin/invoices" class="filterbar simple">
        <input name="search" placeholder="Pesquisar por numero, aluno, email ou curso" value="<?= e($filters['search']) ?>">
        <button class="button" type="submit">Pesquisar</button>
    </form>

    <div class="table-wrap">
        <table>
            <thead>
                <tr>
                    <th>Numero</th>
                    <th>Cliente</th>
                    <th>Curso</th>
                    <th>Total</th>
                    <th>Emitido</th>
                    <th>Accoes</th>
                </tr>
            </thead>
            <tbody>
                <?php if (!$invoices): ?>
                    <tr><td colspan="6">Nenhum recibo emitido.</td></tr>
                <?php endif; ?>
                <?php foreach ($invoices as $invoice): ?>
                    <tr>
                        <td><strong><?= e($invoice['invoice_number']) ?></strong></td>
                        <td><?= e($invoice['buyer_name']) ?><span class="muted"><?= e($invoice['buyer_email']) ?></span></td>
                        <td><?= e($invoice['course_title']) ?></td>
                        <td><?= e(money_mzn($invoice['total'])) ?></td>
                        <td><?= e(format_date($invoice['issued_at'])) ?></td>
                        <td><a class="mini-button" href="/invoices/show?id=<?= e((string) $invoice['id']) ?>">Ver</a></td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</section>

<?php include app()->basePath('app/Views/partials/footer.php'); ?>
