<?php include "views/templates/header.php";?> 
<div class="col-md-6 mx-auto">
  <div class="card">
    <div class="card-header text-center bg-primary text-white">
      Permisos
    </div>
    <div class="card-body">
      <form id="formulario" onsubmit="registrarPermisos(event)">
        <div class="row">
          <?php $count = 0; ?>
          <?php foreach ($data['datos'] as $row) { ?>
            <div class="col-md-4"> 
              <div class="custom-checkbox">
              <input type="checkbox" value="<?php echo $row['id']; ?>" name="permisos[]" id="permiso-<?php echo $row['id']; ?>" class="toggle-checkbox" <?php echo isset($data['asignados'][$row['id']]) ? 'checked' : ''; ?>>

                <label for="permiso-<?php echo $row['id']; ?>"></label>
              </div>
              <label for="permiso-<?php echo $row['id']; ?>"><?php echo $row['permiso']; ?></label>
            </div>
            <?php $count++; ?>
            <?php if ($count % 3 == 0) { echo '</div><div class="row">'; } ?>
          <?php } ?>
          <input type="hidden" value="<?php echo $data['id_usuario'];?>" name="id_usuario">
        </div>
      
        <div class="d-grid gap-2">
          <button class="btn btn-outline-primary" type="submit">ASIGNAR PERMISOS</button>
          <a class="btn btn-outline-danger" href="<?php echo base_url;?>usuarios">CANCELAR</a>
        </div>
      </form>
    </div>
  </div>
</div>


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