<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Parametros Reporte Inventario Valorado</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_itemelegido1").change(function () {
			$("#cbx_itemelegido1 option:selected").each(function () {
				itemelegido1 = $(this).val();
				$.post("itemelegido1.php", { itemelegido1: itemelegido1 }, function(data){
					$("#cbx_itemelegido2").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>

<script language="JavaScript"> 
function oculta(id){
	 var elDiv = document.getElementById(id); //se define la variable "elDiv" igual a nuestro div
	 elDiv.style.display='none'; //damos un atributo display:none que oculta el div	 
	}
 
function muestra(id){
	 var elDiv = document.getElementById(id); //se define la variable "elDiv" igual a nuestro div
	 elDiv.style.display='block';//damos un atributo display:block que  el div	 
	}
 
window.onload = function(){/*hace que se cargue la función */
/* "Mandamos como parametro el nombre de la Div para ocultar" */
oculta('Pfamilia');
oculta('Pnrodoc');
}
</script>

</head>
<?php

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

//$usuario = $_GET["user"];

//verificar el tipo de usuario 3 es normal (no ve el costo)
$resultuser = mysqli_query($link, "select pkyUser as cod_user, codType as cod_tipo 
from accUser
where fldLogin = '$usuario' and
sysEnabled = 1 and sysAuthorized = 1;");
		
while ($row = mysqli_fetch_array($resultuser)) {
$cod_usuario = $row['cod_user'];
$cod_tipo_usuario = $row['cod_tipo'];
}
mysqli_free_result($resultuser);

if($cod_tipo_usuario == 3 && $imprime_costo == 0) { 
	$ver_costo = 0;
} else {
	$ver_costo = 1;
}

?>
<body>

<?php 
//Inicio reporte inventario valorado

//moneda de almacenes
$result0 = mysqli_query($link, "select a.pkyCurrency as codigo, a.fldName as moneda
from actCurrency a, invInventoryConfig b
where
a.pkyCurrency = b.codCurrency and
a.sysEnabled = 1 and a.sysAuthorized = 1;");
		
	while ($row = mysqli_fetch_array($result0)) {
	$nom_moneda = $row['moneda'];
	$cod_moneda = $row['codigo'];
	}
	mysqli_free_result($result0);

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

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

//listado de conceptos de mov de mercaderia
$result3 = mysqli_query($link, "select a.pkyItemMovementTypeConcept as cod_concepto, a.fldName as concepto, b.fldName as tipo
from invItemMovementTypeConcept a, invItemMovementType b 
where 
a.codItemMovementType = b.pkyItemMovementType and 
a.sysEnabled = 1 and a.sysAuthorized = 1 
order by a.codItemMovementType, a.fldName;");

//lista de precios
$result4 = mysqli_query($link, "select a.pkyPriceList as cod_lista, a.fldName as lista, b.fldName as moneda
from 
slsPriceList a, actCurrency b
where
a.codCurrency = b.pkyCurrency and 
a.sysEnabled = 1 and a.sysAuthorized = 1
order by lista;");

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

//listado de empresas
$result6 = mysqli_query($link, "select pkyCompany as codigo, fldName as empresa
from agnCompany
where
sysEnabled = 1 and sysAuthorized = 1
order by empresa;");

//listado de cuentas contables ligadas al almacen
$result7 = mysqli_query($link, "select distinct a.codAccount as cod_cuenta, b.fldName as cuenta 
from invWarehouse a, actAccount b
where 
a.codAccount = b.pkyAccount and 
b.sysEnabled = 1 and b.sysAuthorized = 1 
order by cod_cuenta, cuenta;");

//listado de items
/*
$result = mysqli_query($link, "select a.pkyItem as codigo, a.fldName as item, b.fldName as tipo
from invItem a, invItemType b
where
a.codType = b.pkyItemType and
a.sysEnabled = 1 and a.sysAuthorized = 1
order by a.fldName;");
*/

/*
Para el nro de documento
select pkyItemMovement, fldDocumentNumber from 
invitemmovement 
where upper(fldDocumentNumber) like upper('%2%')
order by pkyItemMovement
*/
?>
<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 Inventario Valorado, Moneda Original Base <?php echo $nom_moneda; ?></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 Lotes: </b></td><td> 
<br/><input type="radio" name="mostrar_lotes" checked="checked" value="0" class="formulario"> No
<br/><input type="radio" name="mostrar_lotes" value="1" class="formulario"> Si

</td></tr><tr><td>
<br/><b>Items agrupados: </b></td><td> 
<br/><input type="radio" name="agrupar_items" value="0" class="formulario" onClick="muestra('Pnrodoc'); "> No (Tipo Kardex, Activa Fitro Num. Doc.)
<br/><input type="radio" name="agrupar_items" checked="checked" value="1" class="formulario" onClick="oculta('Pnrodoc');"> Si (Por Item)
<br/><input type="radio" name="agrupar_items" value="2" class="formulario" onClick="oculta('Pnrodoc');"> Si (Por Familia)
<br/><input type="radio" name="agrupar_items" value="3" class="formulario" onClick="oculta('Pnrodoc');"> Si (Por Sub Familia)
<br/><input type="radio" name="agrupar_items" value="4" class="formulario" onClick="oculta('Pnrodoc');"> Si (Por Grupo)
<br/><input type="radio" name="agrupar_items" value="5" class="formulario" onClick="oculta('Pnrodoc');"> Si (Por Sub Grupo)

</td></tr><tr><td colspan="2">
<table border="0" id="Pnrodoc">
<tr><td width="180">
<br/><b>Nro. Documento: </b></td><td> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="num_doc" value="Todos" size="30" class="formulario"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Solo funciona en Tipo Kardex
</td></tr>
</table>
</td></tr><tr><td>

<br/><b>Mostrar todos<br />los almacenes: </b></td><td> 
<br/><input type="radio" name="mostrar_todo_alm" checked="checked" value="0" class="formulario"> No (Consolidado)
<br/><input type="radio" name="mostrar_todo_alm" value="1" class="formulario"> Si (Items en cada almacen)

</td></tr><tr><td>
<br/><b>Cuenta Contable<br /> del Almac&eacute;n:</b></td><td> <br/><!--<SELECT NAME="almacen" class="formulario">-->
	<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="cuenta_almacen">
    <option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result7)) {   
	?> 
	<option value="<?php echo $row['cod_cuenta']?>"><?php echo $row['cod_cuenta']?> - <?php echo $row['cuenta']?></option> 
	<?php 
	}  
	mysqli_free_result($result7);
	?>
    </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['pkyWarehouse']?>"><?php echo $row['pkyWarehouse']?> - <?php echo $row['fldName']?></option> 
	<?php 
	}  
	mysqli_free_result($result2);
	?>
    </select>
</td></tr><tr><td>

<br/><b>Empresa: </b></td><td><br/><!--<SELECT NAME="cliente" class="formulario">-->
	<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="empresa">
	<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['empresa']?></option> 
	<?php 
	}  
	mysqli_free_result($result6);
	
	?>
    </select>
</td></tr><tr><td>

<br/><b>Concepto:</b></td><td> <br/><!--<SELECT NAME="almacen" class="formulario">-->
	<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="concepto">
    <option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result3)) {   
	?> 
	<option value="<?php echo $row['cod_concepto']?>"><?php echo $row['cod_concepto']?> - <?php echo $row['concepto']?> (<?php echo $row['tipo']?>)</option> 
	<?php 
	}  
	mysqli_free_result($result3);
	?>
    </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>Mostrar saldos en cero: </b></td><td> 
<br/><input type="radio" name="mostrar_saldo_cero" value="0" class="formulario"> Si
<br/><input type="radio" name="mostrar_saldo_cero" checked="checked" value="1" class="formulario"> No

</td></tr><tr><td>
<br/><b>Mostrar solo<br />cantidades: </b></td><td> 
<?php if($ver_costo == 1) { ?>
<br/><input type="radio" name="mostrar_cant" checked="checked" value="0" class="formulario"> No
<br/><input type="radio" name="mostrar_cant" value="1" class="formulario"> Si
<?php } else { ?>
<br/><input type="radio" name="mostrar_cant" checked="checked" value="1" class="formulario"> Si
<?php } ?> 
</td></tr><tr><td>
<br/><b>Lista de Precio: <br /> Solo (Por Item)</b></td><td> <br/><!--<SELECT NAME="almacen" class="formulario">-->
	<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="lista_precio">
	<?php 
	while ($row = mysqli_fetch_array($result4)) {   
	?> 
	<option value="<?php echo $row['cod_lista']?>"><?php echo $row['cod_lista']?> - <?php echo $row['lista']?> (<?php echo $row['moneda']?>)</option> 
	<?php 
	}  
	mysqli_free_result($result4);
	?>
    </select>
</td></tr><tr><td>
<br/><b>Mostrar por: </b></td><td> 
<br/><input type="radio" name="mostrar" checked="checked" value="0" class="formulario" onClick="muestra('Pitem'); oculta('Pfamilia')"> Rango de Items
<br/><input type="radio" name="mostrar" value="1" class="formulario" onClick="muestra('Pfamilia'); oculta('Pitem')"> Familia
</td></tr><tr><td colspan="2">
<table border="0" id="Pitem">
<tr><td width="210">

<br/><b>Item inicial: </b></td><td> <br/><!--<SELECT NAME="cuentaini" id="combo1" class="formulario">-->
<select data-placeholder="Seleccione..." class="chzn-select" style="width:450px;" NAME="itemini" id="cbx_itemelegido1">
<?php
$query = "select pkyItem as cod, fldName as item, fldFactoryKey as cod_fabrica
from
invItem
where
sysEnabled = 1 and sysAuthorized = 1 
order by cod";
$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['cod_fabrica'].' - '.$row['item']; ?></option>
<?php } 
$resultado->close(); ?> 
</select>

</td></tr><tr><td>
<br/><b>Item final: </b></td><td> <br/><SELECT NAME="itemfin" id="cbx_itemelegido2" style="width:450px;" class="select-css">	
<option value="0">Todos</option>
</select>
</td></tr>
</table>

</td></tr><tr><td colspan="2">
<table border="0" id="Pfamilia">
<tr><td width="140">

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

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

<br/><b>Ordenado por: </b></td><td> <br/><input type="radio" name="orden" checked="checked" value="0" class="formulario"> Item (Nombre)
<br/><input type="radio" name="orden" value="1" class="formulario"> Item (C&oacute;digo)
<br/><input type="radio" name="orden" value="2" class="formulario"> Item (C&oacute;digo de F&aacute;brica)
<br/><input type="radio" name="orden" value="3" class="formulario"> Familia (C&oacute;digo)

</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>";
 } 
mysqli_free_result($result1);
	
	?>
</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>Mostrar (solo para <br/>Items agrupados, <br/>Tipo Kardex y <br/>Por Item): </b></td><td> 
<br/><input type="checkbox" name="codfab_ver" value="1" class="formulario"> C&oacute;digo de F&aacute;brica
<br/><input type="checkbox" name="familia_ver" value="1" class="formulario"> Familia
<br/><input type="checkbox" name="subfamilia_ver" value="1" class="formulario"> Sub Familia
<br/><input type="checkbox" name="grupo_ver" value="1" class="formulario"> Grupo
<br/><input type="checkbox" name="subgrupo_ver" value="1" class="formulario"> Sub Grupo
<br/><input type="checkbox" name="tipo_ver" value="1" class="formulario"> Tipo
<br/><input type="checkbox" name="umen_ver" value="1" class="formulario"> Unidad Menor
<br/><input type="checkbox" name="glosa_ver" value="1" class="formulario"> Glosa
<br/><input type="checkbox" name="empresa_ver" value="1" class="formulario"> Empresa (Detalle)

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