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

<?= $this->section('content') ?>
<section class="card stack-md">
    <div class="section-head">
        <div>
            <h3>Clientes</h3>
            <p>Empresas e instalaciones a las que damos servicio.</p>
        </div>
        <a class="btn btn-primary" href="<?= site_url('clients/create') ?>">Nuevo cliente</a>
    </div>

    <?php if ($clients === []): ?>
        <p class="muted">Aún no hay clientes capturados.</p>
    <?php else: ?>
        <div class="table-wrap">
            <table>
                <thead>
                    <tr><th>Nombre</th><th>Contrato</th><th>Contacto</th><th>Teléfono</th><th></th></tr>
                </thead>
                <tbody>
                <?php foreach ($clients as $c): ?>
                    <tr>
                        <td><strong><?= esc($c['nombre']) ?></strong></td>
                        <td><?= esc($c['contrato'] ?? '') ?></td>
                        <td><?= esc($c['contacto_nombre'] ?? '') ?></td>
                        <td><?= esc($c['contacto_telefono'] ?? '') ?></td>
                        <td>
                            <a href="<?= site_url('clients/' . $c['id'] . '/edit') ?>">Editar</a>
                        </td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    <?php endif; ?>
</section>
<?= $this->endSection() ?>
