<?= $this->extend('layouts/app') ?>

<?= $this->section('content') ?>
<section class="card stack-md">
    <div class="section-head">
        <div>
            <h3>Reportes</h3>
            <p>Documentos entregables que agrupan una o varias inspecciones firmadas.</p>
        </div>
        <a class="btn btn-primary" href="<?= site_url('reports/create') ?>">Nuevo reporte</a>
    </div>

    <?php if ($reports === []): ?>
        <p class="muted">Aún no hay reportes.</p>
    <?php else: ?>
        <div class="table-wrap">
            <table>
                <thead><tr><th>Folio</th><th>Título</th><th>Cliente</th><th>Status</th><th></th></tr></thead>
                <tbody>
                <?php foreach ($reports as $r): ?>
                    <tr>
                        <td><a href="<?= site_url('reports/' . $r['id']) ?>"><?= esc($r['folio'] ?? '—') ?></a></td>
                        <td><?= esc($r['title']) ?></td>
                        <td><?= esc($r['client_name'] ?? '') ?></td>
                        <td><span class="badge"><?= esc($r['status']) ?></span></td>
                        <td>
                            <a href="<?= site_url('reports/' . $r['id']) ?>">Ver</a> ·
                            <a href="<?= site_url('reports/' . $r['id'] . '/pdf') ?>" target="_blank">PDF</a>
                        </td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    <?php endif; ?>
</section>
<?= $this->endSection() ?>
