<?= $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"><?= $elementoSeleccionadoModulo ?></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 ?></li>
							</ol>
						</div>
					</div>
				</div>
			</div>
			<!-- end page title -->
			<div class="row">
				<div class="col-lg-12">
					<div class="card">
						<div class="card-header d-flex align-items-center">
                            <h5 class="card-title mb-0 flex-grow-1"><?= $subtitulo ?></h5>
                            <div class="d-flex">
								<?php
								if (in_array("ADDINL", $permisos)) 
								{
								?>
                                <button class="btn bg-sistema d-flex justify-content-center align-items-center mx-1 color-white datos-informacion-legal" data-bs-target="#informacionLegal" data-form="#formInformacionLegal" data-id="0" data-accion="crear" id="crear-informacion-legal">
									<i class="mdi mdi-plus-circle me-1" style="font-size: 14px;"></i>Nuevo 
								</button>
								<?php
								}
								?>
								<button type="button" class="btn bg-filtros color-white px-2 py-1 mx-1 waves-effect waves-light layout-rightside-btn" data-bs-toggle="offcanvas" data-bs-target="#theme-settings-offcanvas" aria-controls="theme-settings-offcanvas">
                                    <i class="mdi mdi-filter" style="font-size: 18px;"></i>
                                </button>
                            </div>
                        </div>
						<div class="card-body">
							<table id="tblInformacionLegales" class="table table-bordered dt-responsive nowrap table-striped align-middle" style="width:100%">
							</table>
						</div>
					</div>
				</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-->

<?= $this->section('js'); ?>
<script>
	$(function () {
		/***SERVERSIDE LISTADO DE LEGALES***/
		assetListVM = {
			dt: null,
			init: function () {
				dt = $('#tblInformacionLegales').DataTable({
					"serverSide": true,
					"processing": true,
					"ajax": {
						"url": baseUrl + "/legales-serverside",
						type: 'POST',
						data: function(d) {
						    let rutavista = window.location.href;
						    let arrayrutavista = rutavista.split("/");
						    d.url_vista = arrayrutavista[arrayrutavista.length-1];
						}
					},
					"columns": [
						{"title": "Código", "data": "IDLegal", "class": "text-center", "searchable": true },
						{"title": "Acta", "data": "Acta", "class": "text-center", "searchable": true },
						{"title": "Título Legal", "data": "Titulo", "class": "text-center", "searchable": true },
						{"title": "Elementos Afecta", "data": "Elementos", "class": "text-center", "searchable": true, "orderable": false  },
						{"title": "Acciones", "data": "acciones", "class": "text-center", "searchable": false, "orderable": false },
					],
					"lengthMenu": [[10, 25, 50], [10, 25, 50]],
					responsive: true,
					autoWidth: false,
					"pageLength": 10,
					"paging": true,
					"aaSorting": [[0, 'desc']],
				});
			}
		}

		assetListVM.init();
		/****FIN SERVERSIDE LISTADO DE LEGALES****/
		
	});
</script>
<?php $this->endSection(); ?>

<!-- Filtros -->
<div class="offcanvas offcanvas-end border-0" tabindex="-1" id="theme-settings-offcanvas" aria-modal="true" role="dialog">
    <div class="d-flex align-items-center bg-filtros bg-gradient p-3 offcanvas-header">
        <h5 class="m-0 me-2 text-white">Filtros</h5>

        <button type="button" class="btn-close btn-close-white ms-auto" id="customizerclose-btn" data-bs-dismiss="offcanvas" aria-label="Close"></button>
    </div>
    <div class="offcanvas-body p-0">
        <!--<div data-simplebar="init" class="h-100 simplebar-scrollable-y">-->
        <!--    <div class="simplebar-wrapper" style="margin: 0px;">-->
        <!--        <div class="simplebar-height-auto-observer-wrapper">-->
        <!--            <div class="simplebar-height-auto-observer">-->
                        
        <!--            </div>-->
        <!--        </div>-->
        <!--        <div class="simplebar-mask">-->
        <!--            <div class="simplebar-offset" style="right: 0px; bottom: 0px;">-->
        <!--                <div class="simplebar-content-wrapper" tabindex="0" role="region" aria-label="scrollable content" style="height: 100%; overflow: hidden scroll;">-->
        <!--                    <div class="simplebar-content" style="padding: 0px;">-->
            <div id="ctnFiltro" class="p-3">
				<div class="card border" style="border-top: 3px #536878 solid!important;">
					<div class="card-header">
                        <div class="d-flex align-items-center">
                            <div class="flex-grow-1">
                                <h6 class="card-title mb-0">Columnas</h6>
                            </div>
                            <div class="flex-shrink-0">
                                <ul class="list-inline card-toolbar-menu d-flex align-items-center mb-0">
                                    <li class="list-inline-item">
                                        <a class="align-middle minimize-card" data-bs-toggle="collapse" href="#collapseColumnasFiltros" role="button" aria-expanded="true" aria-controls="collapseColumnasFiltros">
                                            <i class="mdi mdi-plus align-middle plus"></i>
                                            <i class="mdi mdi-minus align-middle minus"></i>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
					<div class="card-body collapse show" id="collapseColumnasFiltros" style="">
						cxcvcxxvxcxcv
					</div>
				</div>
				<div class="panel">
                    <div class="panel-heading">
                        <h4>Columnas</h4>
                    </div>
                    <div class="panel-content">
                        <div class="row">
                            adasasads
                        </div>
                    </div>
                </div>
            </div>
        <!--                    </div>-->
        <!--                </div>-->
        <!--            </div>-->
        <!--        </div>-->
        <!--        <div class="simplebar-placeholder" style="width: 400px; height: 1978px;">-->
                    
        <!--        </div>-->
        <!--    </div>-->
        <!--    <div class="simplebar-track simplebar-horizontal" style="visibility: hidden;">-->
        <!--        <div class="simplebar-scrollbar" style="width: 0px; display: none;">-->
                    
        <!--        </div>-->
        <!--    </div>-->
        <!--    <div class="simplebar-track simplebar-vertical" style="visibility: visible;">-->
        <!--        <div class="simplebar-scrollbar" style="height: 314px; transform: translate3d(0px, 0px, 0px); display: block;">-->
                    
        <!--        </div>-->
        <!--    </div>-->
        <!--</div>-->
    </div>
    <div class="offcanvas-footer border-top p-3 text-center">
        <div class="row">
            <div class="col-4">
                <button type="button" class="btn btn-light w-100" id="btnLimpiar">Limpiar</button>
            </div>
            <div class="col-4">
                <button type="button" class="btn btn-danger w-100" id="btnCerrarFiltros" data-bs-dismiss="offcanvas" aria-label="Close">Cerrar</button>
            </div>
            <div class="col-4">
                <button type="button" class="btn btn-primary w-100" id="btnBuscarFiltros">Buscar</button>
            </div>
        </div>
    </div>
</div>

<!-- Modal Información Legal -->
<div class="modal fade zoomIn" id="informacionLegal" data-bs-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="exampleinformacionLegal" aria-hidden="true">
	<div class="modal-dialog modal-dialog-centered modal-xl" role="document">
		<div class="modal-content" style="border: none;">
			<div class="modal-header bg-sistema p-3">
				<h5 class="modal-title color-white" id="exampleinformacionLegal">Información Legal</h5>
				<button type="button" class="btn-close bg-white" data-bs-dismiss="modal" aria-label="Close"></button>
			</div>
			<form id="formInformacionLegal" class="formularioLegal" autocomplete="off" action="" method="POST">
				<span class="respuesta"></span>
				<div class="modal-body">
					<input type="hidden" id="txtIDLegal_i" name="txtIDLegal_i">
					<div class="row">
						<div class="col-xxl-7 col-md-12 col-12 mb-3">
							<label for="txtTituloLegal_i" class="form-label">Título Legal</label>
							<div class="input-group">
								<input type="text" class="form-control" aria-label="Título Legal" id="txtTituloLegal_i" name="txtTituloLegal_i">
							</div>
						</div>
						<div class="col-xxl-5 col-md-12 col-12 mb-3">
							<div>
								<label for="txtActaAsociada_i" class="form-label">Acta Asociada</label>
								<select class="form-select" aria-label="Marca" id="txtActaAsociada_i" name="txtActaAsociada_i">
									<option selected="" value="">Seleccione una opción</option>
									<option value="ASIGNACIÓN">ASIGNACIÓN</option>
									<option value="REPOSICIÓN">REPOSICIÓN</option>
									<option value="DEVOLUCIÓN">DEVOLUCIÓN</option>
								</select>
							</div>
						</div>
					    <div class="row col-12 m-0 p-0 mb-3 d-flex px-3">
							<div class="card text-dark bg-sistema px-0 border-sistema-2px">
								<div class="card-header" style="background-color: transparent; color: #FFF;">Elementos Afecta</div>
								<div class="card-body d-flex align-items-center justify-content-center p-0" style="background-color: #FFF;">
									<div class="col-xxl-4 col-md-12 col-12 p-3 m-0">
									    <div class="row col-12 m-0 p-0">
    										<div class="form-check form-switch form-switch-lg">
    											<input class="form-check-input" type="checkbox" role="switch" name="elementosLegal[]" id="chkLegalLINEA" value="LINEA">
    											<label class="form-check-label" for="chkLegalLINEA">Línea</label>
    										</div>
    										<div class="form-check form-switch form-switch-lg">
    											<input class="form-check-input" type="checkbox" role="switch" name="elementosLegal[]" id="chkLegalMOVIL" value="MOVIL">
    											<label class="form-check-label" for="chkLegalMOVIL">Movil</label>
    										</div>
    										<div class="form-check form-switch form-switch-lg">
    											<input class="form-check-input" type="checkbox" role="switch" name="elementosLegal[]" id="chkLegalHARDWARE" value="HARDWARE">
    											<label class="form-check-label" for="chkLegalHARDWARE">Hardware</label>
    										</div>
    									</div>
									</div>
									<div class="col-xxl-4 col-md-12 col-12 p-3 m-0">
									    <div class="row col-12 m-0 p-0">
    										<div class="form-check form-switch form-switch-lg">
    											<input class="form-check-input" type="checkbox" role="switch" name="elementosLegal[]" id="chkLegalTARJETA" value="TARJETA">
    											<label class="form-check-label" for="chkLegalTARJETA">Tarjetas de Acceso</label>
    										</div>
    										<div class="form-check form-switch form-switch-lg">
    											<input class="form-check-input" type="checkbox" role="switch" name="elementosLegal[]" id="chkLegalKITDEMO" value="KITDEMO">
    											<label class="form-check-label" for="chkLegalKITDEMO">Kits Demo</label>
    										</div>
    										<div class="form-check form-switch form-switch-lg">
    											<input class="form-check-input" type="checkbox" role="switch" name="elementosLegal[]" id="chkLegalELEMENTOTRABAJO" value="ELEMENTOTRABAJO">
    											<label class="form-check-label" for="chkLegalELEMENTOTRABAJO">Elementos de Trabajo</label>
    										</div>
    									</div>
									</div>
									<div class="col-xxl-4 col-md-12 col-12 p-3 m-0">
									    <div class="row col-12 m-0 p-0">
    										<!--<div class="form-check form-switch form-switch-lg">-->
    										<!--	<input class="form-check-input" type="checkbox" role="switch" name="elementosLegal[]" id="chkLegalUNIFORME" value="UNIFORME">-->
    										<!--	<label class="form-check-label" for="chkLegalUNIFORME">Uniforme</label>-->
    										<!--</div>-->
    										<div class="form-check form-switch form-switch-lg">
    											<input class="form-check-input" type="checkbox" role="switch" name="elementosLegal[]" id="chkLegalFLOTA" value="FLOTA">
    											<label class="form-check-label" for="chkLegalFLOTA">Flota</label>
    										</div>
    									</div>
									</div>
								</div>
							</div>
						</div>
						<div class="col-xxl-6 col-md-12 col-12 mb-3 h-100">
							<label class="form-label">Texto Legal</label>
							<div id="txtTextoLegal_i">
								
							</div>
						</div>
						<div class="col-xxl-6 col-md-12 col-12 mb-3 h-100">
							<label class="form-label">Previsualización</label>
							<div id="txtPrevisualizacionTextoLegal_i">
								
							</div>
						</div>
						
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn bg-danger d-flex justify-content-center align-items-center color-white" data-bs-dismiss="modal"><i class="mdi mdi-close-thick mx-1" style="font-size: 14px;"></i>Cerrar</button>
					<button type="submit" id="btnEjecutarInfoLegal" class="btn bg-success d-flex justify-content-center align-items-center color-white"><i class="mdi mdi-import mx-1" style="font-size: 14px;"></i>Actualizar</button>
				</div>
			</form>
		</div>
	</div>
</div>
<?php $this->endSection(); ?>