<?= $this->extend('templates/baseAdmin') ?>

<?= $this->section('content') ?>

<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/css/bootstrap.min.css"> -->
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.12.1/js/dataTables.bootstrap5.min.js"></script>


<div class="card">
    <div class="card-body">

        <table id="table-solicitudes" class="table table-bordered table-striped">
            <thead>
                <th>Nombre</th>
                <th>Email</th>
                <th>Status</th>
                <th>Revisar</th>
            </thead>
            <tbody>

                <?php foreach ($solicitudes as $solicitud) : ?>
                    <tr class="<?= $solicitud['status'] == 2 ? 'table-danger' : '' ?>">
                        <td><?= $solicitud['nombre'] . ' ' . $solicitud['apaterno'] . ' ' . $solicitud['amaterno'] ?></td>
                        <td><?= $solicitud['email'] ?></td>
                        <td><?= $solicitud['status'] == 0 ? 'Por aprobar' : 'Rechazada' ?></td>
                        <td>
                            <a href="<?= route_to('admin_solicitud_revisar', $solicitud['id']) ?>" class="btn btn-info ">
                                <i class="nav-icon fas fa-user-check"></i>
                            </a>
                        </td>
                    </tr>
                <?php endforeach ?>


            </tbody>
        </table>

    </div>
</div>

<script>
    document.addEventListener('DOMContentLoaded', function() {
        let table = new DataTable('#table-solicitudes', {
            'searching': true,
            'ordering': true,
            'language': {
                "decimal": "",
                "emptyTable": "No hay informaciĆ³n",
                "info": "Mostrando _START_ a _END_ de _TOTAL_ registros",
                "infoEmpty": "Mostrando 0 to 0 of 0 registros",
                "infoFiltered": "(Filtrado de _MAX_ total registros)",
                "infoPostFix": "",
                "thousands": ",",
                "lengthMenu": "Mostrar _MENU_ registros",
                "loadingRecords": "Cargando...",
                "processing": "Procesando...",
                "search": "Buscar:",
                "zeroRecords": "No se encontraron resultados",
                "paginate": {
                    "first": "Primero",
                    "last": "Ultimo",
                    "next": "Siguiente",
                    "previous": "Anterior"
                }
            },
            'order': [],
        });
    });
</script>

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