<?= $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="formPermisosPerfil" class="formulario" autocomplete="off" method="POST" action="<?= $baseUrl ?>/grabar-rutas-perfil/<?= $idPerfilSeleccionado ?>">
                        <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 ?> | <?= $perfilSeleccionado['Perfil'] ?></h5>
                                <div>
									<?php
									if (in_array("SARUPE", $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($listaRutas as $ruta)
									{
										if($ruta['RaizModulo'] == 'Y')
										{
											$classAdicional = "form-check-input-green";
										}
										else if($ruta['TipoRuta'] == 'ACCION')
										{
											$classAdicional = "form-check-input-red";
										}
										else
										{
											$classAdicional = "form-check-input-orange";
										}
										
										if($ruta['IDModulo'] == $modulos['IDModulo'])
										{
										?>
										<div class="row col-12 m-0 p-0">
    										<div class="form-check form-switch form-switch-lg">
    											<input class="form-check-input <?= $classAdicional ?>" type="checkbox" role="switch" name="rutas[<?=$ruta['IDRuta']?>]" id="chkRuta<?=$ruta['IDRuta']?>" <?=$ruta['ACTIVO']==1 ? 'checked' : ''?> >
    											<label class="form-check-label" for="chkRuta<?=$ruta['IDRuta']?>"><?=$ruta['Ruta']?></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://linktr.ee/rbarcenac">Verisure Peru</a>
					</div>
				</div>
			</div>
		</div>
	</footer>
</div>
<!-- end main content-->
<?php $this->endSection(); ?>