<?= $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>
                                <a href="<?= $baseUrl.'/'.$previo ?>" class="btn bg-red-verisure color-white px-2 py-1 mx-1 waves-effect waves-light layout-rightside-btn">
								    <i class="mdi mdi-arrow-left" style="font-size: 18px;"></i>
								</a>
							</div>
                        </div>
						<div class="card-body">
						    <?php
							if (in_array("ADELKT", $permisos)) 
							{
							?>
							<div class="row col-12 m-0 mb-3 p-3 bg-sistema-25" style="border-radius: 20px;">
                                <div class="col-xxl-9 col-md-12 col-12 mb-3">
                                    <div>
                                        <label for="cboElementoTrabajo_kte" class="form-label">Elemento de Trabajo</label>
                                        <select class="form-select" aria-label="Elemento de Trabajo" id="cboElementoTrabajo_kte" name="cboElementoTrabajo_kte">
                                            <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="btnAgregarElementoKitTrabajo" data-kit="<?= $kitTrabajo['IDKitTrabajo'] ?>">
                                        <i class="mdi mdi-plus-circle"></i> Agregar
                                    </button>
                                    </div>
                                </div>
                            </div>
							<?php
							}
							?>
							<table id="tblElementoKitTrabajo" class="table table-bordered dt-responsive nowrap table-striped align-middle" style="width:100%">
								<thead>
									<tr>
										<th class="text-center align-middle">Código Elemento</th>
										<th class="text-center align-middle">Elemento</th>
										<th class="text-center align-middle">SKU</th>
										<th class="text-center align-middle">Moneda Reposición</th>
										<th class="text-center align-middle">Precio Reposición</th>
										<th class="text-center align-middle">Acciones</th>
									</tr>
								</thead>
								<tbody>
									<?php 
									foreach($listaElementosKitTrabajo as $items){ ?>
									<tr>
										<td class="text-center align-middle"><?= $items['IDElementoTrabajo'] ?></td>
										<td class="text-center align-middle"><?= $items['Nombre'] ?></td>
										<td class="text-center align-middle"><?= $items['SKU'] ?></td>
										<td class="text-center align-middle"><?= $items['MonedaReposicion'] ?></td>
										<td class="text-center align-middle"><?= $items['PrecioReposicion'] ?></td>
										<td class="text-center align-middle">
											<?php
											if (in_array("DEELKT", $permisos)) 
											{
											?>
											<button class="badge bg-danger border-0 p-2 eliminar-elemento-kit-trabajo" data-elemento="<?= $items['IDElementoTrabajo'] ?>" data-kit="<?= $items['IDKitTrabajo'] ?>">
												<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-->

<?= $this->section('js'); ?>
<script>
	selectElementoTrabajo('cboElementoTrabajo_kte', '', '');
</script>
<?php $this->endSection(); ?>

<?php $this->endSection(); ?>