<?php include "Views/templates/header.php"; ?>

<div class="col-md-12">
    <div class="card">
        <div class="card-header text-center text-bg-warning bg-warning"><h5>
            Asignacion de Permisos a Usuario</h5>
        </div>
        <form id="frmPermisos">
            <table class="table">
                <thead class="thead-dark">
                    <tr>
                        <th scope="col">Modulo</th>
                        <th scope="col">Opcion</th>
                        <th scope="col">Detalle</th>
                        <th scope="col">Acción</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($data['datos'] as $row) { 
                    if ($row['nivel'] != 0){
                    ?>
                    <tr>
                        <?php    

                        switch ($row['nivel']) {
                            case 1:
                                ?>
                                <td class="table-active" scope="row"><label for=""><?php echo $row['permiso']; ?></label> </td>
                                <td class="table-active"></td>
                                <td class="table-active" scope="row"></td>
                                <td class="table-active">
                                    <input type="checkbox" data-onstyle="success" name="permisos[]" value="<?php echo $row['id']; ?>" <?php echo isset($data['asignados'][$row['id']]) ? 'checked' : ''; ?> data-toggle="toggle" data-size="sm">
                                </td>
                                <?php
                                break;
                            case 2:
                                ?>
                                <td scope="row"></td>
                                <td class="table-info" scope="row"><label for=""><?php echo $row['permiso']; ?></label> </td>
                                <td class="table-info" scope="row"></td>
                                <td class="table-info" scope="row">
                                    <input type="checkbox" data-onstyle="success" name="permisos[]" value="<?php echo $row['id']; ?>" <?php echo isset($data['asignados'][$row['id']]) ? 'checked' : ''; ?> data-toggle="toggle" data-size="sm">
                                </td>
                                <?php
                                break;
                            case 3:
                                ?>
                                <td></td>
                                <td></td>
                                <td class="table-warning" scope="row"><label for=""><?php echo $row['permiso']; ?></label> </td>
                                <td class="table-warning">
                                    <input type="checkbox" data-onstyle="success" name="permisos[]" value="<?php echo $row['id']; ?>" <?php echo isset($data['asignados'][$row['id']]) ? 'checked' : ''; ?> data-toggle="toggle" data-size="sm">
                                </td>
                                <?php
                                break;
                        }


                        ?>
                    </tr>        
                    <?php }} ?>
                </tbody>
            </table>


            <div class="card-body">
                <div class="row">
                    <input type="hidden" value="<?php echo $data['id_usuario']; ?>" name="id_usuario">
                </div>
            </div>
            <div class="card-footer float-right">
                <button class="btn btn-primary" type="submit">Asignar Permisos</button>
                <a class="btn btn-danger" href="<?php echo base_url; ?>usuarios">Cancelar</a>
            </div>
        </form>
    </div>
</div>

<?php include "Views/templates/footer.php"; ?>

