<?php
    /**
     * @var \App\View\AppView $this
     * @var Icing\Model\Entity\Permission[]|\Cake\Collection\CollectionInterface $permissions
     * @var Icing\Model\Entity\Permission $newPermission
     */

    $this->assign('title', 'Permissions');

    $this->Breadcrumbs->prepend('User Groups', ['controller' => 'UserGroups', 'action' => 'index']);
    $this->Breadcrumbs->prepend('Users', ['controller' => 'Users', 'action' => 'index']);

    $this->PageActions->group('top-right')
        ->link(
            '<i class="fa-solid fa-users fa-fw"></i> User Groups',
            ['controller' => 'UserGroups', 'action' => 'index'],
            ['class' => 'btn btn-primary']
        )
        ->link(
            '<i class="fa-solid fa-user-lock fa-fw"></i> Manage Roles',
            ['controller' => 'Roles', 'action' => 'index'],
            ['class' => 'btn btn-primary'],
        );
?>

<div class="card">
    <div class="card-header">
        <?= $this->element('Icing.quick_search') ?>
    </div>

    <div class="table-responsive">
        <table class="table table-sm table-hover m-0">
            <thead class="thead-light table-nowrap">
            <tr>
                <th><?= $this->Paginator->sort('id', 'Name') ?></th>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($permissions as $permission): ?>
                <tr
                    data-fetch="modal"
                    data-url="<?= $this->Url->build(['action' => 'edit', $permission->id]) ?>"
                >
                    <td><?= h($permission->id) ?></td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>

    <div class="card-footer">
        <?= $this->element('Icing.pagination') ?>
    </div>
</div>

<?php
    $this->PageActions->group('bottom-right')
        ->link(
            '<i class="fa fa-user-plus fa-fw"></i> New Permission',
            ['action' => 'add'],
            ['class' => 'btn btn-success', 'data-fetch' => 'modal'],
        );
?>

