<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Parametros Reporte Contratos de Veh&iacute;culos</title>
<link href="../../maincss.css" rel="stylesheet" type="text/css" />
<link href="../../chosen/chosen.css" rel="stylesheet" />
<link href="../../tcal.css" rel="stylesheet" type="text/css" />
<!--
<script language="javascript" src="js/jquery-1.3.min.js"></script>
-->
<script language="javascript" src="../../js/tcal.js" type="text/javascript"></script>
<script language="javascript" src="../../js/jquery-3.4.1.js"></script>
<script type="text/javascript" src="../../chosen/chosen.jquery.js"></script>
<script language="javascript" src="../../js/validar.js"></script>

<script language="javascript">
	$(document).ready(function(){
		$("#cbx_marcaelegido1").change(function () {
			$("#cbx_marcaelegido1 option:selected").each(function () {
				marcaelegido1 = $(this).val();
				$.post("marcaelegido1.php", { marcaelegido1: marcaelegido1 }, function(data){
					$("#cbx_marcaelegido2").html(data);
				});            
			});
		})
	});
</script>

<script language="javascript">
	$(document).ready(function(){
		$("#cbx_elegido1").change(function () {

			$('#cbx_elegido3').find('option').remove().end().append('<option value="0">Todos</option>').val('0');
			$('#cbx_elegido4').find('option').remove().end().append('<option value="0">Todos</option>').val('0');
			
			$("#cbx_elegido1 option:selected").each(function () {
				elegido1 = $(this).val();
				$.post("elegido1.php", { elegido1: elegido1 }, function(data){
					$("#cbx_elegido2").html(data);
				});            
			});
		})
	});
	
	$(document).ready(function(){
		$("#cbx_elegido2").change(function () {

			$('#cbx_elegido4').find('option').remove().end().append('<option value="0">Todos</option>').val('0');

			$("#cbx_elegido2 option:selected").each(function () {
				elegido2 = $(this).val();
				$.post("elegido2.php", { elegido2: elegido2 }, function(data){
					$("#cbx_elegido3").html(data);
				});            
			});
		})
	});

	$(document).ready(function(){
		$("#cbx_elegido3").change(function () {
			$("#cbx_elegido3 option:selected").each(function () {
				elegido3 = $(this).val();
				$.post("elegido3.php", { elegido3: elegido3 }, function(data){
					$("#cbx_elegido4").html(data);
				});            
			});
		})
	});

</script>

</head>
<?php

include "../../conn.php";
include "../../general.php";
include "../../token.php";

//$usuario = $_GET["user"];
?>
<body>

<?php 
//Inicio reporte Contratos de Vehiculos


//estado de contrato abierto, cerrado, etc
$result0 = mysqli_query($link, "select pkyVehicleContractStatus as cod_estado, fldName as estado
from
vhcVehicleContractStatus
where
sysEnabled = 1 AND sysAuthorized = 1 
order by fldName;");

//tipo de contrato stadard, larga duracion, etc.
$result1 = mysqli_query($link, "select pkyVehicleContractType as cod_tipo, fldName as tipo
from
vhcVehicleContractType
where
sysEnabled = 1 AND sysAuthorized = 1 
order by fldName;");

//listado de almacenes
$result2 = mysqli_query($link, "select pkyWarehouse as cod_alm, fldName as almacen
from
invWarehouse
where
sysEnabled = 1 AND sysAuthorized = 1 
order by fldName;");

//listado de clientes
$result3 = mysqli_query($link, "select pkyCompany as cod_cli, fldName as cliente
from
agnCompany
where
fldIsClient = 1 and 
sysEnabled = 1 AND sysAuthorized = 1 
order by fldName;");

//listado de vehiculos
$result4 = mysqli_query($link, "select a.pkyItem as cod_vehi, a.fldName as vehiculo, 
b.fldCarPlate as placa, b.fldCategory as cat
from
invItem a, vhcVehicleDetail b
where
a.codType = 4 and
a.pkyItem = b.codItem and
a.sysEnabled = 1 AND a.sysAuthorized = 1 
order by b.fldCategory, a.fldName;");

//listado de categoria
$result5 = mysqli_query($link, "SELECT distinct fldCategory as categoria 
from vhcVehicleDetail 
where 
sysEnabled = 1 and sysAuthorized = 1 
order by fldCategory;");

$fecha_hoy=date("Y-m-d");
$ano=date("Y");
$mes=date("m");
?>
<table border="0" align="left" width="100%" cellpadding="5">
<tr><td><b>Empresa: <?php echo $nombre_empresa; ?><br/>NIT: <?php echo $mi_nit; ?></b>
</td><td align="right"><b>Fecha: <?php echo date("Y-m-d"); ?><br/>Hora: <?php echo date("H:i:s"); ?><br/>Usuario: <?php echo $usuario; ?><br/>FH</b>
</td></tr></table><br/>
<table border="0" align="center" cellpadding="5"><tr><td colspan="2" align="center">
<b>Par&aacute;metros Reporte Contrato de Veh&iacute;culos</b></td></tr><tr><td>
<form id="miform" name="miform" method="post" action="report.php?rep=9&tipo=1" onsubmit="return Validar()">
<br/><b>Usuario: </b></td><td> <br/><input type="text" name="usuario" value="<?php echo $usuario; ?>" size="20" readonly="readonly" class="formulario" style="color:#999;">
<input type="hidden" name="token" value="<?php echo $token; ?>">
</td></tr><tr><td>

<br/><b>Mostrar solo<br />por facturar: </b></td><td> <br/><input type="radio" name="por_facturar" checked="checked" value="0" class="formulario"> No
<br/><input type="radio" name="por_facturar" value="1" class="formulario"> Si
</td></tr><tr><td>

<br/><b>Mostrar<br />contratos: </b></td><td> <br/><input type="radio" name="por_fecha" checked="checked" value="0" class="formulario"> Cuya fecha de registro est&eacute; en el periodo
<br/><input type="radio" name="por_fecha" value="1" class="formulario"> Cuya fecha de entrega est&eacute; en el periodo
<br/><input type="radio" name="por_fecha" value="2" class="formulario"> Cuyo rango de fechas de alquiler est&eacute; en el periodo
</td></tr><tr><td>

<br/><b>Estado:</b></td><td> <br/><SELECT NAME="estado" style="width:150px;" class="select-css">
	<option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result0)) {   
	?> 
	<option value="<?php echo $row['cod_estado']?>"><?php echo $row['estado']?></option> 
	<?php 
	}  
	mysqli_free_result($result0);
	?>
    </SELECT>
</td></tr><tr><td>
<br/><b>Tipo:</b></td><td> <br/><SELECT NAME="tipoc" style="width:150px;" class="select-css">
	<option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result1)) {   
	?> 
	<option value="<?php echo $row['cod_tipo']?>"><?php echo $row['tipo']?></option> 
	<?php 
	}  
	mysqli_free_result($result1);
	?>
	</SELECT>
</td></tr><tr><td>
<br/><b>Categor&iacute;a:</b></td><td> <br/><SELECT NAME="categoria" style="width:90px;" class="select-css">
	<option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result5)) {   
	?> 
	<option value="<?php echo $row['categoria']?>"><?php echo $row['categoria']?></option> 
	<?php 
	}  
	mysqli_free_result($result5);
	?>
	</SELECT>

</td></tr><tr><td>
<br/><b>Marca: </b></td><td> <br/><!--<SELECT NAME="familia" id="cbx_marcaelegido1" class="formulario">-->
<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="marca" id="cbx_marcaelegido1">
<?php
$query = "select pkyBrand as cod, fldName as marca 
from invBrand 
where 
sysEnabled = 1 and sysAuthorized = 1
order by fldName";
$resultado=$mysqli->query($query);
?>
<option value="0">Todos</option>
<?php while($row = $resultado->fetch_assoc()) { ?>
	<option value="<?php echo $row['cod']; ?>"><?php echo $row['cod'].' - '.$row['marca']; ?></option>
<?php } 
$resultado->close(); ?> 
</select>

</td></tr>

<tr><td width="135">
<br/><b>Modelo: </b></td><td> <br/><SELECT NAME="modelo" id="cbx_marcaelegido2" style="width:300px;" class="select-css">	
<option value="0">Todos</option>
</select>

</td></tr><tr><td>
<br/><b>Almac&eacute;n:</b></td><td> <br/><!--<SELECT NAME="almacen" class="formulario">-->
<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="almacen">
	<option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result2)) {   
	?> 
	<option value="<?php echo $row['cod_alm']?>"><?php echo $row['cod_alm']?> - <?php echo $row['almacen']?></option> 
	<?php 
	}  
	mysqli_free_result($result2);
	?>
    </select>    
</td></tr><tr><td>
<br/><b>Cliente:</b></td><td> <br/><!--<SELECT NAME="cliente" class="formulario">-->
<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="cliente">
	<option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result3)) {   
	?> 
	<option value="<?php echo $row['cod_cli']?>"><?php echo $row['cod_cli']?> - <?php echo $row['cliente']?></option> 
	<?php 
	}  
	mysqli_free_result($result3);
	?>
    </select>
    
</td></tr><tr><td>
<br/><b>Familia: </b></td><td> <br/><!--<SELECT NAME="familia" id="combo1" class="formulario">-->
	<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="familia" id="cbx_elegido1">
	<?php 
	$query = "select pkyItemCategory as cod, fldName as categoria
	from
	invItemCategory
	where
	fldLevel = 1 and
	sysEnabled = 1 and sysAuthorized = 1 
	order by categoria";
	$resultado=$mysqli->query($query);
	?>
	<option value="0">Todos</option>
	<?php while($row = $resultado->fetch_assoc()) { ?>
		<option value="<?php echo $row['cod']; ?>"><?php echo $row['cod'].' - '.$row['categoria']; ?></option>
	<?php } 
	$resultado->close(); ?> 
	</select>

	</td></tr><tr><td>
<br/><b>Sub Familia: </b></td><td> <br/><SELECT NAME="subfamilia" id="cbx_elegido2" style="width:300px;" class="select-css">	
<option value="0">Todos</option>
</select>
</td></tr><tr><td>

<br/><b>Grupo: </b></td><td> <br/><SELECT NAME="grupo" id="cbx_elegido3" style="width:300px;" class="select-css">	
<option value="0">Todos</option>
</select>
</td></tr><tr><td>

<br/><b>Sub Grupo: </b></td><td> <br/><SELECT NAME="subgrupo" id="cbx_elegido4" style="width:300px;" class="select-css">
<option value="0">Todos</option>
</select>

</td></tr><tr><td>

<br/><b>Veh&iacute;culo:</b></td><td> <br/><!--<SELECT NAME="vehiculo" class="formulario">-->
<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="vehiculo">
	<option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result4)) {   
	?> 
	<option value="<?php echo $row['cod_vehi']?>"><?php echo $row['cod_vehi']?> - <?php echo $row['cat']?> - <?php echo $row['vehiculo']?> - (<?php echo $row['placa']?>)</option> 
	<?php 
	}  
	mysqli_free_result($result4);
	?>
    </select>
</td></tr><tr><td>
<br/><b>De Fecha: </b></td><td> <br/><div><input type="text" id="fechaini" name="fechaini" value="<?php echo $fechaini_gest; ?>" length="10" maxlength="10" class="tcal" title="aaaa-mm-dd"> </div>aaaa-mm-dd
</td></tr><tr><td>
<br/><b>A Fecha: </b></td><td> <br/><div><input type="text" id="fechafin" name="fechafin" value="<?php echo $fecha_hoy; ?>" length="10" maxlength="10" class="tcal" title="aaaa-mm-dd"> </div>aaaa-mm-dd

</td></tr><tr><td>
<br/><b>Ordenado por: </b></td><td> <br/><input type="radio" name="orden" checked="checked" value="0" class="formulario"> Fecha
<br/><input type="radio" name="orden" value="1" class="formulario"> Contrato

</td></tr><tr><td>
<br/><b>Ver: </b></td><td> <br/><input type="checkbox" name="km_ver" value="1" class="formulario"> Km. Previo y Entrega
<br/><input type="checkbox" name="gas_ver" value="1" class="formulario"> Gasolina Previo y Entrega

</td></tr>
<tr><td colspan="2" align="center">
<br/><br/><INPUT TYPE="submit" VALUE="Generar Reporte" class="boton_generar"></td></tr>

<script type="text/javascript"> $(".chzn-select").chosen({no_results_text: "No se encontraron resultados con "}); $(".chzn-select-deselect").chosen({allow_single_deselect:true}); </script>
</form>
</table>

</body>
</html>
