<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Parametros Reporte Ventas por Cliente</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
	
//Inicio reporte ventas por cliente

//listado de vendedores
$result = mysqli_query($link, "select pkyPerson as codigo, case when fldMiddleName is NULL then concat(fldLastName,', ',fldFirstName) else concat(fldLastName,' ',fldMiddleName,', ',fldFirstName) end as vendedor
from agnPerson
where
fldIsEmployee = 1 and
fldCanSell = 1 and  
sysEnabled = 1 and sysAuthorized = 1
order by vendedor;");

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

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

//listado de tipos de nota de venta
$result3 = mysqli_query($link, "select pkySalesNoteType as codigo, fldName as tipo
from 
slsSalesNoteType
where
sysEnabled = 1 and sysAuthorized = 1
order by tipo;");

//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;");

//listado de local o punto de venta
$result5 = mysqli_query($link, "select pkySalesPlace as codigo, fldName as local
from slsSalesPlace
where
sysEnabled = 1 and sysAuthorized = 1
order by local;");

//listado de ciudad en base a los clientes
$result6 = mysqli_query($link, "select a.codCityLocation as codigo, b.fldName as ciudad
from
agnCompany a, regCity b
where
a.fldIsClient = 1 and 
a.codCityLocation = b.pkyCity and 
a.sysEnabled = 1 and a.sysAuthorized = 1 
group by codigo 
order by ciudad;");

//canal
$result7 = mysqli_query($link, "select pkyChannel as codigo, fldName as canal
from agnChannel 
where 
sysEnabled = 1 and sysAuthorized = 1
order by fldName;");

//lista contexto
$result8 = 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; ?><br/>F</b>
</td></tr></table><br/>
<table border="0" align="center" cellpadding="5"><tr><td colspan="2" align="center">
<b>Par&aacute;metros Reporte Ventas por Cliente</b></td></tr><tr><td>
<form id="miform" name="miform" method="post" action="report.php?rep=13&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>Asiento con CC: </b></td><td> <br/><input type="radio" name="asientocc" checked="checked" value="0" class="formulario"> No
<br/><input type="radio" name="asientocc" value="1" class="formulario"> Si
</td></tr><tr><td>

<br/><b>Tipo: </b></td><td> <br/><!--<SELECT NAME="tiponota" class="formulario">-->
<select data-placeholder="Seleccione..." class="chzn-select" style="width:150px;" NAME="tiponota">
	<option value="0">Todos</option>
    <?php 
	while ($row = mysqli_fetch_array($result3)) {   
	?> 
    
	<option value="<?php echo $row['codigo']?>"><?php echo $row['tipo']?></option> 
	<?php 
	}  
	mysqli_free_result($result3);
	?> 
    </SELECT>
</td></tr><tr><td>
<!--
<br/><b>Estado: </b></td><td> <br/><SELECT NAME="estado" class="formulario">
	<option value="0">Todos</option>
    <option value="1">Pendiente</option>
    <option value="2">Cobrado</option> 
</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($result2)) {   
	?> 
	<option value="<?php echo $row['codigo']?>"><?php echo $row['codigo']?> - <?php echo $row['cliente']?></option> 
	<?php 
	}  
	mysqli_free_result($result2);
	
	?>
    </select>
</td></tr><tr><td>

<br/><b>Canal (solo para empresas): </b></td><td><br/><!--<SELECT NAME="concepto_cobro" class="formulario">-->
	<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="canal_venta">
    <option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result7)) {   
	?> 
	<option value="<?php echo $row['codigo']?>"><?php echo $row['codigo']?> - <?php echo $row['canal']?></option> 
	<?php 
	}  
	mysqli_free_result($result7);
	?> 
    </select>
</td></tr><tr><td>

<br/><b>Vendedor: </b></td><td> <br/><!--<SELECT NAME="vendedor" class="formulario">-->
<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="vendedor">
	<option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result)) {   
	?> 
    
	<option value="<?php echo $row['codigo']?>"><?php echo $row['codigo']?> - <?php echo $row['vendedor']?></option> 
	<?php 
	}  
	mysqli_free_result($result);
	?> 
    </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>Punto o Local de venta: </b></td><td><br/><!--<SELECT NAME="local" class="formulario">-->
<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="local">
	<option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result5)) {   
	?> 
	<option value="<?php echo $row['codigo']?>"><?php echo $row['codigo']?> - <?php echo $row['local']?></option> 
	<?php 
	}  
	mysqli_free_result($result5);
	?>
    </select>
</td></tr><tr><td>

<br/><b>Ciudad: </b></td><td><br/><!--<SELECT NAME="ciudad" class="formulario">-->
<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="ciudad">
	<option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result6)) {   
	?> 
	<option value="<?php echo $row['codigo']?>"><?php echo $row['codigo']?> - <?php echo $row['ciudad']?></option> 
	<?php 
	}  
	mysqli_free_result($result6);
	?>
    </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($result8)) {   
	?> 
	<option value="<?php echo $row['cod_contexto']?>"><?php echo $row['cod_contexto']?> - <?php echo $row['contexto']?></option> 
	<?php 
	}  
	mysqli_free_result($result8);
	?> 
    </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 tambi&eacute;n en: </b></td><td> <br/>
<input name="otra_moneda" type="radio" value="0" checked="checked">Moneda original<br>
<?php 
while($row = mysqli_fetch_array($result1)){ 
 echo "<input name='otra_moneda' type='radio' value='".$row['codigo']."'> ".$row['moneda']."<br>";
 //if($row['codigo'] == 1) { $moneda_base = $row['moneda'];}
 } 
mysqli_free_result($result1);
	
	?>

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

<br/><b>Ordenado por: </b><br/>Solo si elije <br/>No Mostrar participaci&oacute;n</td><td> <br/><input type="radio" name="orden" checked="checked" value="0" class="formulario"> Cliente, Fecha, Vendedor
<br/><input type="radio" name="orden" value="1" class="formulario"> Nro. de Documento, Fecha, Cliente, Vendedor (Moneda original)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cliente, Nro. de Documento, Fecha, Vendedor
<br/><input type="radio" name="orden" value="2" class="formulario"> Nro. de Factura, Fecha, Cliente (Moneda original)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cliente, Nro. de Factura, Fecha, Vendedor
</td></tr><tr><td>

<br/><b>Mostrar detalle: </b><br/>Si elije Moneda original<br/>y No Mostrar Detalle,<br/>la informaci&oacute;n se<br/>mostrar&aacute; por defecto<br/>en <?php echo $nom_moneda_principal; ?></td><td> <br/><input type="radio" name="detalle" checked="checked" value="0" class="formulario"> Si Mostrar Detalle
<br/><input type="radio" name="detalle" value="1" class="formulario"> No Mostrar Detalle
</td></tr><tr><td>

<br/><b>Participaci&oacute;n en %: </b><br/>Si elije Moneda original,<br/>la informaci&oacute;n se<br/>mostrar&aacute; por defecto<br/>en <?php echo $nom_moneda_principal; ?> (excepto en No<br/>Mostrar participaci&oacute;n)</td><td> <br/><input type="radio" name="participacion" checked="checked" value="0" class="formulario"> No Mostrar participaci&oacute;n
<br/><input type="radio" name="participacion" value="1" class="formulario"> por Cliente
<br/><input type="radio" name="participacion" value="2" class="formulario"> por Tipo de Cliente
<br/><input type="radio" name="participacion" value="3" class="formulario"> por Rubro de Cliente
</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>
