<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Parametros Reporte Movimiento de 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" src="../../js/validar.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>

</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 fldOtherNames is NULL then case when fldMiddleName is NULL then concat(fldLastName,', ',fldFirstName) else concat(fldLastName,' ',fldMiddleName,', ',fldFirstName) end else case when fldMiddleName is NULL then concat(fldLastName,', ',fldFirstName,' ',fldOtherNames) else concat(fldLastName,' ',fldMiddleName,', ',fldFirstName,' ',fldOtherNames) end 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;");

//tipo movimiento
$result6 = mysqli_query($link, "select pkyFixedAssetMovementType as cod_tipo, fldName as tipo
from 
fasFixedAssetMovementType
where 
sysEnabled = 1 and sysAuthorized = 1  
order by fldName;");

?>
<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 Movimiento de Activos Fijos</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>Tipo: </b></td><td><br/><!--<SELECT NAME="cliente" class="formulario">-->
<select data-placeholder="Seleccione..." class="chzn-select" style="width:300px;" NAME="tipo_mov">
	<option value="0">Todos</option>
	<?php 
	while ($row = mysqli_fetch_array($result6)) {   
	?> 
	<option value="<?php echo $row['cod_tipo']?>"><?php echo $row['cod_tipo']?> - <?php echo $row['tipo']?></option> 
	<?php 
	}  
	mysqli_free_result($result6);
	?>
    </select>
</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>
<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><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>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.
<br/><input type="radio" name="orden" value="3" class="formulario"> Fecha

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