<div class="wide-xl mx-auto">
    <!-- Header @s -->
    <div class="nk-block-head nk-block-head-lg">
        <div class="nk-block-between">
            <div class="nk-block-head-content">
                <h3 class="nk-block-title page-title">Perfiles de Usuario</h3>
                <div class="nk-block-des text-soft">
                    <nav>
                        <ul class="breadcrumb">
                            <li class="breadcrumb-item"><a href="#"><?= APP_NAME ?></a></li>
                            <li class="breadcrumb-item"><a href="#">Configuración</a></li>
                            <li class="breadcrumb-item active">Perfiles de Usuario</li>
                        </ul>
                    </nav>
                </div>
            </div><!-- .nk-block-head-content -->
        </div><!-- .nk-block-between -->
    </div><!-- .nk-block-head -->
    <!-- Header @e -->

    <!-- Body @s -->
    <div class="nk-block nk-block-lg">
        <div class="card">
            <div class="card-inner">
                <!-- @s -->
                <table class="nowrap table" id="table-config-profiles" data-export-title="Acciones"></table>
                <!-- @e -->
            </div>
        </div>
    </div>
    <!-- Body @e -->

</div>

<!-- Modal ACL v2 @s -->
<div class="modal fade" tabindex="-1" aria-labelledby="" id="modal_ACL_v2" data-bs-backdrop="static" data-bs-keyboard="false">
    <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-lg">
        <div class="modal-content">
            <form id="form_ACL_v2">
                <div class="modal-header">
                    <h5 class="modal-title">Nuevo perfil</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <ul class="nav nav-tabs">
                        <li class="nav-item">
                            <a href="#information" class="nav-link active" data-bs-toggle="tab">Información</a>
                        </li>
                        <li class="nav-item">
                            <a href="#acl" class="nav-link" data-bs-toggle="tab">Módulos y Permisos</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="information">
                            <input type="hidden" name="profile_id">
                            <div class="mb-3">
                                <label for="name" class="form-label">Nombre<em class="text-danger">*</em></label>
                                <input type="text" name="name" id="name" class="form-control">
                            </div>
                            <div class="mb-3">
                                <label for="description" class="form-label">Descripción</label>
                                <textarea name="description" id="description" class="form-control"></textarea>
                            </div>
                            <div class="mb-3">
                                <label for="default_view" class="form-label">Vista por defecto<em
                                            class="text-danger">*</em></label>
                                <select name="default_view" id="default_view" class="form-control form-select">
                                    <?= generateHtmlOptionInSelectForDefaultView(getMenu(true)); ?>
                                </select>
                            </div>
                        </div>
                        <div class="tab-pane" id="acl">
                            <div>
                                <label for="" class="form-label">Módulos y Submódulos</label>
                                <div class="border" style="max-height: 500px; overflow-y: auto;">

                                    <ul class="demo-accordion accordionjs m-0" data-bs-active-index="false">
                                        <?php foreach ($_groups as $group): ?>
                                            <li>
                                                <div><h3><?= $group['title'] ?></h3></div>
                                                <div>
                                                    <div class="table-responsive-xl">
                                                        <table class="table">
                                                            <thead>
                                                            <tr>
                                                                <th scope="col">Nombre</th>
                                                                <th scope="col">Modulo</th>
                                                                <th scope="col">Acciones</th>
                                                            </tr>
                                                            </thead>
                                                            <tbody>

                                                            <?php foreach ($group['menu'] as $group_item): ?>
                                                                <?php if (isset($group_item['module'])): ?>

                                                                    <?php foreach ($group_item['module'] as $module_item): ?>
                                                                        <tr>
                                                                            <td><?= $module_item['folder']['name'] ?></td>
                                                                            <!-- Nombre -->
                                                                            <td>
                                                                                <em class="<?= $group_item['icon'] ?>"></em> <?= $group_item['name'] ?>
                                                                            </td><!-- Modulo -->
                                                                            <td>
                                                                                <div class="btn-group" role="group" aria-label="<?= $module_item['folder']['folder'] ?>_<?= $group['id'] ?>">
                                                                                    <input type="checkbox"
                                                                                           class="btn-check"
                                                                                           name="<?= $module_item['folder']['folder'] ?>"
                                                                                           id="all_<?= $module_item['folder']['folder'] ?>_<?= $group['id'] ?>"
                                                                                           autocomplete="off">
                                                                                    <label class="btn btn-outline-primary"
                                                                                           for="all_<?= $module_item['folder']['folder'] ?>_<?= $group['id'] ?>">Todo</label>

                                                                                    <input type="checkbox"
                                                                                           class="btn-check"
                                                                                           name="acl[<?= $group['id'] ?>][<?= $module_item['folder']['folder'] ?>][]"
                                                                                           id="read_<?= $module_item['folder']['folder'] ?>_<?= $group['id'] ?>"
                                                                                           autocomplete="off"
                                                                                           value="read">
                                                                                    <label class="btn btn-outline-primary"
                                                                                           for="read_<?= $module_item['folder']['folder'] ?>_<?= $group['id'] ?>">Leer</label>

                                                                                    <input type="checkbox"
                                                                                           class="btn-check"
                                                                                           name="acl[<?= $group['id'] ?>][<?= $module_item['folder']['folder'] ?>][]"
                                                                                           id="create_<?= $module_item['folder']['folder'] ?>_<?= $group['id'] ?>"
                                                                                           autocomplete="off"
                                                                                           value="create">
                                                                                    <label class="btn btn-outline-primary"
                                                                                           for="create_<?= $module_item['folder']['folder'] ?>_<?= $group['id'] ?>">Guardar</label>

                                                                                    <input type="checkbox"
                                                                                           class="btn-check"
                                                                                           name="acl[<?= $group['id'] ?>][<?= $module_item['folder']['folder'] ?>][]"
                                                                                           id="delete_<?= $module_item['folder']['folder'] ?>_<?= $group['id'] ?>"
                                                                                           autocomplete="off"
                                                                                           value="delete">
                                                                                    <label class="btn btn-outline-primary"
                                                                                           for="delete_<?= $module_item['folder']['folder'] ?>_<?= $group['id'] ?>">Eliminar</label>

                                                                                    <input type="checkbox"
                                                                                           class="btn-check"
                                                                                           name="acl[<?= $group['id'] ?>][<?= $module_item['folder']['folder'] ?>][]"
                                                                                           id="update_<?= $module_item['folder']['folder'] ?>_<?= $group['id'] ?>"
                                                                                           autocomplete="off"
                                                                                           value="update">
                                                                                    <label class="btn btn-outline-primary"
                                                                                           for="update_<?= $module_item['folder']['folder'] ?>_<?= $group['id'] ?>">Actualizar</label>
                                                                                </div>
                                                                            </td><!-- Acciones -->
                                                                        </tr>
                                                                    <?php endforeach; ?>

                                                                <?php else: ?>
                                                                    <tr>
                                                                        <td><?= $group_item['name'] ?></td>
                                                                        <!-- Nombre -->
                                                                        <td>
                                                                            <em class="<?= $group_item['icon'] ?>"></em> <?= $group_item['name'] ?>
                                                                        </td><!-- Modulo -->
                                                                        <td>
                                                                            <div class="btn-group" role="group"
                                                                                 aria-label="<?= $group_item['folder'] ?>_<?= $group['id'] ?>">
                                                                                <input type="checkbox" class="btn-check"
                                                                                       name="<?= $group_item['folder'] ?>"
                                                                                       id="all_<?= $group_item['folder'] ?>_<?= $group['id'] ?>"
                                                                                       autocomplete="off">
                                                                                <label class="btn btn-outline-primary"
                                                                                       for="all_<?= $group_item['folder'] ?>_<?= $group['id'] ?>">Todo</label>

                                                                                <input type="checkbox" class="btn-check"
                                                                                       name="acl[<?= $group['id'] ?>][<?= $group_item['folder'] ?>][]"
                                                                                       id="read_<?= $group_item['folder'] ?>_<?= $group['id'] ?>"
                                                                                       autocomplete="off" value="read">
                                                                                <label class="btn btn-outline-primary"
                                                                                       for="read_<?= $group_item['folder'] ?>_<?= $group['id'] ?>">Leer</label>

                                                                                <input type="checkbox" class="btn-check"
                                                                                       name="acl[<?= $group['id'] ?>][<?= $group_item['folder'] ?>][]"
                                                                                       id="create_<?= $group_item['folder'] ?>_<?= $group['id'] ?>"
                                                                                       autocomplete="off"
                                                                                       value="create">
                                                                                <label class="btn btn-outline-primary"
                                                                                       for="create_<?= $group_item['folder'] ?>_<?= $group['id'] ?>">Guardar</label>

                                                                                <input type="checkbox" class="btn-check"
                                                                                       name="acl[<?= $group['id'] ?>][<?= $group_item['folder'] ?>][]"
                                                                                       id="delete_<?= $group_item['folder'] ?>_<?= $group['id'] ?>"
                                                                                       autocomplete="off"
                                                                                       value="delete">
                                                                                <label class="btn btn-outline-primary"
                                                                                       for="delete_<?= $group_item['folder'] ?>_<?= $group['id'] ?>">Eliminar</label>

                                                                                <input type="checkbox" class="btn-check"
                                                                                       name="acl[<?= $group['id'] ?>][<?= $group_item['folder'] ?>][]"
                                                                                       id="update_<?= $group_item['folder'] ?>_<?= $group['id'] ?>"
                                                                                       autocomplete="off"
                                                                                       value="update">
                                                                                <label class="btn btn-outline-primary"
                                                                                       for="update_<?= $group_item['folder'] ?>_<?= $group['id'] ?>">Actualizar</label>
                                                                            </div>
                                                                        </td><!-- Acciones -->
                                                                    </tr>
                                                                <?php endif; ?>
                                                            <?php endforeach; ?>

                                                            </tbody>
                                                        </table>
                                                    </div>
                                                </div>
                                            </li>
                                        <?php endforeach; ?>
                                    </ul>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-dim btn-outline-danger" data-bs-dismiss="modal">Cancelar</button>
                    <button type="button" class="btn btn-dim btn-outline-success" data-modal-action="submit">Guardar</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- Modal ACL v2 @e -->

<!-- Modal Users Per Profile @s -->
<div class="modal fade" id="modal_table_users_profile" tabindex="-1" aria-labelledby="" data-bs-backdrop="static" data-bs-keyboard="false">
    <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Usuarios vinculados</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body py-0">
                <input type="hidden" name="profile_id">
                <div style="min-height: 350px; max-height: 750px; overflow-y: auto;">
                    <div class="table-responsive">
                        <table class="table table-bordered text-nowrap border-bottom w-100" id="table-config-users"></table>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-dim btn-outline-danger" data-bs-dismiss="modal">Cerrar</button>
            </div>
        </div>
    </div>
</div>
<!-- Modal Users Per Profile @e -->