<?= $this->extend('estructura/header_dashboard'); ?>
<?= $this->section('content'); ?>
<!-- ============================================================== -->
<!-- Start right Content here -->
<!-- ============================================================== -->
<div class="main-content">
	<div class="page-content">
		<div class="container-fluid">
			<!-- start page title -->
			<div class="row">
				<div class="col-12">
					<div class="page-title-box d-sm-flex align-items-center justify-content-between">
						<h4 class="mb-sm-0"><?= $breadcrumb_alias ?></h4>
						<div class="page-title-right">
							<ol class="breadcrumb m-0">
								<li class="breadcrumb-item"><a href="javascript: void(0);">Inicio</a></li>
								<li class="breadcrumb-item active"><?= $breadcrumb_alias ?></li>
							</ol>
						</div>
					</div>
				</div>
			</div>
			<!-- end page title -->
			<div class="row">
				<div class="col-lg-12">
					<form id="formPermisosUsuario" class="formulario" autocomplete="off" method="POST" action="<?= $baseUrl ?>/grabar-permisos-usuario/<?= $idUsuario ?>">
                        <span class="respuesta"></span>
                        <!-- Horizontal Form -->
                        <div class="card">
                            <div class="card-header d-flex align-items-center" style="background-color: #d2d6de;">
                                <h5 class="card-title mb-0 flex-grow-1" style=""><?= $breadcrumb_alias ?> | <?= $usuarioSeleccionado['Nombres'].' '.$usuarioSeleccionado['Apellidos'] ?></h5>
								<div>
									<?php
									if (in_array("SAPEUS", $permisos)) 
									{
									?>
									<button type="submit" class="btn btn-success">
										<i class="mdi mdi-content-save"></i> Guardar
									</button>
									<?php
									}
									?>
									<a href="<?= $baseUrl.'/'.$previo ?>" class="btn px-2 py-0" style="border-radius: 45%; background-color: red;"><i class="mdi mdi-arrow-left-circle" style="font-size: 24px; color: #FFF"></i></a>
								</div>
							</div>
                            <!-- /.card-header -->
                            
                            <div class="card-body row m-0 p-0">
							<?php
							foreach($listaModulos as $modulos)
							{
							?>
							<div class="col-4 p-3 m-0">
								<div class="card text-dark bg-info">
									<div class="card-header" style="background-color: transparent; color: #FFF;"><?= $modulos['Modulo'] ?></div>
									<div class="card-body" style="background-color: #FFF;">
										
									<?php
									foreach($listaPermisos as $permisos)
									{
										if($permisos['IDModulo'] == $modulos['IDModulo'])
										{
									?>
									    <div class="row col-12 m-0 p-0">
    										<div class="form-check form-switch">
    											<input class="form-check-input" type="checkbox" role="switch" name="permisos[<?=$permisos['IDAccionModulo']?>]" id="chk<?=$permisos['Codigo']?>" <?=$permisos['ACTIVO']==1 ? 'checked' : ''?> >
    											<label class="form-check-label" for="chk<?=$permisos['Codigo']?>"><?=$permisos['Accion']?></label>
    										</div>
    									</div>
									<?php
										}
									}
									?>
									</div>
								</div>
							</div>
							<?php
							}
							?>
                            </div>
                            <!-- /.card-body -->
                        </div>
                    </form>
				</div>
			</div>
		</div>
		<span class="respuesta_global"></span>
		<!-- container-fluid -->
	</div>
	<!-- End Page-content -->
    <footer class="footer">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-6">
                    <script>document.write(new Date().getFullYear())</script> © Verisure Peru.
                </div>
                <div class="col-sm-6">
                    <div class="text-sm-end d-none d-sm-block">Desarrollado por <a href="https://www.verisure.pe/">Verisure Peru</a>
                    </div>
                </div>
            </div>
        </div>
    </footer>  
</div>
<!-- end main content-->
<?php $this->endSection(); ?>