<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Pantalla Reporte Movimiento de Activos Fijos</title>
<link href="../../maincss.css" rel="stylesheet" type="text/css" />
<link href="../../printcss.css" rel="stylesheet" type="text/css" media="print" />

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

$rep=$_GET["rep"];
$tipo=$_GET["tipo"];

$tipo_mov=$_POST["tipo_mov"];
$afijo=$_POST["afijo"];
$sucursal=$_POST["sucursal"];
$empleado=$_POST["empleado"];
$marca=$_POST["marca"];
$modelo=$_POST["modelo"];
$familia=$_POST["familia"];
$subfamilia=$_POST["subfamilia"];
$grupo=$_POST["grupo"];
$subgrupo=$_POST["subgrupo"];
$orden=$_POST["orden"];
$usuario=$_POST["usuario"];
$fechaini=$_POST["fechaini"];
$fechafin=$_POST["fechafin"];
$cod_contexto=$_POST["contexto"];

/*
$afijo_det=$_GET["afijo_det"];
$fechafin_det=$_GET["fechafin_det"];
$usuario_det=$_GET["usuario_det"];
*/

if($familia == '') { $familia = 0;}
if($subfamilia == '') { $subfamilia = 0;}
if($grupo == '') { $grupo = 0;}
if($subgrupo == '') { $subgrupo = 0;}

if($marca == '') { $marca = 0;}
if($modelo == '') { $modelo = 0;}

$n_decimales = 2;


?>
<body>
<?php


//Inicio reporte movimiento activos fijos

if($rep == 9 && $tipo == 1) { // if 2
	
	if($afijo == 0) { 
		$nom_afijo = 'Todos';
		$valor_afijo = ' ';
	} else {
		$resultaf = mysqli_query($link, "select pkyFixedAsset as cod, fldName as item, fldFactoryKey as cod_fabrica, fldAlternativeKey as cod_alt
							from 
							fasFixedAsset
							where
							pkyFixedAsset = '$afijo' and 
							sysEnabled = 1 and sysAuthorized = 1;");
		while ($row = mysqli_fetch_array($resultaf)) {
			$nom_afijo = $row['cod'].' - '.$row['cod_fabrica'].' - '.$row['cod_alt'].' - '.$row['item'];
		}
		mysqli_free_result($resultaf);
		$valor_afijo = ' e.codFixedAsset = ' .$afijo. ' and ';
	}
	
	
	if($sucursal == 0) { 
		$nom_sucursal = 'Todos';
		$valor_sucursal = ' ';
	} else {
		$resultsuc = mysqli_query($link, "select pkyCompanyBranch as cod_sucursal, fldName as sucursal
							from 
							agnCompanyBranch
							where
							pkyCompanyBranch = '$sucursal' and 
							sysEnabled = 1 and sysAuthorized = 1;");
		while ($row = mysqli_fetch_array($resultsuc)) {
			$nom_sucursal = $row['sucursal'];
		}
		mysqli_free_result($resultsuc);
		$valor_sucursal = ' e.codBranch = ' .$sucursal. ' and ';
	}
	
	
	if($empleado == 0) { 
		$nom_empleado = 'Todos';
		$valor_empleado = ' ';
	} else {
		$resultemp = 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
							pkyPerson = '$empleado' and 
							sysEnabled = 1 and sysAuthorized = 1;");
		while ($row = mysqli_fetch_array($resultemp)) {
			$nom_empleado = $row['codigo'].' - '.$row['empleado'];
		}
		mysqli_free_result($resultemp);
		$valor_empleado = ' e.codPerson = ' .$empleado. ' and ';
	}
	
	
	if ($familia == 0) { // if familia
		$nom_familia = 'Todos';
		$valor_familia = ' ';
	} else {
		//nombre familia
		$resultfam = mysqli_query($link, "select pkyFixedAssetCategory as cod, fldName as nombre
							from 
							fasFixedAssetCategory
							where
							pkyFixedAssetCategory = '$familia' and 
							sysEnabled = 1 and sysAuthorized = 1;");
		while ($row = mysqli_fetch_array($resultfam)) {
			$nom_familia = $row['nombre'];
		}
		mysqli_free_result($resultfam);
		$valor_familia = ' a.codFamily = ' .$familia. ' and ';
	} //fin if familia

if ($subfamilia == 0) { // if subfamilia
		$nom_subfamilia = 'Todos';
		$valor_subfamilia = ' ';
	} else {
		//nombre sub familia
		$resultsubf = mysqli_query($link, "select pkyFixedAssetCategory as cod, fldName as nombre
							from 
							fasFixedAssetCategory
							where
							pkyFixedAssetCategory = '$subfamilia' and 
							sysEnabled = 1 and sysAuthorized = 1;");
		while ($row = mysqli_fetch_array($resultsubf)) {
			$nom_subfamilia = $row['nombre'];
		}
		mysqli_free_result($resultsubf);
		$valor_subfamilia = ' a.codSubFamily = ' .$subfamilia. ' and ';
	} //fin if subfamilia
	
if ($grupo == 0) { // if grupo
		$nom_grupo = 'Todos';
		$valor_grupo = ' ';
	} else {
		//nombre grupo
		$resultgru = mysqli_query($link, "select pkyFixedAssetCategory as cod, fldName as nombre
							from 
							fasFixedAssetCategory
							where
							pkyFixedAssetCategory = '$grupo' and 
							sysEnabled = 1 and sysAuthorized = 1;");
		while ($row = mysqli_fetch_array($resultgru)) {
			$nom_grupo = $row['nombre'];
		}
		mysqli_free_result($resultgru);
		$valor_grupo = ' a.codGroup = ' .$grupo. ' and ';
	} //fin if grupo
	
if ($subgrupo == 0) { // if subgrupo
		$nom_subgrupo = 'Todos';
		$valor_subgrupo = ' ';
	} else {
		//nombre sub grupo
		$resultsubg = mysqli_query($link, "select pkyFixedAssetCategory as cod, fldName as nombre
							from 
							fasFixedAssetCategory
							where
							pkyFixedAssetCategory = '$subgrupo' and 
							sysEnabled = 1 and sysAuthorized = 1;");
		while ($row = mysqli_fetch_array($resultsubg)) {
			$nom_subgrupo = $row['nombre'];
		}
		mysqli_free_result($resultsubg);
		$valor_subgrupo = ' a.codSubGroup = ' .$subgrupo. ' and ';
	} //fin if subgrupo
	
	if ($marca == 0) { // if marca
		$nom_marca = 'Todos';
		$valor_marca = ' ';
	} else {
		//nombre marca
		$result5 = mysqli_query($link, "select pkyBrand as cod, fldName as marca 
								from invBrand 
								where 
								pkyBrand = '$marca' and 
								sysEnabled = 1 and sysAuthorized = 1;");
		while ($row = mysqli_fetch_array($result5)) {
			$nom_marca = $row['marca'];
		}
		mysqli_free_result($result5);
		$valor_marca = ' a.codBrand = ' .$marca. ' and ';
	} //fin if marca
	
	if ($modelo == 0) { // if modelo
		$nom_modelo = 'Todos';
		$valor_modelo = ' ';
	} else {
		//nombre modelo
		$result6 = mysqli_query($link, "select pkyBrandModel as cod, fldName as modelo 
								from invBrandModel 
								where 
								pkyBrandModel = '$modelo' and 
								sysEnabled = 1 and sysAuthorized = 1;");
		while ($row = mysqli_fetch_array($result6)) {
			$nom_modelo = $row['modelo'];
		}
		mysqli_free_result($result6);
		$valor_modelo = ' a.codBrandModel = ' .$modelo. ' and ';
	} //fin if modelo
	
	//contexto
if($cod_contexto == -1){ 
	$nom_contexto = 'Todos';
	//$valor_contexto = ' ';
	$valor_contexto2 = ' ';
} else {
	$resultcontx = mysqli_query($link, "select pkyContext as cod_contexto, fldName as contexto, codCostCenter as cod_cc 
	from srvContext
	where 
	pkyContext = '$cod_contexto';");
		while ($row = mysqli_fetch_array($resultcontx)) {   
			$nom_contexto = $row['cod_contexto'].' - '.$row['contexto'];
		}
		mysqli_free_result($resultcontx);
	//$valor_contexto = ' a.sysContext = '.$cod_contexto.' and '; //se quito de depreciacion y actualizacion, para que no cruce ya qu ela dep y act se hace en conjunto	
	$valor_contexto2 = ' e.sysContext = '.$cod_contexto.' and ';	
}

if ($tipo_mov == 0) { // if tipo
	$nom_tipo_mov = 'Todos';
	$valor_tipo_mov = ' ';
} else {
	//nombre sucursal
	$result7 = mysqli_query($link, "select pkyEmployeeMovementType as cod_tipo, fldName as tipo
							from 
							hrsEmployeeMovementType
							where
							pkyEmployeeMovementType = '$tipo_mov' and 
							sysEnabled = 1 and sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($result7)) {
		$nom_tipo_mov = $row['tipo'];
	}
	mysqli_free_result($result7);
	$valor_tipo_mov = ' e.codType = ' .$tipo_mov. ' and ';
} //fin if tipo	
	
	if ($orden == 0) { // if 2.11
		$nom_orden = 'Item';
		$valor_orden = ' order by a.fldName, e.fldDate, f.fldName ';
	} //fin if 2.11
	if ($orden == 1) { // if 2.12
		$nom_orden = 'C&oacute;digo';
		$valor_orden = ' order by e.codFixedAsset, e.fldDate, f.fldName ';
	} //fin if 2.12
	if ($orden == 2) { // if 2.13
		$nom_orden = 'Cod. Alt.';
		$valor_orden = ' order by a.fldAlternativeKey, e.fldDate, f.fldName ';
	} //fin if 2.13
	if ($orden == 3) { // if 2.14
		$nom_orden = 'Fecha';
		$valor_orden = ' order by e.fldDate, f.fldName ';
	} //fin if 2.14
	

//listado de movimiento activos fijos 	
$result4 = mysqli_query($link, "select e.pkyFixedAssetMovement as cod_mov, e.fldDocumentNumber as nro_doc, e.codType as cod_tipo, f.fldName as tipo, e.codFixedAsset as cod_af, a.fldFactoryKey as cod_fabrica, a.fldAlternativeKey as cod_alt, a.fldName as afijo, a.codFamily as cod_familia, b.fldName as familia, a.codSubFamily as cod_subfamilia, a.codGroup as cod_grupo, a.codSubGroup as cod_subgrupo, a.codBrand as cod_marca, a.codBrandModel as cod_modelo, e.codPreviousPerson as cod_emp_ant, e.codPerson as cod_emp, case when c.fldOtherNames is NULL then case when c.fldMiddleName is NULL then concat(c.fldLastName,', ',c.fldFirstName) else concat(c.fldLastName,' ',c.fldMiddleName,', ',c.fldFirstName) end else case when c.fldMiddleName is NULL then concat(c.fldLastName,', ',c.fldFirstName,' ',c.fldOtherNames) else concat(c.fldLastName,' ',c.fldMiddleName,', ',c.fldFirstName,' ',c.fldOtherNames) end end as empleado, e.codPreviousBranch as cod_suc_ant, e.codBranch as cod_suc, d.fldName as sucursal, e.codExchangeRate as cod_tc, e.fldValue as valor, e.fldDate as fecha_mov, b.fldDepreciationTime as meses_dep, e.codAccountEntry as cod_asiento, e.codItem as cod_item_cargado, e.codItemMovement as cod_mov_merc, e.txtDescription as glosa, a.fldIncomingDate as fecha_compra
from 
fasFixedAsset a, fasFixedAssetCategory b, agnPerson c, agnCompanyBranch d, fasFixedAssetMovement e, fasFixedAssetMovementType f
where  
$valor_afijo 
$valor_sucursal 
$valor_empleado 
$valor_familia 
$valor_subfamilia 
$valor_grupo 
$valor_subgrupo 
$valor_marca 
$valor_modelo 
$valor_contexto2 
$valor_tipo_mov 
a.codFamily = b.pkyFixedAssetCategory and 
e.codPerson = c.pkyPerson and 
e.codBranch = d.pkyCompanyBranch and 
a.pkyFixedAsset = e.codFixedAsset and 
e.codType = f.pkyFixedAssetMovementType and 
e.fldDate >= '$fechaini' and 
e.fldDate <= '$fechafin' and 
e.sysEnabled = 1 and e.sysAuthorized = 1 
$valor_orden;");

$mat_af = array();
$i = 1;
while ($row = mysqli_fetch_array($result4)) {
	$mat_af [$i][1] = $row['cod_mov'];
	$mat_af [$i][2] = $row['nro_doc'];
	$mat_af [$i][3] = $row['cod_tipo'];
	$mat_af [$i][4] = $row['tipo'];
	$mat_af [$i][5] = $row['cod_af'];
	$mat_af [$i][6] = $row['cod_fabrica'];
	$mat_af [$i][7] = $row['cod_alt'];
	$mat_af [$i][8] = $row['afijo'];
	$mat_af [$i][9] = $row['cod_familia'];
	$mat_af [$i][10] = $row['familia'];
	$mat_af [$i][11] = $row['cod_subfamilia'];
	$mat_af [$i][12] = NULL;//subfamilia
	$mat_af [$i][13] = $row['cod_grupo'];
	$mat_af [$i][14] = NULL;//grupo
	$mat_af [$i][15] = $row['cod_subgrupo'];
	$mat_af [$i][16] = NULL;//sub grupo
	$mat_af [$i][17] = $row['cod_marca'];
	$mat_af [$i][18] = NULL;//marca
	$mat_af [$i][19] = $row['cod_modelo'];
	$mat_af [$i][20] = NULL;//modelo
	$mat_af [$i][21] = $row['cod_emp_ant'];
	$mat_af [$i][22] = NULL;//empleado anterior
	$mat_af [$i][23] = $row['cod_emp'];
	$mat_af [$i][24] = $row['empleado'];
	$mat_af [$i][25] = $row['cod_suc_ant'];
	$mat_af [$i][26] = NULL;//sucursal anterior
	$mat_af [$i][27] = $row['cod_suc'];
	$mat_af [$i][28] = $row['sucursal'];
	$mat_af [$i][29] = $row['cod_tc'];
	$mat_af [$i][30] = $row['valor'];
	$mat_af [$i][31] = $row['fecha_mov'];
	$mat_af [$i][32] = $row['meses_dep'];
	$mat_af [$i][33] = $row['cod_asiento'];
	$mat_af [$i][34] = $row['cod_item_cargado'];
	$mat_af [$i][35] = $row['cod_mov_merc'];
	$mat_af [$i][36] = $row['fecha_compra'];
	$mat_af [$i][37] = $row['glosa'];
	
	$cod_af = $mat_af [$i][5];
	$cod_subf = $mat_af [$i][11];
	$cod_grupo = $mat_af [$i][12];
	$cod_subgr = $mat_af [$i][13];
	$cod_marca = $mat_af [$i][14];
	$cod_modelo = $mat_af [$i][15];
	$cod_suc_ant = $mat_af [$i][19];
	$cod_emp_ant = $mat_af [$i][21];
	
	//nombre sub familia
	$resultsubf = mysqli_query($link, "select pkyFixedAssetCategory as cod, fldName as nombre
						from 
						fasFixedAssetCategory
						where
						pkyFixedAssetCategory = '$cod_subf' and 
						sysEnabled = 1 and sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($resultsubf)) {
		$mat_af [$i][12] = $row['nombre'];
	}
	mysqli_free_result($resultsubf);
	
	//nombre grupo
	$resultgrupo = mysqli_query($link, "select pkyFixedAssetCategory as cod, fldName as nombre
						from 
						fasFixedAssetCategory
						where
						pkyFixedAssetCategory = '$cod_grupo' and 
						sysEnabled = 1 and sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($resultgrupo)) {
		$mat_af [$i][14] = $row['nombre'];
	}
	mysqli_free_result($resultgrupo);
	
	//nombre sub grupo
	$resultsubgr = mysqli_query($link, "select pkyFixedAssetCategory as cod, fldName as nombre
						from 
						fasFixedAssetCategory
						where
						pkyFixedAssetCategory = '$cod_subgr' and 
						sysEnabled = 1 and sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($resultsubgr)) {
		$mat_af [$i][16] = $row['nombre'];
	}
	mysqli_free_result($resultsubgr);
	
	//nombre marca
	$result5 = mysqli_query($link, "select pkyBrand as cod, fldName as marca 
							from invBrand 
							where 
							pkyBrand = '$cod_marca' and 
							sysEnabled = 1 and sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($result5)) {
		$mat_af [$i][18] = $row['marca'];
	}
	mysqli_free_result($result5);
	
	//nombre modelo
	$result6 = mysqli_query($link, "select pkyBrandModel as cod, fldName as modelo 
							from invBrandModel 
							where 
							pkyBrandModel = '$cod_modelo' and 
							sysEnabled = 1 and sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($result6)) {
		$mat_af [$i][20] = $row['modelo'];
	}
	mysqli_free_result($result6);
	
	//empleado anterior
	$result42 = 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 
pkyPerson = '$cod_emp_ant' and 
sysEnabled = 1 and sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($result42)) {
		$mat_af [$i][22] = $row['empleado'];
	}
	mysqli_free_result($result42);
	
	//sucursal anterior
	$result42 = mysqli_query($link, "select pkyCompanyBranch as cod_suc, fldName as sucursal, fldID as id
from 
agnCompanyBranch
where 
pkyCompanyBranch = '$cod_suc_ant' and 
sysEnabled = 1 and sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($result42)) {
		$mat_af [$i][26] = $row['sucursal'];
	}
	mysqli_free_result($result42);
	
	$i++;
}
$fin_af = $i - 1;
mysqli_free_result($result4);


?>
<table border="0" align="left" width="100%" cellpadding="5">
<tr><td><?php echo $mostrar_logo_reportes; ?>
</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; ?></b>
</td></tr></table>
<p><br /><center><font color="#000099" size="+1"><b>Reporte Movimiento de Activos Fijos</b></font></center></p>
<table border="0" cellpadding="2" align="center" width="100%">
<tr>
<td>	
    <table border="1" align="center" cellpadding="2" width="100%">
        <TR>
        <TD width="25%"><b>Tipo: </b><?php echo $nom_tipo_mov; ?></TD> 
        <TD width="25%"><b>Activo Fijo: </b><?php echo $nom_afijo; ?></TD>
        <TD width="25%"><b>Sucursal: </b><?php echo $nom_sucursal; ?></TD>
        <TD width="25%"><b>Responsable: </b><?php echo $nom_empleado; ?></TD>
        </TR>
        <TR>
        <TD><b>Familia: </b><?php echo $nom_familia; ?></TD>
        <TD><b>Sub Familia: </b><?php echo $nom_subfamilia; ?></TD>
        <TD><b>Grupo: </b><?php echo $nom_grupo; ?></TD>
        <TD><b>Sub Grupo: </b><?php echo $nom_subgrupo; ?></TD>
        </TR>
        <TR>
        <TD><b>Marca: </b><?php echo $nom_marca; ?></TD>
        <TD><b>Modelo: </b><?php echo $nom_modelo; ?></TD>
        <TD><b>Ordenado por: </b><?php echo $nom_orden; ?></TD>
        <TD><b>Contexto: </b><?php echo $nom_contexto; ?></TD>
        </TR>
        <TR>
        <TD colspan="2"><b>De Fecha: </b><?php echo $fechaini; ?> <b>a Fecha: </b><?php echo $fechafin; ?></TD>
        <TD colspan="2"><b>Expresado en: </b><?php echo $nom_moneda_principal; ?></TD>
        </TR>
    </table>

</td>
<!--
<td valign="top" width="150">

    <table border="1" align="center" cellpadding="2" width="100%">
    <tr>
    <TD><b>Tipo de Cambio:</b></TD>
    </tr><tr>
    <TD align="center"><a href="../../ModuleAccounting/VoucherExchangeRate/index.php?pkyExchangeRate=<?php echo $ultimo_tc; ?>&user=<?php echo $usuario; ?>" title="Tipo de Cambio"><?php echo $ultimo_tc; ?></a> (<?php echo $tc_fecha; ?> - <?php echo $tc_hora; ?>)<br/ >
        <table border="0" cellpadding="2" align="center">
            <?php
            for($m = 1; $m <= $fin_m; $m++) {
            printf("<tr><td align='left'>1 %s</td>", $ma_tc [$m][1]);//moneda base
            printf("<td align='center'>%s</td>", ' = ');//letra a
            printf("<td align='left'>%s %s</td>", number_format($ma_tc [$m][3],$n_tipocambio), $ma_tc [$m][2]);//moneda target y tasa
            //printf("<td align='right'>%s</td></tr>", number_format($ma_tc [$m][3],$n_tipocambio));//tasa
            }
            ?>
        </table>
    </TD>
    </tr>
	</table>
    
</td>
-->
</tr>
</table>
<br />
<table border="1" align="center" cellpadding="2" width="100%">
    <thead>
    <TR> 
    <TD align="center"><b>Cod.</b></TD>
    <TD align="center"><b>Nro. Doc.</b></TD>
    <TD align="center" width="65"><b>Fecha</b></TD>
    <TD align="center"><b>Tipo</b></TD>
    <TD align="center"><b>Cod. Item</b></TD>
    <TD align="center"><b>Cod. Fab.</b></TD>
    <TD align="center"><b>Cod. Alt.</b></TD>
    <TD align="center"><b>Item</b></TD>
    <TD align="center"><b>Responsable Ant.</b></TD>
    <TD align="center"><b>Sucursal Ant.</b></TD>
    <TD align="center"><b>Responsable</b></TD>
    <TD align="center"><b>Sucursal</b></TD>
    <TD align="center"><b>Familia</b></TD>
    <TD align="center"><b>Sub Familia</b></TD>
    <TD align="center"><b>Grupo</b></TD>
    <TD align="center"><b>Sub Grupo</b></TD>
    <TD align="center"><b>Marca</b></TD>
    <TD align="center"><b>Modelo</b></TD>
    <TD align="center"><b>Dep. (Meses)</b></TD>
    <TD align="center"><b>Asiento</b></TD>
    <TD align="center" width="65"><b>Fecha Compra</b></TD>
    <TD align="center"><b>Valor Compra</b></TD>
    </TR>
    </thead>
    <tbody class="marcafila">
    
  <?php
  $color = 2;
    
  $suma_valor_compra = 0; 
  
  $i = 1;
  while ($i <= $fin_af) { //while
  $cod_afijo = $mat_af [$i][5];
  $cod_mov_afijo = $mat_af [$i][1];
  $cod_asiento = $mat_af [$i][33];
  
	if($color % 2 == 0) { //if color
		printf("<tr BGCOLOR='#e2e7fa'><td align='center'><a href='../../ModuleFixedAssets/VoucherFixedAssetMovement/index.php?pkyFixedAssetMovement=$cod_mov_afijo&user=$usuario' title='Nota de Movimiento de Activo Fijo'>%s</a></td>", $mat_af [$i][1]);//cod
	} else {
		printf("<tr><td align='center'><a href='../../ModuleFixedAssets/VoucherFixedAssetMovement/index.php?pkyFixedAssetMovement=$cod_mov_afijo&user=$usuario' title='Movimiento de Activo Fijo'>%s</a></td>", $mat_af [$i][1]);//cod
	}//fin if color
	
	printf("<td align='left'>%s</td>", $mat_af [$i][2]);//nro doc
	printf("<td align='center'>%s</td>", $mat_af [$i][31]);//fecha mov
	printf("<td align='left'>%s</td>", $mat_af [$i][4]);//tipo
	printf("<td align='left'><a href='../../ModuleFixedAssets/VoucherFixedAsset/index.php?pkyFixedAsset=$cod_afijo&user=$usuario' title='Activo Fijo'>%s</a></td>", $mat_af [$i][5]);//cod item
	printf("<td align='left'>%s</td>", $mat_af [$i][6]);//cod fabrica
	printf("<td align='left'>%s</td>", $mat_af [$i][7]);//cod alterno
	printf("<td align='left'>%s</td>", $mat_af [$i][8]);//item
	printf("<td align='left'>%s</td>", $mat_af [$i][22]);//resp anterior
	printf("<td align='left'>%s</td>", $mat_af [$i][26]);//suc anterior
	printf("<td align='left'>%s</td>", $mat_af [$i][24]);//responsable
	printf("<td align='left'>%s</td>", $mat_af [$i][28]);//sucursal
	printf("<td align='left'>%s</td>", $mat_af [$i][10]);//familia
	printf("<td align='left'>%s</td>", $mat_af [$i][12]);//sub familia
	printf("<td align='left'>%s</td>", $mat_af [$i][14]);//grupo
	printf("<td align='left'>%s</td>", $mat_af [$i][16]);//sub grupo
	printf("<td align='left'>%s</td>", $mat_af [$i][18]);//marca
	printf("<td align='left'>%s</td>", $mat_af [$i][20]);//modelo
	
	printf("<td align='right'>%s</td>", number_format($mat_af [$i][32],0));//dep meses
	printf("<td align='center'><a href='../../ModuleAccounting/VoucherAccountEntry/index.php?pkyAccountEntry=$cod_asiento&showCC=0&user=$usuario' title='Asiento Contable'>%s</a></td>", $mat_af [$i][33]);//asiento
	printf("<td align='center'>%s</td>", $mat_af [$i][36]);//fecha compra
	printf("<td align='right'>%s</td></tr>", number_format($mat_af [$i][30],$n_decimales));//valor compra
	 
	$suma_valor_compra = $suma_valor_compra + $mat_af [$i][30];

	$color++;
	$i++;
  }//fin while
	
?>
<tr BGCOLOR="#ffcccc"><td colspan="21"><b>Total General</b></td>
<td align="right"><?php printf("<b>%s</b>", number_format($suma_valor_compra,$n_decimales)); ?></td>
</tr>
</tbody>
</table>
<?php

} //fin if 2

?>

