<?php
if(!isset($_SESSION)) {
    session_start();
}

require_once($_SERVER['DOCUMENT_ROOT'].'/varios/varios.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/clases/Varios.Class.php');

if( Varios::isActiveSession() 
    && Varios::hasModuleAccess(12)
	&& isset($_SESSION[_SYSTEM_SESIONID.'userId'])
) {
	$id = Varios::decodifica($_SESSION[_SYSTEM_SESIONID.'userId']);


	$rut = '';
	$nombre = '';
	$estadoID = '';
	$tipoOrdenID = '';
	require_once($_SERVER['DOCUMENT_ROOT'].'/clases/Parametro.Class.php');
    $parametro_obj = new Parametro(null);
    $estado_inf = $parametro_obj->informacionParametro( 101000, null, 1, 1);
    $bodega_inf = $parametro_obj->informacionParametro( 105000, null, 1, 1);
    $parametro_obj->Close();

	require_once($_SERVER['DOCUMENT_ROOT'].'/clases/Puerta.Class.php');
    $puerta_obj = new Puerta(null);
    $puerta_inf = $puerta_obj->informacionPuerta( null, 1, 1);
	$puerta_obj->Close();
	?>
	<script type="text/javascript">
		// FIXME: Separar en JS
	$(document).ready(function(){

		var v_hoy = new Date();

		$("#txt_filtroFechaInicio, #txt_filtroFechaFin").datetimepicker({
			locale: 'es',
			format: "dd-mm-yyyy",
			autoclose: true,
			todayBtn: true,
			minView: 2,
			pickerPosition: "bottom",
			startDate: "01-01-2023"
		});


	});
</script>
	<link rel="stylesheet" href="/assets/css/checkbox.css?v=0">
	<input value="<?php echo date("m");?>" type="hidden" id="txt_mes_inicial" name="txt_mes_inicial">
	<input value="<?php echo date("Y");?>" type="hidden" id="txt_anio_inicial" name="txt_anio_inicial">
	<div class="row ">
		<div class="col-xs-12 col-xl-10">
			<div class="row form-group">
				<label for="" class="col-form-label col-xs-12 col-xl-1">Fecha Inicio</label>
				<div class="col-sm-2">
					<input class="form-control"
						data-format="dd-MM-yyyy" <?php Varios::inputVerification('filtroReporteReservasFechaInicio');?>
						type="text" id="txt_filtroFechaInicio" name="txt_filtroFechaInicio" value="">
				</div>
				<label for="" class="col-form-label col-sm-1">Fecha Fin</label>
				<div class="col-sm-2">
				<input class="form-control"
						data-format="dd-MM-yyyy" <?php Varios::inputVerification('filtroReporteReservasFechaFin');?>
						type="text" id="txt_filtroFechaFin" name="txt_filtroFechaFin" value="">
				</div>
				<label for="" class="col-form-label col-xs-12 col-xl-1">Tipo</label>
				<div class="col-sm-5">
					<label class="checkboxes">Cliente
						<input id="chb_cliente" name="chb_cliente"
							type="checkbox" <?php if(0 == 1) {?>checked="checked"<?php }?>>
						<span class="checkmark"></span>
					</label>
					<label class="checkboxes">Proveedor Sils
						<input id="chb_proveedorSils" name="chb_proveedorSils"
							type="checkbox" <?php if(0 == 1) {?>checked="checked"<?php  }?>>
						<span class="checkmark"></span>
					</label>                                    
					<label class="checkboxes">Proveedor Cliente
						<input id="chb_proveedorCliente" name="chb_proveedorCliente"
							type="checkbox" <?php if(0 == 1) {?>checked="checked"<?php  }?>>
						<span class="checkmark"></span>
					</label>                                    
				</div>
			</div>
			<div class="form-group row">
				<label for="" class="col-form-label col-xs-12 col-xl-1">Bodega</label>
				<div class="col-xs-12 col-xl-5">
					<select name="cmb_filtroBodega" id="cmb_filtroBodega" class="form-control" >
						<option value="">Seleccione ...</option><?php
						foreach ($bodega_inf as $row) {?>
							<option value="<?php echo $row['para_UID'];?>"
                            	<?php Varios::selectVerification('filtroReporteReservasBodega', $row['para_UID']);?>><?php echo $row['para_nombre'];?>
                           </option><?php
						}?>
					</select>
				</div>
				<label for="" class="col-form-label col-xs-12 col-xl-1">Puerta</label>
				<div class="col-xs-12 col-xl-5">
					<select name="cmb_filtroPuerta" id="cmb_filtroPuerta" class="form-control" >
						<option value="">Seleccione ...</option><?php
						foreach ($puerta_inf as $row) {?>
							<option value="<?php echo $row['puer_UID'];?>"
                            	<?php Varios::selectVerification('filtroReporteReservasPuerta', $row['puer_UID']);?>><?php echo $row['puer_descripcion'];?>
                           </option><?php
						}?>
					</select>
				</div>
				
			</div>
			<div class="form-group row">				
				<label for="" class="col-form-label col-xs-12 col-xl-1">Razón Social</label>
				<div class="col-xs-12 col-xl-5">
					<input class="form-control" placeholder="Razón Social" type="text"
						id="txt_filtroRazonSocial" name="txt_filtroRazonSocial" maxlength="100"	<?php Varios::inputVerification('filtroReporteReservasRazonSocial');?>>
				</div>
				<label for="" class="col-form-label col-xs-12 col-xl-1">Número</label>
				<div class="col-xs-12 col-xl-2">
					<input class="form-control" placeholder="Número" type="text"
						id="txt_filtroNumero" name="txt_filtroNumero" maxlength="100"	<?php Varios::inputVerification('filtroReporteReservasNumero');?>>
				</div>
				<label for="" class="col-form-label col-xs-12 col-xl-1">Estado</label>
				<div class="col-xs-12 col-xl-2">
					<select name="cmb_filtroEstado" id="cmb_filtroEstado" class="form-control" >
						<option value="">Seleccione...</option><?php
						foreach ($estado_inf as $row) {?>
							<option value="<?php echo $row['para_UID'];?>"
                            	<?php Varios::selectVerification('filtroReporteReservasEstado', $row['para_UID']);?>><?php echo $row['para_nombre'];?>
                           </option><?php
						}?>
					</select>
				</div>
			</div>
			
		</div>
		<div class="col-xs-12 col-xl-2">
			<div class="col-xs-4" >
				<button type="button" class="btn btn-primary mr-2 mb-2" onclick="aplicarFiltro()">
					<i class="" style="font-size:15px;color:white;"></i>
					Buscar
				</button>
			</div>
			<div class="col-xs-4" >
				<button type="button" class="btn btn-default mr-2 mb-2" onclick="limpiarInformacion()">
					<i class="style="font-size:15px;color:black;"></i>
					Limpiar
				</button>
			</div>
			<div class="col-xs-4" >
				<button type="button" class="btn btn-primary mr-2 mb-2"  onclick="exportarExcel()">
					<i class="" style="font-size:15px;color:white;"></i>
					Excel
				</button>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-sm-12" >
			<div id='div_informacion'>

			</div>
		</div>
	</div>
		<?php
}?>