<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Pantalla Reporte Bonos y Descuentos</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";
include "../../token.php";

//$usuario=$_POST["usuario"];
$rep=$_GET["rep"];
$tipo=$_GET["tipo"];
$agrupado=$_POST["agrupado"];
$bod=$_POST["bod"];
$modalidad=$_POST["modalidad"];
$empleado=$_POST["empleado"];
$genero=$_POST["genero"];
$cargo=$_POST["cargo"];
$cod_contexto=$_POST["contexto"];
$mesini=$_POST["mesini"];
$anoini=$_POST["anoini"];
$mesfin=$_POST["mesfin"];
$anofin=$_POST["anofin"];
$orden=$_POST["orden"];

//$mostrar_asiento_cc = $_GET["showCC"];

$n_decimales = 2;

?>
<body>

<?php


//Inicio reporte bonos y descuentos

if($rep == 9 && $tipo == 1) { // if 2

//agrupado
if ($agrupado == 0) { 
	$nom_agrupado = 'No';
} else {
	$nom_agrupado = 'Si';
}

//bono descuento
if ($bod == 0) { // if bod
	$nom_bod = 'Todos';
	$valor_bod = ' ';
} else { //else bod
	if ($bod == -1) { // if -1
		$nom_bod = 'Bonos';
		$valor_bod = ' c.fldIsDiscount = 0 and ';
	} else { //else if -1
		if ($bod == -2) { // if -2
		$nom_bod = 'Descuentos';
		$valor_bod = ' c.fldIsDiscount = 1 and ';
		} else { //else if -2 
			//nombre bono descuento
			$result4 = mysqli_query($link, "select pkyBonusDiscountConcept as cod_bondes, fldName as nombre, fldIsDiscount as cod_bod, case when fldIsDiscount = 0 then 'Bono' else 'Descuento' end as bod
						from hrsBonusDiscountConcept 
						where 
						pkyBonusDiscountConcept = '$bod' and 
						sysEnabled = 1 and sysAuthorized = 1;");
			while ($row = mysqli_fetch_array($result4)) {
				$nom_bod = $row['cod_bondes'].' - '.$row['nombre'].' ('.$row['bod'].')';
			}
			mysqli_free_result($result4);
			$valor_bod = ' b.codConcept = ' .$bod. ' and ';
		} //fin if -2
	} //fin if -1
} //fin if bod

if ($modalidad == -1) { 
	$nom_modalidad = 'Todos';
	$valor_modalidad = ' ';
} 
if ($modalidad == 0) { 
	$nom_modalidad = 'Fijo';
	$valor_modalidad = ' c.fldIsFixed = ' .$modalidad. ' and ';
}
if ($modalidad == 1) { 
	$nom_modalidad = 'Variable';
	$valor_modalidad = ' c.fldIsFixed = ' .$modalidad. ' and ';
}



//empleado
if ($empleado == 0) { //if empleado
    $valor_empleado = ' ';
	$nom_empleado = 'Todos';
  } else { 
    $valor_empleado = ' b.codEmployee = '.$empleado.' and ';
	//nombre de empleado
	$resultemp = 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
				pkyPerson = '$empleado' and 
				sysEnabled = 1 and sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($resultemp)) {
	$nom_empleado = $row['codigo'].' - '.$row['empleado'];
	}
	mysqli_free_result($resultemp);
} //fin if empleado


//genero
if ($genero == 0) { // if genero
	$nom_genero = 'Todos';
	$valor_genero = ' ';
} else {
	//nombre genero
	$result3 = mysqli_query($link, "select pkyGender as cod_gen, fldName as genero
							from 
							agnGender
							where
							pkyGender = '$genero' and 
							sysEnabled = 1 and sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($result3)) {
		$nom_genero = $row['genero'];
	}
	mysqli_free_result($result3);
	$valor_genero = ' d.codGender = ' .$genero. ' and ';
} //fin if genero


//cargo
if ($cargo == 0) { // if cargo
	$nom_cargo = 'Todos';
	$valor_cargo = ' ';
} else {
	//nombre cargo
	$result5 = mysqli_query($link, "select pkyJob as cod_cargo, fldName as cargo
							from 
							hrsJob
							where
							pkyJob = '$cargo' and 
							sysEnabled = 1 and sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($result5)) {
		$nom_cargo = $row['cargo'];
	}
	mysqli_free_result($result5);
	$valor_cargo = ' d.codJob = ' .$cargo. ' and ';
} //fin if cargo


//contexto
if($cod_contexto == -1) { // if contexto
	$nom_contexto = 'Todos';
	$valor_contexto = ' ';
} 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 ';	
} //fin if contexto


if ($orden == 0) { 
	$nom_orden = 'Nombre';
	$valor_orden = 'order by bono_descuento, es_bod, periodo, empleado';
} 
if ($orden == 1) { 
	$nom_orden = 'Modalidad';
	$valor_orden = 'order by es_fijovar, es_bod, bono_descuento, periodo, empleado';
}
if ($orden == 2) { 
	$nom_orden = 'Empleado';
	$valor_orden = 'order by empleado, es_bod, bono_descuento, periodo';
}
if ($orden == 3) { 
	$nom_orden = 'G&eacute;nero';
	$valor_orden = 'order by cod_sexo desc, es_bod, bono_descuento, empleado, periodo';
}
/*
if ($orden == 4) { 
	$nom_orden = 'Cargo';
	$valor_orden = 'order by cod_cargo, es_bod, bono_descuento, empleado, periodo';
}
*/

$nom_mesini = nombreMes($mesini);
$nom_mesfin = nombreMes($mesfin);

$vfechaini =  $anoini.'-'.$mesini.'-01';
$vfechafin =  $anofin.'-'.$mesfin.'-31';


//agrupado NO
if($agrupado == 0) {//if agrupado 0

$result = mysqli_query($link, "select a.pkyBonusDiscount as cod_bondes, a.fldDocumentNumber as nro_doc, a.fldDate as fecha, a.fldPeriod as periodo, b.codEmployee as cod_empleado, case when d.fldOtherNames is NULL then case when d.fldMiddleName is NULL then concat(d.fldLastName,', ',d.fldFirstName) else concat(d.fldLastName,' ',d.fldMiddleName,', ',d.fldFirstName) end else case when d.fldMiddleName is NULL then concat(d.fldLastName,', ',d.fldFirstName,' ',d.fldOtherNames) else concat(d.fldLastName,' ',d.fldMiddleName,', ',d.fldFirstName,' ',d.fldOtherNames) end end as empleado, b.codConcept as cod_conceptobd, c.fldName as bono_descuento, b.fldAmount as monto, c.fldIsFixed as es_fijovar, c.fldIsDiscount as es_bod, d.codGender as cod_sexo, d.codJob as cod_cargo
from hrsBonusDiscount a, hrsBonusDiscountDetail b, hrsBonusDiscountConcept c, agnPerson d
where 
$valor_bod 
$valor_modalidad 
$valor_empleado 
$valor_genero 
$valor_cargo
$valor_contexto 
a.pkyBonusDiscount = b.codBonusDiscount and 
b.codConcept = c.pkyBonusDiscountConcept and 
b.codEmployee = d.pkyPerson and 
a.fldDate >= '$vfechaini' and 
a.fldDate <= '$vfechafin' and 
a.sysEnabled = 1 and a.sysAuthorized = 1
$valor_orden;");


$matriz_bod = array();
$i = 1;
while ($row = mysqli_fetch_array($result)) {
	$matriz_bod [$i][1] = $row['cod_bondes'];
	$matriz_bod [$i][2] = $row['nro_doc'];
	$matriz_bod [$i][3] = $row['fecha'];
	$matriz_bod [$i][4] = $row['periodo'];
	$matriz_bod [$i][5] = $row['cod_empleado'];
	$matriz_bod [$i][6] = $row['empleado'];
	$matriz_bod [$i][7] = $row['cod_conceptobd'];
	$matriz_bod [$i][8] = $row['bono_descuento'];
	$matriz_bod [$i][9] = $row['monto'];
	$matriz_bod [$i][10] = $row['es_fijovar'];
	$matriz_bod [$i][11] = $row['es_bod'];
	$matriz_bod [$i][12] = $row['cod_sexo'];
	$matriz_bod [$i][13] = $row['cod_cargo'];
	

	
	$cod_cargo = $matriz_bod [$i][13];
	//cargo
	$resultcargo = mysqli_query($link, "select pkyJob as cod_cargo, fldName as cargo
							from 
							hrsJob
							where
							pkyJob = '$cod_cargo';");
	while ($row = mysqli_fetch_array($resultcargo)) {   
		$matriz_bod [$i][14] = $row['cargo'];
	}
	mysqli_free_result($resultcargo);
	
	if($matriz_bod [$i][10] == 0) {
		$matriz_bod [$i][15] = 'Fijo';
	} else {
		$matriz_bod [$i][15] = 'Variable';
	}
	
	if($matriz_bod [$i][11] == 0) {
		$matriz_bod [$i][16] = 'Bono';
	} else {
		$matriz_bod [$i][16] = 'Descuento';
	}
	
	if($matriz_bod [$i][12] == 1) {
		$matriz_bod [$i][17] = 'Masculino';
	} else {
		$matriz_bod [$i][17] = 'Femenino';
	}
	
	$i++;
}
$fin = $i - 1;
mysqli_free_result($result);

$total_bono_desc = 0;

?>
<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 Bonos y Descuentos</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="33%"><b>Bono/Descuento: </b><?php echo $nom_bod; ?></TD>
        <TD width="33%"><b>Modalidad: </b><?php echo $nom_modalidad; ?></TD>
        <TD width="33%"><b>Empleado: </b><?php echo $nom_empleado; ?></TD>
        </TR>
        <TR> 
        <TD><b>Genero: </b><?php echo $nom_genero; ?></TD>
        <TD><b>Cargo: </b><?php echo $nom_cargo; ?></TD>
        <TD><b>Ordenado por: </b><?php echo $nom_orden; ?></TD>
        </TR>
        <TR>
        <TD><b>Mes A&ntilde;o Inicial: </b><?php echo $nom_mesini; ?> de <?php echo $anoini; ?></TD>
        <TD><b>Mes A&ntilde;o Final: </b><?php echo $nom_mesfin; ?> de <?php echo $anofin; ?></TD>
        <TD><b>Expresado en: </b><?php echo $nom_moneda_principal; ?></TD>
        </TR>
        <TR>
        <TD><b>Agrupado por Concepto: </b><?php echo $nom_agrupado; ?></TD>
        <TD colspan="2"><b>Contexto: </b><?php echo $nom_contexto; ?></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; ?>&token=<?php echo $token; ?>" 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>Concepto</b></TD>
    <TD align="center"><b>Bono / Descuento</b></TD>
    <TD align="center"><b>Modalidad</b></TD>
    <TD align="center"><b>Cod. Bon. Desc.</b></TD>
    <TD align="center"><b>Fecha</b></TD>
    <TD align="center"><b>Periodo</b></TD>
    <TD align="center"><b>Empleado</b></TD>
    <TD align="center"><b>Sexo</b></TD>
    <TD align="center"><b>Cargo</b></TD>
    <TD align="center"><b>Monto</b></TD>
    </TR>
    </thead>
    <tbody class="marcafila">

<?php
$color = 2;
$j = 1;
$suma_bod = 0;



	while ($j <= $fin) { //while
	
	//$cod_emp = $matriz_bod [$j][2];
	
    if($color % 2 == 0) { //if color
	printf("<tr BGCOLOR='#e2e7fa'><td align='center'>%s</td>", $matriz_bod [$j][7]);//cod
	} else {
	printf("<tr><td align='center'>%s</td>", $matriz_bod [$j][7]);//cod
	}//fin if color
    
	printf("<td align='left'>%s</td>", $matriz_bod [$j][8]);//concepto
	printf("<td align='left'>%s</td>", $matriz_bod [$j][16]);//bono/descuento
	printf("<td align='left'>%s</td>", $matriz_bod [$j][15]);//modalidad
	printf("<td align='center'>%s %s</td>", $matriz_bod [$j][1], $matriz_bod [$j][2]);//cod planilla bono/descuento y nro doc
	printf("<td align='center'>%s</td>", $matriz_bod [$j][3]);//fecha
	printf("<td align='center'>%s</td>", substr($matriz_bod [$j][4],0,7));//periodo
	$texto = $matriz_bod [$j][6];//empleado
	$texto = strtr(strtoupper($texto), "àáâãäåæçèéêëìíîïðñòóôõöøùüú", "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÜÚ");
	//$texto = substr($texto,0,150);
	printf("<td align='left'>%s</td>", $texto);//empleado
	printf("<td align='left'>%s</td>", $matriz_bod [$j][17]);//sexo
	printf("<td align='left'>%s</td>", $matriz_bod [$j][14]);//cargo
	printf("<td align='right'>%s</td></tr>", number_format($matriz_bod [$j][9],$n_decimales));//monto
	
	$suma_bod = $suma_bod+$matriz_bod [$j][9];
	$color++;
	$j++;
  
	} //fin while
?>
 
<tr BGCOLOR='#ffcccc'><td colspan="10"><b>Total</b></td>
<td align="right"><?php printf("<b>%s</b>", number_format($suma_bod,$n_decimales)); ?></td>
</tr>
</tbody>
</table>

<?php	
}// fin if agrupado 0


//agrupado SI
if($agrupado == 1) {//if agrupado 1

$result = mysqli_query($link, "select a.pkyBonusDiscount as cod_bondes, a.fldDocumentNumber as nro_doc, a.fldDate as fecha, a.fldPeriod as periodo, b.codEmployee as cod_empleado, case when d.fldOtherNames is NULL then case when d.fldMiddleName is NULL then concat(d.fldLastName,', ',d.fldFirstName) else concat(d.fldLastName,' ',d.fldMiddleName,', ',d.fldFirstName) end else case when d.fldMiddleName is NULL then concat(d.fldLastName,', ',d.fldFirstName,' ',d.fldOtherNames) else concat(d.fldLastName,' ',d.fldMiddleName,', ',d.fldFirstName,' ',d.fldOtherNames) end end as empleado, b.codConcept as cod_conceptobd, c.fldName as bono_descuento, sum(b.fldAmount) as monto, c.fldIsFixed as es_fijovar, c.fldIsDiscount as es_bod, d.codGender as cod_sexo, d.codJob as cod_cargo
from hrsBonusDiscount a, hrsBonusDiscountDetail b, hrsBonusDiscountConcept c, agnPerson d
where 
$valor_bod 
$valor_modalidad 
$valor_empleado 
$valor_genero 
$valor_cargo
$valor_contexto 
a.pkyBonusDiscount = b.codBonusDiscount and 
b.codConcept = c.pkyBonusDiscountConcept and 
b.codEmployee = d.pkyPerson and 
a.fldDate >= '$vfechaini' and 
a.fldDate <= '$vfechafin' and 
a.sysEnabled = 1 and a.sysAuthorized = 1
group by c.fldName
$valor_orden;");


$matriz_bod = array();
$i = 1;
while ($row = mysqli_fetch_array($result)) {
	$matriz_bod [$i][1] = $row['cod_bondes'];
	$matriz_bod [$i][2] = $row['nro_doc'];
	$matriz_bod [$i][3] = $row['fecha'];
	$matriz_bod [$i][4] = $row['periodo'];
	$matriz_bod [$i][5] = $row['cod_empleado'];
	$matriz_bod [$i][6] = $row['empleado'];
	$matriz_bod [$i][7] = $row['cod_conceptobd'];
	$matriz_bod [$i][8] = $row['bono_descuento'];
	$matriz_bod [$i][9] = $row['monto'];
	$matriz_bod [$i][10] = $row['es_fijovar'];
	$matriz_bod [$i][11] = $row['es_bod'];
	$matriz_bod [$i][12] = $row['cod_sexo'];
	$matriz_bod [$i][13] = $row['cod_cargo'];
	

	
	$cod_cargo = $matriz_bod [$i][13];
	//cargo
	$resultcargo = mysqli_query($link, "select pkyJob as cod_cargo, fldName as cargo
							from 
							hrsJob
							where
							pkyJob = '$cod_cargo';");
	while ($row = mysqli_fetch_array($resultcargo)) {   
		$matriz_bod [$i][14] = $row['cargo'];
	}
	mysqli_free_result($resultcargo);
	
	if($matriz_bod [$i][10] == 0) {
		$matriz_bod [$i][15] = 'Fijo';
	} else {
		$matriz_bod [$i][15] = 'Variable';
	}
	
	if($matriz_bod [$i][11] == 0) {
		$matriz_bod [$i][16] = 'Bono';
	} else {
		$matriz_bod [$i][16] = 'Descuento';
	}
	
	if($matriz_bod [$i][12] == 1) {
		$matriz_bod [$i][17] = 'Masculino';
	} else {
		$matriz_bod [$i][17] = 'Femenino';
	}
	
	$i++;
}
$fin = $i - 1;
mysqli_free_result($result);

$total_bono_desc = 0;

?>
<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 Bonos y Descuentos</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="33%"><b>Bono/Descuento: </b><?php echo $nom_bod; ?></TD>
        <TD width="33%"><b>Modalidad: </b><?php echo $nom_modalidad; ?></TD>
        <TD width="33%"><b>Empleado: </b><?php echo $nom_empleado; ?></TD>
        </TR>
        <TR> 
        <TD><b>Genero: </b><?php echo $nom_genero; ?></TD>
        <TD><b>Cargo: </b><?php echo $nom_cargo; ?></TD>
        <TD><b>Ordenado por: </b><?php echo $nom_orden; ?></TD>
        </TR>
        <TR>
        <TD><b>Mes A&ntilde;o Inicial: </b><?php echo $nom_mesini; ?> de <?php echo $anoini; ?></TD>
        <TD><b>Mes A&ntilde;o Final: </b><?php echo $nom_mesfin; ?> de <?php echo $anofin; ?></TD>
        <TD><b>Expresado en: </b><?php echo $nom_moneda_principal; ?></TD>
        </TR>
        <TR>
        <TD><b>Agrupado por Concepto: </b><?php echo $nom_agrupado; ?></TD>  
        <TD colspan="3"><b>Contexto: </b><?php echo $nom_contexto; ?></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; ?>&token=<?php echo $token; ?>" 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>Concepto</b></TD>
    <TD align="center"><b>Bono / Descuento</b></TD>
    <TD align="center"><b>Modalidad</b></TD>
    <TD align="center"><b>Monto</b></TD>
    </TR>
    </thead>
    <tbody class="marcafila">

<?php
$color = 2;
$j = 1;
$suma_bod = 0;



	while ($j <= $fin) { //while
	
	//$cod_emp = $matriz_bod [$j][2];
	
    if($color % 2 == 0) { //if color
	printf("<tr BGCOLOR='#e2e7fa'><td align='center'>%s</td>", $matriz_bod [$j][7]);//cod
	} else {
	printf("<tr><td align='center'>%s</td>", $matriz_bod [$j][7]);//cod
	}//fin if color
    
	printf("<td align='left'>%s</td>", $matriz_bod [$j][8]);//concepto
	printf("<td align='left'>%s</td>", $matriz_bod [$j][16]);//bono/descuento
	printf("<td align='left'>%s</td>", $matriz_bod [$j][15]);//modalidad
	printf("<td align='right'>%s</td></tr>", number_format($matriz_bod [$j][9],$n_decimales));//monto
	
	$suma_bod = $suma_bod+$matriz_bod [$j][9];
	$color++;
	$j++;
  
	} //fin while
?>
 
<tr BGCOLOR='#ffcccc'><td colspan="4"><b>Total</b></td>
<td align="right"><?php printf("<b>%s</b>", number_format($suma_bod,$n_decimales)); ?></td>
</tr>
</tbody>
</table>

<?php	
}// fin if agrupado 1

}// fin if 2
?>


</body>
</html>
