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

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

$tipo_mov=$_POST["tipo_mov"];
$empleado=$_POST["empleado"];
$genero=$_POST["genero"];
$ciudad=$_POST["ciudad"];
$cargo=$_POST["cargo"];
$sucursal=$_POST["sucursal"];
$cod_contexto=$_POST["contexto"];
$orden=$_POST["orden"];
//$usuario=$_POST["usuario"];
$fechaini=$_POST["fechaini"];
$fechafin=$_POST["fechafin"];


?>
<body>
<?php


//Inicio reporte mov de empleado

if($rep == 9 && $tipo == 1) { // if 2
	 
if ($empleado == 0) { //if empleado
    $valor_empleado = ' ';
	$nom_empleado = 'Todos';
  } else { 
    $valor_empleado = ' a.codPerson = '.$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


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 = ' c.codGender = ' .$genero. ' and ';
} //fin if genero


if ($ciudad == 0) { // if ciudad
	$nom_ciudad = 'Todos';
	$valor_ciudad = ' ';
} else {
	//nombre ciudad
	$result4 = mysqli_query($link, "select a.pkyCity as cod_ciu, a.fldName as ciudad, b.fldName as pais
							from 
							regCity a, regCountry b
							where
							a.pkyCity = '$ciudad' and 
							a.codCountry = b.pkyCountry and 
							a.sysEnabled = 1 and a.sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($result4)) {
		$nom_ciudad = $row['ciudad'].' - '.$row['pais'];
	}
	mysqli_free_result($result4);
	$valor_ciudad = ' d.codCity = ' .$ciudad. ' and ';
} //fin if ciudad


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 = ' a.codJob = ' .$cargo. ' and ';
} //fin if cargo


if ($sucursal == 0) { // if sucursal
	$nom_sucursal = 'Todos';
	$valor_sucursal = ' ';
} else {
	//nombre sucursal
	$result6 = mysqli_query($link, "select a.pkyCompanyBranch as cod_suc, a.fldName as suc, a.fldID as id, b.fldName as ciudad
							from 
							agnCompanyBranch a, regCity b 
							where 
							a.pkyCompanyBranch = '$sucursal' and 
							a.codCompany = 2 and 
							a.codCity = b.pkyCity and 
							a.sysEnabled = 1 and a.sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($result6)) {
		$nom_sucursal = $row['suc'].' - '.$row['id'].' - '.$row['ciudad'];
	}
	mysqli_free_result($result6);
	$valor_sucursal = ' a.codBranch = ' .$sucursal. ' and ';
} //fin if sucursal

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 = ' a.codType = ' .$tipo_mov. ' and ';
} //fin if tipo

//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 empleado, fecha';
} 
if ($orden == 1) { 
	$nom_orden = 'Fecha de Movimiento';
	$valor_orden = 'order by fecha, empleado';
}
if ($orden == 2) { 
	$nom_orden = 'Sexo';
	$valor_orden = 'order by cod_sexo desc, empleado';
}
if ($orden == 3) { 
	$nom_orden = 'Cargo';
	$valor_orden = 'order by cargo, empleado';
}
if ($orden == 4) { 
	$nom_orden = 'C&oacute;digo';
	$valor_orden = 'order by cod_empleado, fecha';
}

//listado de mov empleado
$result4 = mysqli_query($link, "select a.pkyEmployeeMovement as cod_mov, a.fldDocumentNumber as nro_doc, a.fldDate as fecha, a.codType as cod_tipo, b.fldName as tipo, a.codPerson as cod_empleado, 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, a.codPreviousBranch as cod_suc_ant, a.codBranch as cod_suc, d.fldName as sucursal, c.codGender as cod_sexo, a.codPreviousJob as cod_cargo_ant, a.codJob as cod_cargo, e.fldName as cargo, a.fldPreviousSalary as salario_ant, a.fldBasicSalary as salario, c.fldAccumulatedVacation as vacacion_acum, c.fldAccumulatedVAT as iva_acum, d.codCity as cod_ciu, a.txtDescription as glosa, c.fldHiringDate as fecha_cont
from 
hrsEmployeeMovement a, hrsEmployeeMovementType b, agnPerson c, agnCompanyBranch d, hrsJob e
where 
$valor_empleado 
$valor_genero 
$valor_ciudad 
$valor_cargo 
$valor_sucursal 
$valor_tipo_mov 
$valor_contexto 
a.fldDate >= '$fechaini' and 
a.fldDate <= '$fechafin' and 
a.codType = b.pkyEmployeeMovementType and 
a.codPerson = c.pkyPerson and 
a.codBranch = d.pkyCompanyBranch and 
a.codJob =e.pkyJob and 
a.sysEnabled = 1 and a.sysAuthorized = 1  
$valor_orden;");

$mat_mov = array();
$i = 1;
while ($row = mysqli_fetch_array($result4)) {
	$mat_mov [$i][1] = $row['cod_mov'];
	$mat_mov [$i][2] = $row['nro_doc'];
	$mat_mov [$i][3] = $row['fecha'];
	$mat_mov [$i][4] = $row['cod_tipo'];
	$mat_mov [$i][5] = $row['tipo'];
	$mat_mov [$i][6] = $row['cod_empleado'];
	$mat_mov [$i][7] = $row['empleado'];
	$mat_mov [$i][8] = $row['cod_suc_ant'];
	$mat_mov [$i][9] = NULL;//sucursal anterior
	$mat_mov [$i][10] = $row['cod_suc'];
	$mat_mov [$i][11] = $row['sucursal'];
	$mat_mov [$i][12] = $row['cod_sexo'];
	if($row['cod_sexo'] == 1) {
		$mat_mov [$i][13] = 'Masculino';
	} else {
		$mat_mov [$i][13] = 'Femenino';
	}
	$mat_mov [$i][14] = $row['cod_cargo_ant'];
	$mat_mov [$i][15] = NULL;//cargo anterior
	$mat_mov [$i][16] = $row['cod_cargo'];
	$mat_mov [$i][17] = $row['cargo'];
	$mat_mov [$i][18] = $row['salario_ant'];
	$mat_mov [$i][19] = $row['salario'];
	$mat_mov [$i][20] = $row['vacacion_acum'];
	$mat_mov [$i][21] = $row['iva_acum'];
	$mat_mov [$i][22] = $row['cod_ciu'];
	$mat_mov [$i][23] = NULL; //ciudad
	$mat_mov [$i][24] = $row['glosa'];
	$mat_mov [$i][25] = $row['fecha_cont']; //fecha contratacion
	$mat_mov [$i][26] = 0; //vacaciones calculadas inicial
	$mat_mov [$i][27] = 0; //vacaciones tomadas con 0.5 vacaciones
	$mat_mov [$i][28] = 0; //vacaciones tomadas planilla
	$mat_mov [$i][29] = 0; //vacaciones saldo con 0.5 vacaciones
	$mat_mov [$i][30] = 0; //vacaciones saldo planilla
	$mat_mov [$i][31] = 0; //vacaciones calculadas final
	
	$cod_mov = $mat_mov [$i][1];
	$cod_empleado = $mat_mov [$i][6];
	$cod_suc_ant = $mat_mov [$i][8];
	$cod_sexo = $mat_mov [$i][12];
	$cod_cargo_ant = $mat_mov [$i][14];
	$cod_ciu = $mat_mov [$i][22];
	$fecha_cont = $mat_mov [$i][25];
	
	
	//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_mov [$i][9] = $row['sucursal'];
	}
	mysqli_free_result($result42);
	
	//cargo anterior
	$result42 = mysqli_query($link, "select pkyJob as cod_cargo, fldName as cargo
from 
hrsJob
where 
pkyJob = '$cod_cargo_ant' and 
sysEnabled = 1 and sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($result42)) {
		$mat_mov [$i][15] = $row['cargo'];
	}
	mysqli_free_result($result42);
	
	//ciudad
	$result42 = mysqli_query($link, "select a.pkyCity as cod_ciu, a.fldName as ciudad, b.fldName as pais
from 
regCity a, regCountry b
where 
pkyCity = '$cod_ciu' and 
a.codCountry = b.pkyCountry and 
a.sysEnabled = 1 and a.sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($result42)) {
		$mat_mov [$i][23] = $row['ciudad'];
	}
	mysqli_free_result($result42);

	//vacaciones calculadas inicial
	$anos_vac = calcularEdad($fecha_cont,$fechaini);
	if($anos_vac >= 1 && $anos_vac <= 5) { $mat_mov [$i][26] = $anos_vac * 15; }
	if($anos_vac >= 6 && $anos_vac <= 10) { $mat_mov [$i][26] = $anos_vac * 20; }
	if($anos_vac >= 11) { $mat_mov [$i][26] = $anos_vac * 30; }

	//vacaciones calculadas final
	$anos_vac = calcularEdad($fecha_cont,$fechafin);
	if($anos_vac >= 1 && $anos_vac <= 5) { $mat_mov [$i][31] = $anos_vac * 15; }
	if($anos_vac >= 6 && $anos_vac <= 10) { $mat_mov [$i][31] = $anos_vac * 20; }
	if($anos_vac >= 11) { $mat_mov [$i][31] = $anos_vac * 30; }
	
	//vacaciones tomadas con 0.5
	$result42 = mysqli_query($link, "select b.fldWorkdays as dias_tomados
	from 
	hrsVacation a, hrsVacationDetail b
	where 
	a.fldStartDate >= '$fechaini' and 
	a.fldEndDate <= '$fechafin' and 
	a.pkyVacation = b.codVacation and 
	b.codEmployee = '$cod_empleado' and 
	a.sysEnabled = 1 and a.sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($result42)) {
		$mat_mov [$i][27] = $row['dias_tomados'];
	}
	mysqli_free_result($result42);

	//vacaciones tomadas planilla
	$result42 = mysqli_query($link, "select b.fldVacation as dias_tomados
	from 
	hrsSalaryPayroll a, hrsSalaryPayrollDetail b
	where 
	a.fldPeriod >= '$fechaini' and 
	a.fldPeriod <= '$fechafin' and 
	a.pkySalaryPayroll = b.codSalaryPayroll and 
	b.codEmployee = '$cod_empleado' and 
	a.sysEnabled = 1 and a.sysAuthorized = 1;");
	while ($row = mysqli_fetch_array($result42)) {
		$mat_mov [$i][28] = $row['dias_tomados'];
	}
	mysqli_free_result($result42);

	//saldo vacaciones con 0.5
	$mat_mov [$i][29] = $mat_mov [$i][31] - ($mat_mov [$i][26] - $mat_mov [$i][20] + $mat_mov [$i][27]);

	//saldo vacaciones planilla
	$mat_mov [$i][30] = $mat_mov [$i][31] - ($mat_mov [$i][26] - $mat_mov [$i][20] + $mat_mov [$i][28]);

	$i++;
}
$fin_mov = $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 Empleado</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>Empleado: </b><?php echo $nom_empleado; ?></TD>
        <TD width="25%"><b>G&eacute;nero: </b><?php echo $nom_genero; ?></TD>
        <TD width="25%"><b>Cargo: </b><?php echo $nom_cargo; ?></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>Sucursal: </b><?php echo $nom_sucursal; ?></TD>
        </TR>
        <TR>
        <TD colspan="2"><b>Ciudad de la(s) sucursal(s): </b><?php echo $nom_ciudad; ?></TD>
        <TD><b>Ordenado por: </b><?php echo $nom_orden; ?></TD>
        <TD><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>Nro. Doc.</b></TD>
	<TD align="center"><b>Tipo</b></TD>
	<TD align="center"><b>Fecha Contrataci&oacute;n</b></TD>
    <TD align="center"><b>Cod. Empleado</b></TD>
    <TD align="center"><b>Nombre</b></TD>
    <TD align="center"><b>G&eacute;nero</b></TD>
    <TD align="center"><b>Cargo Anterior</b></TD>
    <TD align="center"><b>Sucursal Anterior</b></TD>
    <TD align="center"><b>Cargo</b></TD>
    <TD align="center"><b>Sucursal</b></TD>
    <TD align="center"><b>Ciudad de la(s) sucursal(s)</b></TD>
    <TD align="center" width="65"><b>Fecha</b></TD>
    <TD align="center"><b>Salario Anterior</b></TD>
    <TD align="center"><b>Salario B&aacute;sico</b></TD>
	<TD align="center"><b>Vac. Acum. Alta</b></TD>
	<TD align="center"><b>Vac. Calculadas a fecha<br /> <?php echo $fechaini; ?></b></TD>
	<TD align="center"><b>Vac. Tomadas (con 1/2 d&iacute;a)<br />Periodo</b></TD>
	<TD align="center"><b>Vac. Tomadas Planilla<br />Periodo</b></TD>
	<TD align="center"><b>Vac. Calculadas a fecha<br /> <?php echo $fechafin; ?></b></TD>
	<TD align="center"><b>Vac. Saldo (con 1/2 d&iacute;a)<br />Periodo</b></TD>
	<TD align="center"><b>Vac. Saldo Planilla<br />Periodo</b></TD>
    <TD align="center"><b>RC IVA Acum.</b></TD>
    <TD align="center"><b>Glosa</b></TD>
    </TR>
    </thead>
    <tbody class="marcafila">
    
  <?php
  $color = 2;
    
  $suma_sal_ant = 0;
  $suma_sal_bas = 0;
  $suma_vac_acum = 0;
  $suma_vac_cal_ini = 0;
  $suma_vac_tom05 = 0;
  $suma_vac_tomp = 0;
  $suma_vac_sal05 = 0;
  $suma_vac_salp = 0;
  $suma_vac_cal_fin = 0;
  $suma_iva_acum = 0;
  
  $i = 1;
  while ($i <= $fin_mov) { //while
 	$cod_mov = $mat_mov [$i][1];
	if($color % 2 == 0) { //if color
		printf("<tr BGCOLOR='#e2e7fa'><td align='center'><a href='../../ModuleHumanResources/VoucherEmployeeMovement/index.php?pkyEmployeeMovement=$cod_mov&user=$usuario&token=$token' title='Movimiento de Empleado'>%s</a></td>", $mat_mov [$i][1]);//cod
	} else {
		printf("<tr><td align='center'><a href='../../ModuleHumanResources/VoucherEmployeeMovement/index.php?pkyEmployeeMovement=$cod_mov&user=$usuario&token=$token' title='Movimiento de Empleado'>%s</a></td>", $mat_mov [$i][1]);//cod
	}//fin if color
	
	printf("<td align='center'>%s</td>", $mat_mov [$i][2]);//nro doc
	printf("<td align='left'>%s</td>", $mat_mov [$i][5]);//tipo
	printf("<td align='center'>%s</td>", $mat_mov [$i][25]);//fecha contrato
	printf("<td align='right'>%s</td>", $mat_mov [$i][6]);//cod empleado
	printf("<td align='left'>%s</td>", $mat_mov [$i][7]);//empleado
	printf("<td align='center'>%s</td>", $mat_mov [$i][13]);//genero
	printf("<td align='left'>%s</td>", $mat_mov [$i][15]);//cargo ant
	printf("<td align='left'>%s</td>", $mat_mov [$i][9]);//sucursal ant
	printf("<td align='left'>%s</td>", $mat_mov [$i][17]);//cargo
	printf("<td align='left'>%s</td>", $mat_mov [$i][11]);//sucursal
	printf("<td align='left'>%s</td>", $mat_mov [$i][23]);//ciudad
	printf("<td align='center'>%s</td>", $mat_mov [$i][3]);//fecha
	printf("<td align='right'>%s</td>", number_format($mat_mov [$i][18],$n_decimales));//sal ant
	printf("<td align='right'>%s</td>", number_format($mat_mov [$i][19],$n_decimales));//sal bas
	printf("<td align='right'>%s</td>", number_format($mat_mov [$i][20],0));//vac acum alta
	printf("<td align='right'>%s</td>", number_format($mat_mov [$i][26],0));//vac calculadas inicial
	printf("<td align='right'>%s</td>", number_format($mat_mov [$i][27],1));//vac tomadas 0.5
	printf("<td align='right'>%s</td>", number_format($mat_mov [$i][28],0));//vac tomadas planilla
	printf("<td align='right'>%s</td>", number_format($mat_mov [$i][31],0));//vac calculadas final
	printf("<td align='right'>%s</td>", number_format($mat_mov [$i][29],1));//vac saldo 0.5
	printf("<td align='right'>%s</td>", number_format($mat_mov [$i][30],0));//vac saldo planilla
	printf("<td align='right'>%s</td>", number_format($mat_mov [$i][21],0));//iva acum
	printf("<td align='left'>%s</td></tr>", $mat_mov [$i][24]);//glosa
	
	
	$suma_sal_ant = $suma_sal_ant + $mat_mov [$i][18];   
	$suma_sal_bas = $suma_sal_bas + $mat_mov [$i][19];
	$suma_vac_acum = $suma_vac_acum + $mat_mov [$i][20];   
	$suma_vac_cal_ini = $suma_vac_cal_ini + $mat_mov [$i][26];  
	$suma_vac_tom05 = $suma_vac_tom05 + $mat_mov [$i][27];
	$suma_vac_tomp = $suma_vac_tomp + $mat_mov [$i][28];
	$suma_vac_sal05 = $suma_vac_sal05 + $mat_mov [$i][29];
	$suma_vac_salp = $suma_vac_salp + $mat_mov [$i][30];
	$suma_vac_cal_fin = $suma_vac_cal_fin + $mat_mov [$i][31];
	$suma_iva_acum = $suma_iva_acum + $mat_mov [$i][21];
	$color++;
	$i++;
  }//fin while
	
?>
<tr BGCOLOR="#ffcccc"><td colspan="13"><b>Total</b></td>
<td align="right"><?php printf("<b>%s</b>", number_format($suma_sal_ant,$n_decimales)); ?></td>
<td align="right"><?php printf("<b>%s</b>", number_format($suma_sal_bas,$n_decimales)); ?></td>
<td align="right"><?php printf("<b>%s</b>", number_format($suma_vac_acum,0)); ?></td>
<td align="right"><?php printf("<b>%s</b>", number_format($suma_vac_cal_ini,0)); ?></td>
<td align="right"><?php printf("<b>%s</b>", number_format($suma_vac_tom05,1)); ?></td>
<td align="right"><?php printf("<b>%s</b>", number_format($suma_vac_tomp,0)); ?></td>
<td align="right"><?php printf("<b>%s</b>", number_format($suma_vac_cal_fin,0)); ?></td>
<td align="right"><?php printf("<b>%s</b>", number_format($suma_vac_sal05,1)); ?></td>
<td align="right"><?php printf("<b>%s</b>", number_format($suma_vac_salp,0)); ?></td>
<td align="right"><?php printf("<b>%s</b>", number_format($suma_iva_acum,0)); ?></td>
<td align="right"><?php printf("<b>%s</b>", number_format($i-1,0)); ?></td>
</tr>
</tbody>
</table>
<?php

} //fin if 2


?>

