<?php
/**
 * @var \App\View\AppView $this
 * @var iterable<\App\Model\Entity\Personal> $personal
 */
?>
<?php $this->assign('title', 'Personal'); ?>

<div class="personal index content">
    <?= $this->Html->link(__('Añadir Personal'), ['action' => 'add'], ['class' => 'button float-right btn btn-info openModal']) ?>
    <div class="contenedor principal">
        <div class="table-responsive">
            <table class="table table-striped mt-3">
                <thead class="bg-info text-white">
                    <tr>
                        <th><?= $this->Paginator->sort('id', 'N°') ?></th>
                        <th><?= $this->Paginator->sort('nombre', 'Nombre') ?></th>
                        <th><?= $this->Paginator->sort('apellido', 'Apellido') ?></th>
                        <th><?= $this->Paginator->sort('cargo', 'Cargo') ?></th>
                        <th><?= $this->Paginator->sort('telefono', 'Teléfono') ?></th>
                        <th><?= $this->Paginator->sort('email', 'Email') ?></th>
                        <th><?= $this->Paginator->sort('porcentaje_pago', 'Porcentaje %') ?></th>
                        <th><?= $this->Paginator->sort('created', 'Creado') ?></th>
                        <th><?= $this->Paginator->sort('modified', 'Modificado') ?></th>
                        <th class="actions text-dark"><?= __('Acciones') ?></th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($personal as $persona): ?>
                    <tr>
                        <td><?= $this->Number->format($persona->id) ?></td>
                        <td><?= h($persona->nombre) ?></td>
                        <td><?= h($persona->apellido) ?></td>
                        <td><?= h($persona->cargo) ?></td>
                        <td><?= h($persona->telefono) ?></td>
                        <td><?= h($persona->email) ?></td>
                        <td><?= h($persona->porcentaje_pago) ?>%</td>
                        <td><?= h($persona->created) ?></td>
                        <td><?= h($persona->modified) ?></td>
                        <td class="actions text-center">
                            <!-- Íconos personalizados para acciones -->
                            <?= $this->Html->link(
                                '<i class="fas fa-eye"></i>',
                                ['action' => 'view', $persona->id],
                                ['escape' => false, 'title' => 'Ver', 'class' => 'btn btn-info btn-sm openModal']
                            ) ?>
                            <?= $this->Html->link(
                                '<i class="fas fa-edit"></i>',
                                ['action' => 'edit', $persona->id],
                                ['escape' => false, 'title' => 'Editar', 'class' => 'btn btn-warning btn-sm openModal']
                            ) ?>
                        </td>
                    </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>

    <!-- Paginación -->
    <div class="paginator">
        <ul class="pagination">
            <?= $this->Paginator->first('<< ' . __('Primero')) ?>
            <?= $this->Paginator->prev('< ' . __('Anterior')) ?>
            <?= $this->Paginator->numbers() ?>
            <?= $this->Paginator->next(__('Siguiente') . ' >') ?>
            <?= $this->Paginator->last(__('Último') . ' >>') ?>
        </ul>
        <p><?= $this->Paginator->counter(__('Página {{page}} de {{pages}}, mostrando {{current}} registro(s) de un total de {{count}}')) ?></p>
    </div>
</div>
