<!DOCTYPE html>
<html lang="en">
                          
<?php $this->load->view("template/header"); ?>
<?php $this->load->view("template/nav"); ?>

<style>
     .form-control, #btn_buscar {
        height: calc(1.5em + 0.75rem + 2px); /* Altura uniforme */
        padding: 0.375rem 0.75rem; /* Padding uniforme */
        font-size: 16px;
        line-height: 1.5;
    }

    #btn_buscar {
        width: 150px;
    }

    .form-group {
        margin-bottom: 0; /* Ajusta el espacio entre los campos */
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        width: 100%;
        margin-bottom: 1rem;
        background-color: transparent;
    }

    .card-footer {
        padding: 10px; /* Elimina padding para evitar el desalineamiento */
        display: flex; /* Usa flex para alinear el contenido */
        align-items: center; /* Centra verticalmente los elementos en el contenedor */    
    }

    /* Responsive design */
    @media (max-width: 768px) {
        .card-body .row {
            flex-direction: column; /* Cambia la dirección del flex para pantallas pequeñas */
        }

        #btn_buscar {
            width: 100%; /* Hace que los botones ocupen todo el ancho en pantallas pequeñas */
        }
    }
</style>

<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1 class="m-0">Informe Ocupación</h1>
                </div>
                <!-- /.col -->
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                    <!-- <li class="breadcrumb-item"><a href="#" onclick="mySession()" class="nav-link">Cerrar Sesión</a></li> -->
                    </ol>
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </div>
        <!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <!-- Small boxes (Stat box) -->
            <div class="row">
            <div class="col-md-12">

            <!-- jquery validation -->
            <div class="card card-secondary">
                <div class="card-header">
                    <h3 class="card-title">Datos de  búsqueda </h3>
                </div>
                <!-- /.card-header -->

                <!-- form start -->
                <form id="quickForm"  autocomplete="off" >
                    <div class="card-body">
                        <div class="row">
                            <div class="col-12 col-sm-4 col-md-3 col-lg-2 mt-1 mb-1">
                                <div class="form-group">
                                    <label>Establecimiento</label>
                                    <select class="form-control" id="cmb_establecimiento">
									<option value="">--Seleccionar-- </option>
									<?php foreach($establecimiento as $k1) { ?>
										<option value="<?=$k1['IdEstablecimiento']?>"><?=$k1['Nombre']?></option>
									<?php } ?>                                    
                                	</select> 
                                </div>
                            </div> 

                            <div class="col-12 col-sm-4 col-md-3 col-lg-2 mt-1 mb-1">
								<div class="form-group">
									<label>Check In</label>
									<input type="date" name="txt_fechaini" class="form-control" id="txt_fechaini"> </input>
								</div>
							</div> 

                            <!-- /.col -->
                            <div class="col-12 col-sm-4 col-md-3 col-lg-2 mt-1 mb-1 d-flex align-items-end">
                                <button type="button" class="btn btn-primary" id="btn_buscar">Buscar</button>
                            </div>
                        </div> 
                    </div> 

                    <div class="card-body">
                        <div id="example1_wrapper" class="dataTables_wrapper dt-bootstrap4">
                            <div class="table-responsive">
                                <table id="example1" class="table table-bordered table-striped dataTable dtr-inline" role="grid" aria-describedby="example1_info">
                                    <thead>
                                        <tr role="row">
                                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="">Establecimiento</th>
                                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="">No. Habitación</th>
                                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="">Habitación</th>
                                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="">Huesped Principal</th>
                                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="">Acompañantes</th>
                                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="">Check In</th>
                                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="">Hora Ingreso</th>
                                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="">Check Out</th>
                                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="">Hora Salida</th>
                                    </thead>
                                    <tbody>            
                                    </tbody>
                                    <tfoot>
                                        <tr>
                                            <th rowspan="1" colspan="1" >Establecimiento</th>
                                            <th rowspan="1" colspan="1" >No. Habitación</th>
                                            <th rowspan="1" colspan="1" >Habitación</th>
                                            <th rowspan="1" colspan="1" >Huesped Principal</th>
                                            <th rowspan="1" colspan="1" >Acompañantes</th>
                                            <th rowspan="1" colspan="1" >Check In</th>
                                            <th rowspan="1" colspan="1" >Hora Ingreso</th>
                                            <th rowspan="1" colspan="1" >Check Out</th>
                                            <th rowspan="1" colspan="1" >Hora Salida</th>
                                        </tr>
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                    </div>
                </form>
            </div> 

            <!-- Main row -->
            <div class="row">
                <!-- Left col -->
                <section class="col-lg-7 connectedSortable">
                    <!-- Custom tabs (Charts with tabs)-->

                    <!-- /.card -->
                    </section>
                        <!-- /.Left col -->
                        <!-- right col (We are only adding the ID to make the widgets sortable)-->
                    <section class="col-lg-5 connectedSortable">

                </section>
                 <!-- right col -->
            </div>
            <!-- /.row (main row) -->
        </div>
        <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->

<?php $this->load->view("template/footer"); ?>


<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
</aside>
<!-- /.control-sidebar -->

<!-- ======================================================================================================================================================================================================= -->
     <!-- jQuery -->
     <script src="<?php echo base_url() ?>assets/plugins/jquery/jquery.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/jquery/jquery.min.js"></script>
    <!-- jQuery UI 1.11.4 -->
    <script src="<?php echo base_url() ?>assets/plugins/jquery-ui/jquery-ui.min.js"></script>
    <!-- jQuery Mask -->
    <script src="<?php echo base_url() ?>assets/plugins/jquery-Mask/jquery.mask.min.js"></script>
    <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
    <script>
        $.widget.bridge('uibutton', $.ui.button)
    </script>
    <!-- Bootstrap 4 -->
    <script src="<?php echo base_url() ?>assets/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
    <!-- ChartJS -->
    <script src="<?php echo base_url() ?>assets/plugins/chart.js/Chart.min.js"></script>
    <!-- Sparkline -->
    <!-- <script src="<?php echo base_url() ?>assets/plugins/sparklines/sparkline.js"></script> -->
    <!-- JQVMap  -->
    <script src="<?php echo base_url() ?>assets/plugins/jqvmap/jquery.vmap.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/jqvmap/maps/jquery.vmap.usa.js"></script>
    <!-- jQuery Knob Chart -->
    <script src="<?php echo base_url() ?>assets/plugins/jquery-knob/jquery.knob.min.js"></script>
    <!-- daterangepicker -->
    <script src="<?php echo base_url() ?>assets/plugins/moment/moment.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/daterangepicker/daterangepicker.js"></script>
    <!-- Tempusdominus Bootstrap 4 -->
    <script src="<?php echo base_url() ?>assets/plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
    <!-- Summernote -->
    <script src="<?php echo base_url() ?>assets/plugins/summernote/summernote-bs4.min.js"></script>
    <!-- overlayScrollbars -->
    <script src="<?php echo base_url() ?>assets/plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
    <!-- AdminLTE App -->
    <script src="<?php echo base_url() ?>assets/dist/js/adminlte.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="<?php echo base_url() ?>assets/dist/js/demo.js"></script>
    <!-- AdminLTE dashboard demo (This is only for demo purposes) -->
     <!-- <script src="<?php echo base_url() ?>assets/dist/js/pages/dashboard.js"></script> -->
    <!-- SweetAlert -->
    <script src="<?php echo base_url() ?>assets/plugins/sweetalert2/sweetalert2.all.min.js"></script>
    <!-- AdminLTE Datatable components -->
    <script src="<?php echo base_url() ?>assets/plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/jszip/jszip.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/pdfmake/pdfmake.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/pdfmake/vfs_fonts.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-buttons/js/buttons.html5.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-buttons/js/buttons.print.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
<!-- ======================================================================================================================================================================================================= -->

<script>
		// //aca ya carga la data no necesito enviar nuevamente    
		var establecimiento = <?php echo json_encode($establecimiento) ?>;  
		
        $("#btn_buscar").click(function () 
		{             
			//Captura de valores 
			var IdEstablecimiento = $('#cmb_establecimiento').val();
			var Fechaini          = $('#txt_fechaini').val();
		
			//llamada a micro servicio de validacion
			$.ajax({

				url: '<?php echo base_url() ?>InfoOcupacion/searchInfo',//controlador
				type: "POST",//tipo de peticion POST o GET
				headers: {'X-Requested-With': 'XMLHttpRequest'},//Encabezados
				data: { 'IdEstablecimiento' : IdEstablecimiento,
                        'Fechaini'          : Fechaini}//formato json Data
										
			}).done(function(dato){
				//convierto la respuesta json
				var info_bus = JSON.parse(dato);

                $("#example1").DataTable({
                data: info_bus,
                destroy: true,
				searching: false,
                columns:
                [
					{data : 'Establecimiento'},
					{data : 'NumeroHabitacion'},
					{data : 'TipoHabitacion'},
                    {data : 'NombreHuesped'},
                    {data : 'CantAcompanantes'},
					{data : 'FechaIni'},
					{data : 'HoraIni'},
					{data : 'FechaFin'},
					{data : 'HoraFin'}  
				],
                responsive: true,
                "lengthChange": false, 
                "autoWidth": false,
                lengthChange: true, // Habilitar la opción de longitud
                lengthMenu: [ [10, 25, 50, -1], [10, 25, 50, "All"] ], // Opciones para seleccionar la cantidad de registros por página
                autoWidth: false,
                language: {
                    "sProcessing": "Procesando...",
                    "sLengthMenu": "Mostrar _MENU_ entradas",
                    "sZeroRecords": "No se encontraron resultados",
                    "sInfo": "Mostrando de _START_ a _END_ de _TOTAL_ entradas",
                    "sInfoEmpty": "Mostrando 0 a 0 de 0 entradas",
                    "sInfoFiltered": "(filtrado de _MAX_ entradas totales)",
                    "sInfoPostFix": "",
                    "sSearch": "Buscar:",
                    "sUrl": "",
                    "sInfoThousands": ",",
                    "sLoadingRecords": "Cargando...",
                    "oPaginate": {
                        "sFirst": "Primero",
                        "sPrevious": "Anterior",
                        "sNext": "Siguiente",
                        "sLast": "Último"
                    },
                    "oAria": {
                        "sSortAscending": ": activar para ordenar la columna de manera ascendente",
                        "sSortDescending": ": activar para ordenar la columna de manera descendente"
                    }
                },
                buttons: ["copy", "csv", "excel", "pdf", "print"]
                }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(1)').css('float','right');	
			});	

            $('#cmb_establecimiento').val("");
            $('#txt_fechaini').val("");
		});
	
    </script>

</body>

</html>