<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Parametros Reporte Ordenes de Compra</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>
</head>
<?php

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

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

<?php

//listado de proveedores
$result2 = mysqli_query($link, "select pkyCompany as codigo, fldName as proveedor
from agnCompany
where
fldIsSupplier = 1 and
sysEnabled = 1 and sysAuthorized = 1
order by proveedor;");

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

//monedas para el reporte
$result1 = mysqli_query($link, "select pkyCurrency as codigo, fldName as moneda
from actCurrency
where
sysEnabled = 1 and sysAuthorized = 1;");

//estado de la OC
$result3 = mysqli_query($link, "select pkyPurchaseOrderStatus as codigo, fldName as estado 
from 
pchPurchaseOrderStatus 
where 
sysEnabled = 1 and sysAuthorized = 1 
order by fldName;");

//listado de ordenes de compra
$result6 = mysqli_query($link, "select a.pkyPurchaseOrder as cod_oc, a.fldDate as fecha, a.fldNumber as nro_doc, b.fldName as proveedor
from pchPurchaseOrder a, agnCompany b 
where 
a.codSupplier = b.pkyCompany and 
a.sysEnabled = 1 and a.sysAuthorized = 1 
order by a.pkyPurchaseOrder;");

//lista contexto
$result5 = mysqli_query($link, "select pkyContext as cod_contexto, fldName as contexto, codCostCenter as cod_cc 
from srvContext
where 
sysEnabled = 1 and sysAuthorized = 1;");


?>
<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; ?></b>
</td></tr></table><br/>
<table border="0" align="center" cellpadding="5"><tr><td colspan="2" align="center">
<b>Par&aacute;metros Reporte Ordenes de Compra</b></td></tr><tr><td>
<form id="miform" name="miform" method="post" action="report.php?rep=14&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>Estado: </b></td><td> <br/><SELECT NAME="estado" style="width:90px;" class="select-css">
	<option value="0">Todos</option>
    <?php 
	while ($row = mysqli_fetch_array($result3)) {   
	?> 
    
	<option value="<?php echo $row['codigo']?>"><?php echo $row['estado']?></option> 
	<?php 
	}  
	mysqli_free_result($result3);
	?> 
    </SELECT>
</td></tr><tr><td>

<br/><b>Orden de Compra: </b></td><td><br/><!-- <SELECT NAME="almacen" class="formulario"> -->
	<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="orden_compra">
	<option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result6)) {   
	?> 
	<option value="<?php echo $row['cod_oc']?>"><?php echo $row['cod_oc']?> - <?php echo $row['fecha']?> - <?php echo $row['nro_doc']?> - <?php echo $row['proveedor']?></option> 
	<?php 
	}  
	mysqli_free_result($result6);
	?>
    </SELECT>

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

<br/><b>Proveedor: </b></td><td><br/><!-- <SELECT NAME="proveedor" class="formulario"> -->
	<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="proveedor">
	<option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result2)) {   
	?> 
	<option value="<?php echo $row['codigo']?>"><?php echo $row['codigo']?> - <?php echo $row['proveedor']?></option> 
	<?php 
	}  
	mysqli_free_result($result2);
	?>
    </SELECT>

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

<br/><b>Almacen: </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($result4)) {   
	?> 
	<option value="<?php echo $row['codigo']?>"><?php echo $row['codigo']?> - <?php echo $row['almacen']?></option> 
	<?php 
	}  
	mysqli_free_result($result4);
	?>
    </SELECT>
</td></tr><tr><td>

<br/><b>Contexto: </b></td><td> <br/><!--<SELECT NAME="concepto_pago" class="formulario">-->
	<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="contexto">
    <option value="-1">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result5)) {   
	?> 
	<option value="<?php echo $row['cod_contexto']?>"><?php echo $row['cod_contexto']?> - <?php echo $row['contexto']?></option> 
	<?php 
	}  
	mysqli_free_result($result5);
	?> 
    </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>Valorar en: </b></td><td> <br/>
<?php 
$i = 1;
while($row = mysqli_fetch_array($result1)){ 
 if($i == 1) {
 echo "<input name='otra_moneda' type='radio' checked='checked' value='".$row['codigo']."'> ".$row['moneda']."<br>";
 $i++;
 } else {
 echo "<input name='otra_moneda' type='radio' value='".$row['codigo']."'> ".$row['moneda']."<br>";	 } 
}
mysqli_free_result($result1);
	
	?>
</td></tr><tr><td>
<br/><b>Ordenado por: </b></td><td> <br/><input type="radio" name="ordenar" checked="checked" value="0" class="formulario"> Fecha
<br/><input type="radio" name="ordenar" value="1" class="formulario"> Nro. Documento
<br/><input type="radio" name="ordenar" value="2" class="formulario"> Proveedor
<br/><input type="radio" name="ordenar" value="3" class="formulario"> C&oacute;digo

</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>
