<?= $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">
								
                            </div>
                        </div>
						<div class="card-body">
							<table id="tblResponsablesEstructuraDepartamental" class="table table-bordered dt-responsive nowrap table-striped align-middle" style="width:100%">
								<thead>
									<tr>
										<th class="text-center align-middle">Delegaciones</th>
										<th class="text-center align-middle">Subárea</th>
										<th class="text-center align-middle">Área</th>
										<th class="text-center align-middle">Dirección</th>
										<th class="text-center align-middle">Responsable Subárea<br>(Firma 01)</th>
										<th class="text-center align-middle">Responsable Área<br>(Firma 02)</th>
										<th class="text-center align-middle">Responsable Dirección<br>(Firma 03)</th>
										<th class="text-center align-middle">Acciones</th>
									</tr>
								</thead>
								<tbody>
									<?php 
									foreach($estructuraDepartamental as $items){ ?>
									<tr>
									    <td class="text-center align-middle"><?= $items['Delegaciones'] ?></td>
										<td class="text-center align-middle"><?= $items['Subarea'] ?></td>
										<td class="text-center align-middle"><?= $items['Area'] ?></td>
										<td class="text-center align-middle"><?= $items['Direccion'] ?></td>
										<td class="text-center align-middle">
										    <?php
										    if(isset($aprobadores01[$items['IDSubarea']]) && $aprobadores01[$items['IDSubarea']] != '' && $aprobadores01[$items['IDSubarea']] != NULL)
										    {
										        echo ucwords(mb_strtolower($listadoUsuarios[$aprobadores01[$items['IDSubarea']]]));
										    }
										    else
										    {
										        echo "Sin Información";
										    }
										    ?>
										</td>
										<td class="text-center align-middle">
										    <?php
										    if(isset($aprobadores02[$items['IDSubarea']]) && $aprobadores02[$items['IDSubarea']] != '' && $aprobadores02[$items['IDSubarea']] != NULL)
										    {
										        echo ucwords(mb_strtolower($listadoUsuarios[$aprobadores02[$items['IDSubarea']]]));
										    }
										    else
										    {
										        echo "Sin Información";
										    }
										    ?>
										</td>
										<td class="text-center align-middle">
										    <?php
										    if(isset($aprobadores03[$items['IDSubarea']]) && $aprobadores03[$items['IDSubarea']] != '' && $aprobadores03[$items['IDSubarea']] != NULL)
										    {
										        echo ucwords(mb_strtolower($listadoUsuarios[$aprobadores03[$items['IDSubarea']]]));
										    }
										    else
										    {
										        echo "Sin Información";
										    }
										    ?>
										</td>
										<td class="text-center align-middle">
										    <center>
                                                <div class="btn-group" role="group" aria-label="">
                                                    <button type="button" class="btn bg-success px-2 py-1 d-flex justify-content-center align-items-center color-white mx-1 modificar-responsables-aprobacion-subarea" data-form="#formModificarResponsablesAprobacionSubarea" data-bs-target="#modificarResponsablesAprobacionSubarea" data-subarea="<?= $items['IDSubarea'] ?>">
                                                        <span class="mdi mdi-autorenew" style="font-size: 24px;"></span>
                                                    </button>
                                                </div>
                                            </center>
										</td>
									</tr>
									<?php } ?>
								</tbody>
							</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://linktr.ee/rbarcenac">Verisure Peru</a>
					</div>
				</div>
			</div>
		</div>
	</footer>
</div>
<!-- end main content-->

<!-- Modal Modificar Aprobadores -->
<div class="modal fade zoomIn" id="modificarResponsablesAprobacionSubarea" data-bs-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="examplemodificarResponsablesAprobacionSubarea" aria-hidden="true">
	<div class="modal-dialog modal-xl modal-dialog-centered" role="document">
		<div class="modal-content" style="border: none;">
			<div class="modal-header bg-sistema p-3">
				<h5 class="modal-title color-white" id="examplemodificarResponsablesAprobacionSubarea">Modificar Responsables de Aprobación</h5>
				<button type="button" class="btn-close bg-white" data-bs-dismiss="modal" aria-label="Close"></button>
			</div>
			<form id="formModificarResponsablesAprobacionSubarea" class="formulario" autocomplete="off" action="<?= $baseUrl ?>/actualizar-responsables-aprobacion-subarea" method="POST" accept-charset="utf-8">
				<div class="modal-body">
				    <span class="respuesta"></span>
			        <input type="hidden" id="idSubarea_mras" name="idSubarea_mras">
    			    <h3 class="mb-3">Requerimiento</h3>
    			    <div class="row m-0 mb-3">
    					<div class="col-12 col-lg-4">
    						<div class="form-group">
    							<label for="subarea_mras">Subárea</label>
    							<input type="text" class="form-control" id="subarea_mras" placeholder="Subárea" disabled>
    						</div>
    					</div>
    					<div class="col-12 col-lg-4">
    						<div class="form-group">
    							<label for="area_mras">Área</label>
    							<input type="text" class="form-control" id="area_mras" placeholder="Área" disabled>
    						</div>
    					</div>
    					<div class="col-12 col-lg-4">
    						<div class="form-group">
    							<label for="direccion_mras">Dirección</label>
    							<input type="text" class="form-control" id="direccion_mras" placeholder="Dirección" disabled>
    						</div>
    					</div>
    				</div>
    				<hr>
    				<h3 class="mb-3">Responsables Firma</h3>
    			    <div class="row m-0 mb-3">
    					<div class="col-12 col-lg-4">
    						<label for="cboResponsableAprobacion01_mras">Firma 01</label>
							<select class="form-select" id="cboResponsableAprobacion01_mras" name="cboResponsableAprobacion01_mras" data-modal="modificarResponsablesAprobacionSubarea">
							</select>
    					</div>
    					<div class="col-12 col-lg-4">
    						<label for="cboResponsableAprobacion02_mras">Firma 02</label>
							<select class="form-select" id="cboResponsableAprobacion02_mras" name="cboResponsableAprobacion02_mras" data-modal="modificarResponsablesAprobacionSubarea">
							</select>
    					</div>
    					<div class="col-12 col-lg-4">
    						<label for="cboResponsableAprobacion03_mras">Firma 03</label>
							<select class="form-select" id="cboResponsableAprobacion03_mras" name="cboResponsableAprobacion03_mras" data-modal="modificarResponsablesAprobacionSubarea">
							</select>
    					</div>
    				</div>
    				<hr class="mb-0">
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-danger color-white" data-bs-dismiss="modal"><i class="mdi mdi-close-thick me-1" style="font-size: 14px;"></i>Cerrar</button>
					<button type="submit" class="btn bg-success color-white"><i class="mdi mdi-content-save me-1" style="font-size: 14px;"></i>Guardar</button>
				</div>
			</form>
		</div>
	</div>
</div>
<?php $this->endSection(); ?>