<?= $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">
					<div class="card">
						<div class="card-header d-flex align-items-center">
                            <h5 class="card-title mb-0 flex-grow-1"><?= $breadcrumb_alias ?></h5>
                            <div>
								<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>
						<div class="card-body">
						    <?php
							if (in_array("ASDESU", $permisos)) 
							{
							?>
							<div class="row col-12 m-0 mb-3 p-3 bg-red-verisure-25" style="border-radius: 20px;">
                                <div class="col-xxl-9 col-md-12 col-12 mb-3">
                                    <div>
                                        <label for="txtDelegacionAsociarSubarea" class="form-label">Delegación</label>
                                        <select class="form-select" aria-label="Delegación" id="txtDelegacionAsociarSubarea" name="txtDelegacionAsociarSubarea">
                                            <option selected="" value="">Seleccione una opción</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-xxl-3 col-md-12 col-12 mb-3 d-flex flex-row-reverse align-items-center">
                                    <div>
                                        <button type="button" class="btn btn-success" id="btnAgregarDelegacionSubarea" data-subarea="<?= $idSubareaDel ?>">
                                        <i class="mdi mdi-plus-circle"></i> Agregar
                                    </button>
                                    </div>
                                </div>
                            </div>
							<?php
							}
							?>
							<table id="tblDelegacionesSubareaEstructura" class="table table-bordered dt-responsive nowrap table-striped align-middle" style="width:100%">
								<thead>
									<tr>
										<th class="text-center align-middle">Delegación</th>
										<th class="text-center align-middle">CC</th>
										<th class="text-center align-middle">LN</th>
										<th class="text-center align-middle">Acciones</th>
									</tr>
								</thead>
								<tbody>
									<?php 
									foreach($listaDelegaciones as $items){ ?>
									<tr>
										<td class="text-center align-middle"><?= $items['Delegacion'] ?></td>
										<td class="text-center align-middle"><?= $items['CC'] ?></td>
										<td class="text-center align-middle"><?= $items['LN'] ?></td>
										<td class="text-center align-middle">
											<?php
											if (in_array("DEDESU", $permisos)) 
											{
											?>
											<button class="badge bg-danger border-0 p-2 eliminar-delegacion-subarea-estructura" data-delegacion="<?= $items['IDDelegacion'] ?>" data-subarea="<?= $idSubareaDel ?>">
												<i class="mdi mdi-trash-can-outline align-bottom" style="font-size: 20px; color: #FFF;"></i>
											</button>
											<?php
											}
											?>
										</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-->
<?php $this->endSection(); ?>