<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Parametros Reporte Movimientos de Caja</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"> 
 
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 funcion */
/* "Mandamos como parametro el nombre de la Div para ocultar" */
muestra('Pconcepto'); /*Ocultamos Pmoral*/
muestra('Pfechaini');
}
</script>

</head>
<?php
include "../../conn.php";
include "../../general.php";
include "../../token.php";

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

<?php 
//Inicio reporte movimientos de caja

//verificar el tipo de usuario 3 es normal (solo sus cajas)
$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 && $ver_caja == 1) { 
	$valor_caja = ' a.codUser = '.$cod_usuario.' and ';
	$variable_caja = 1;
} else {
	$valor_caja = ' ';
	$variable_caja = 0;
}

//listado de cajas
$result = mysqli_query($link, "select a.pkyPettyCash as cod_caja, a.fldName as caja, a.txtDescription as descripcion, b.fldLogin as usuario, c.fldName as ciudad
from
ptcPettyCash a, accUser b, regCity c
where 
$valor_caja 
a.codUser = b.pkyUser and
a.codCity = c.pkyCity and
a.sysEnabled = 1 and a.sysAuthorized = 1
order by caja;");

//listado de conceptos
$result2 = mysqli_query($link, "select pkyPettyCashMovementTypeConcept as cod_con, fldName as nombre
from
ptcPettyCashMovementTypeConcept
where
sysEnabled = 1 and sysAuthorized = 1
order by nombre;");

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

//lista contexto
$result3 = 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 Movimientos de Caja</b></td></tr><tr><td>
<form id="miform" name="miform" method="post" action="report.php?rep=11&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>Caja: </b></td><td> <br/><!--<SELECT NAME="caja" class="formulario">-->
<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="caja">
	<?php if($variable_caja == 0) { ?> 
    <option value="0">Todos</option>
    <?php } ?>
    <!--<option value="">----------------------</option>-->
    <?php 
	while ($row = mysqli_fetch_array($result)) {   
	?> 
	<option value="<?php echo $row['cod_caja']?>"><?php echo $row['cod_caja']?> - <?php echo $row['caja']?> (<?php echo $row['ciudad']?>)</option> 
	<?php 
	}  
	mysqli_free_result($result);
	?> 
    </SELECT>
    </td></tr><tr><td>
    <br/><b>Solo saldos: </b></td><td> <br/><input type="radio" name="solo_saldos" checked="checked" value="0" class="formulario" onClick="muestra('Pconcepto'); muestra('Pfechaini')"> No
<br/><input type="radio" name="solo_saldos" value="1" class="formulario" onClick="oculta('Pconcepto'); oculta('Pfechaini')"> Si

	</td></tr><tr><td colspan="2">
    <table border="0" id="Pconcepto">
	<tr><td width="85">
    <br/><b>Concepto: </b></td><td> <br/><!--<SELECT NAME="concepto" class="formulario">-->
    <select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="concepto">
	<option value="0">Todos</option>
    <!--<option value="">----------------------</option>
    <option value="-1">Egreso a Banco</option>-->
    <?php 
	while ($row = mysqli_fetch_array($result2)) {   
	?> 
    <option value="<?php echo $row['cod_con']?>"><?php echo $row['cod_con']?> - <?php echo $row['nombre']?></option> 
	<?php 
	}  
	mysqli_free_result($result2);
	
	?>
	</SELECT>
    </td></tr>
	</table>
    </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($result3)) {   
	?> 
	<option value="<?php echo $row['cod_contexto']?>"><?php echo $row['cod_contexto']?> - <?php echo $row['contexto']?></option> 
	<?php 
	}  
	mysqli_free_result($result3);
	?> 
    </select>

    
	</td></tr><tr><td colspan="2">
    <table border="0" id="Pfechaini">
	<tr><td width="85">
	<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>
	</table>
    </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/>
<input name='otra_moneda' type='radio' checked='checked' value='0'>Moneda original<br/>
<?php 
$i = 1;
while($row = mysqli_fetch_array($result1)){ 
 if($i == 1) {
 echo "<input name='otra_moneda' type='radio' 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="orden" checked="checked" value="0" class="formulario"> Fecha
<br/><input type="radio" name="orden" value="1" class="formulario"> C&oacute;digo

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