<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Parametros Reporte Activos Fijos</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">
	$(document).ready(function(){
		$("#cbx_afelegido1").change(function () {

			$('#cbx_afelegido3').find('option').remove().end().append('<option value="0">Todos</option>').val('0');
			$('#cbx_afelegido4').find('option').remove().end().append('<option value="0">Todos</option>').val('0');
			
			$("#cbx_afelegido1 option:selected").each(function () {
				afelegido1 = $(this).val();
				$.post("afelegido1.php", { afelegido1: afelegido1 }, function(data){
					$("#cbx_afelegido2").html(data);
				});            
			});
		})
	});
	
	$(document).ready(function(){
		$("#cbx_afelegido2").change(function () {

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

			$("#cbx_afelegido2 option:selected").each(function () {
				afelegido2 = $(this).val();
				$.post("afelegido2.php", { afelegido2: afelegido2 }, function(data){
					$("#cbx_afelegido3").html(data);
				});            
			});
		})
	});

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

</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"> 
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('Pvariasfamilias');
}
</script>

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

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

<?php 
//Inicio reporte activos fijos

//listado de activos fijos (si sysAuthorized = 1 no tomar en cuenta, si sysEnabled = 1 and sysAuthorized = 1 esta activo el AF, si sysEnabled = 0 and sysAuthorized = 0 lo dieron de baja)
$result2 = mysqli_query($link, "select pkyFixedAsset as codigo, fldName as item, fldFactoryKey as cod_fabrica, fldAlternativeKey as cod_alt
from 
fasFixedAsset
where 
(sysEnabled = 1 and sysAuthorized = 1) or (sysEnabled = 0 and sysAuthorized = 0)
order by item;");

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

//listado de sucursales
$result4 = mysqli_query($link, "select pkyCompanyBranch as cod_sucursal, fldName as sucursal
from 
agnCompanyBranch 
where 
sysEnabled = 1 and sysAuthorized = 1
order by sucursal;");

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

//lista familia para varias
$result6 = mysqli_query($link, "select pkyFixedAssetCategory as cod_familia, fldName as familia
from fasFixedAssetCategory
where
fldLevel = 1 and
sysEnabled = 1 and sysAuthorized = 1 
order by familia;");



?>
<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 Activos Fijos</b></td></tr><tr><td>
<form id="miform" name="miform" method="post" action="report.php?rep=9&tipo=1">
<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 por Sucursal: </b></td><td> <br/><input type="radio" name="mostrarsuc" checked="checked" value="0" class="formulario"> No
<br/><input type="radio" name="mostrarsuc" value="1" class="formulario"> Si
</td></tr><tr><td>

<br/><b>Solo Consolidado: </b></td><td> <br/><input type="radio" name="consolidado" checked="checked" value="0" class="formulario"> No
<br/><input type="radio" name="consolidado" value="1" class="formulario"> Si
</td></tr><tr><td>

<br/><b>Seleccionar Varias<br />Familias: </b></td><td> 
<br/><input type="radio" name="varias_fam" checked="checked" value="0" class="formulario" onClick="oculta('Pvariasfamilias'), muestra('Pfamilias');"> No (Solo una o todas)
<br/><input type="radio" name="varias_fam" value="1" class="formulario" onClick="oculta('Pfamilias'), muestra('Pvariasfamilias');"> Si (Varias)
</td></tr><tr><td>

<br/><b>Activo Fijo:</b></td><td> <br/><!--<SELECT NAME="almacen" class="formulario">-->
<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="afijo">
	<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['cod_fabrica']?> - <?php echo $row['cod_alt']?> - <?php echo $row['item']?></option>  
	<?php 
	}  
	mysqli_free_result($result2);
	?>
    </select>    
    
</td></tr><tr><td>
<br/><b>Sucursal: </b></td><td> <br/><!--<SELECT NAME="vendedor" class="formulario">-->
<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="sucursal">
	<option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result4)) {   
	?> 
    
	<option value="<?php echo $row['cod_sucursal']?>"><?php echo $row['cod_sucursal']?> - <?php echo $row['sucursal']?></option> 
	<?php 
	}  
	mysqli_free_result($result4);
	?> 
    </select>
    
</td></tr><tr><td>
<br/><b>Responsable: </b></td><td> <br/><!--<SELECT NAME="vendedor" class="formulario">-->
<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="empleado">
	<option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result3)) {   
	?> 
    
	<option value="<?php echo $row['codigo']?>"><?php echo $row['codigo']?> - <?php echo $row['empleado']?></option> 
	<?php 
	}  
	mysqli_free_result($result3);
	?> 
    </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>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 colspan="2">
<table border="0" id="Pvariasfamilias">
<tr><td width="142">
<br/><b>Seleccionar varias<br />familias:</b></td><td> <br/>
	<?php 
	while ($row = mysqli_fetch_array($result6)) {   
	?> 
	<input type="checkbox" name="familia_seleccion[]" value="<?php echo $row['cod_familia']?>">&nbsp;<?php echo $row['cod_familia']?> - <?php echo $row['familia']?><br />
	<?php 
	}  
	mysqli_free_result($result6);
	?>
</td></tr>
</table>

</td></tr><tr><td colspan="2">
<table border="0" id="Pfamilias">
<tr><td width="142">
	<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_afelegido1">
		<?php 
		$query = "select pkyFixedAssetCategory as cod, fldName as categoria
		from
		fasFixedAssetCategory
		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_afelegido2" 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_afelegido3" 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_afelegido4" style="width:300px;" class="select-css">
	<option value="0">Todos</option>
	</select>
</td></tr>
</table>

</td></tr><tr><td>
<br/><b>Rango de Fechas: </b></td><td> <br/><input type="radio" name="anual" checked="checked" value="0" class="formulario"> A Fecha
<br/><input type="radio" name="anual" value="1" class="formulario"> Gesti&oacute;n Acumulada (mes - año)

</td></tr><tr><td>
<br/><b>A Fecha: </b></td><td> <br/><select name="mesfin" class="formulario"> 
<option value="1">Enero</option>
<option value="2">Febrero</option>
<option value="3">Marzo</option>
<option value="4">Abril</option>
<option value="5">Mayo</option>
<option value="6">Junio</option>
<option value="7">Julio</option>
<option value="8">Agosto</option>
<option value="9">Septiembre</option>
<option value="10">Octubre</option>
<option value="11">Noviembre</option>
<option value="12">Diciembre</option>
</select>
<input type="text" name="anofin" value="<?php echo $ano_ini; ?>" size="4" length="4" maxlength="4" title="aaaa"><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aaaa
</td></tr><tr><td>

<br/><b>Ordenado por: </b></td><td> <br/><input type="radio" name="orden" checked="checked" value="0" class="formulario"> Item
<br/><input type="radio" name="orden" value="1" class="formulario"> C&oacute;digo
<br/><input type="radio" name="orden" value="2" class="formulario"> Cod. Alt.

</td></tr><tr><td>
<br/><b>Mostrar: </b></td><td> 
<br/><input type="checkbox" name="fechaing_ver" value="1" checked="checked" class="formulario"> Fecha de Ingreso
<br/><input type="checkbox" name="valoring_ver" value="1" checked="checked" class="formulario"> Valor de Ingreso
<br/><input type="checkbox" name="acumulada_ver" value="1" checked="checked" class="formulario"> Depreciaci&oacute;n Acumulada
<br/><input type="checkbox" name="gestion_ver" value="1" checked="checked" class="formulario"> Depreciaci&oacute;n Gesti&oacute;n

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