<?= $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_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"><?= $subtitulo ?></h5>
                            <div class="d-flex">
								
                            </div>
                        </div>
						<div class="card-body">
							<table id="tblReposiciones" 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 REPOSICIONES***/
		assetListVM = {
			dt: null,
			init: function () {
				dt = $('#tblReposiciones').DataTable({
					"serverSide": true,
					"processing": true,
					"ajax": {
						"url": baseUrl + "/reposiciones-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": "IDReposicion", "class": "text-center", "searchable": true },
						{"title": "Matrícula", "data": "MatriculaAdjudicado", "class": "text-center", "searchable": true },
						{"title": "Adjudicado", "data": "NombreAdjudicado", "class": "text-center", "searchable": true },
						{"title": "Fecha Adjudicado", "data": "FechaAdjudicado", "class": "text-center", "searchable": true },
						{"title": "Monto Adjudicado", "data": "MontoAdjudicado", "class": "text-center", "searchable": true },
						{"title": "Observación", "data": "Observacion", "class": "text-center", "searchable": true },
						{"title": "Cuotas", "data": "CuotasPago", "class": "text-center", "searchable": true },
						{"title": "Dispositivos Adjudicados", "data": "TotalElementos", "class": "text-center", "searchable": true },
						{"title": "¿Firmado?", "data": "Firma", "class": "text-center", "searchable": true },
						{"title": "Acciones", "data": "Acciones", "class": "text-center", "searchable": true }
					],
                    "drawCallback": function(settings) {
                        // Re-inicializar tooltips después de que los datos son cargados
                        $('[data-tooltip="tooltip"]').tooltip();
                        $('[data-toggle="tooltip"]').tooltip();
                    },
					"lengthMenu": [[10, 25, 50], [10, 25, 50]],
					responsive: true,
                    columnDefs: [
                        { responsivePriority: 1, targets: 0 },
                        { responsivePriority: 1, targets: 1 },
                        { responsivePriority: 1, targets: 2 },
                        { responsivePriority: 6, targets: 3 },
                        { responsivePriority: 6, targets: 4 },
                        { responsivePriority: 10, targets: 5 },
                        { responsivePriority: 10, targets: 6 },
                        { responsivePriority: 6, targets: 7 },
                        { responsivePriority: 1, targets: 8 },
                        { responsivePriority: 1, targets: 9 }
                    ],
					autoWidth: false,
					"aaSorting": [[0, 'desc']],
				});
			}
		}

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

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