<?session_start();
//RESTRICCIÓN DE ACCESO A TRABAJADOR (ACCESO INDIVIDUAL) 
if (isset($_SESSION['tipousuario']))
		{if ($_SESSION['tipousuario']=='1')
		header ('location:menu_personal.php');
		}

if  (trim($_SESSION['nombre_validar'])=='') header ('location:index.php');
	include ("fphp.php");
	$enlace=cargar_conexion();
	$cedula=str_repeat('0',8-strlen(trim($_REQUEST["cedula"]))).trim($_REQUEST["cedula"]);

	$consulta="select nombres,nombres1,apellidos,apellidos1 from personal where codigo='".$cedula."' and id='".$_SESSION['id_validar']."' ";
	$resultado = mysqli_query($enlace,$consulta) or die($consulta . mysqli_error($enlace));
	$row=mysqli_fetch_array($resultado);
	echo "<center><font face='verdana' color=red size=4>[Calculo de Prestaciones Sociales del Trabajador]</font></center>";
	//echo "<br><center><img src='img2/administrator.png'><font color=black size=4>&nbsp;".trim($row['nombres'])." ".trim($row['nombres1']).' '.trim($row['apellidos'])." ".trim($row['apellidos1'])."</font></center><br>";

	//============ datos de empresa
	$consulta=mysqli_query($enlace,"select * from empresa where id='".$_SESSION['id_validar']."' ");
	$row=mysqli_fetch_array($consulta);
	$ince=$row['ince'];
	$dvac=$row['dvac'];
	$dbon=$row['dbon'];
	$duti=$row['duti'];
	$icon=$rowr['icon'];
	$ticket=$row['ticket'];
	
	//=========== datos de prestaciones
	$consultax="select * from prestacion where cedula='".$cedula."' and id='".$_SESSION['id_validar']."' ";
	$resultadox = mysqli_query($enlace,$consultax) or die('verificaci&oacute; del c&oacute;digo fall&oacute;: ' . mysqli_error($enlace));
	$rowx=mysqli_fetch_array($resultadox);
	$status = $rowx['status'];
	$smes = $rowx['smes'];
	$diaspagar = $rowx['dias'];
	$dias = $rowx['dias'];
	$dpnl = $rowx['dpnl'];
	$diasticket = $rowx['diast'];
	$islr=$rowx['islr'];
	$faov=$rowx['faov'];
	$fideicomiso=$rowx['fideicomiso'];
	$adeuti=$rowx['adeuti'];
	$adevac=$rowx['adevac'];
	$semana=$rowx['semana'];
	$fec1 = $rowx['fechai'];
	$fec2 = $rowx['egreso'];
	$vac = $rowx['vacacion'];
	$tipoe = $rowx['tipoe'];
	$cuantosdias=calcular_dias($fec1,$fec2);
	
	$hoy=substr($fec2,0,4).'-01-01';
	if ($fec1>$hoy) $hoy = $fec1;
	
	$mesutilidad = mostrar_antiguedad(2,$hoy, $fec2);
	$utilidad = $duti/12*$mesutilidad*($smes/30);
		
	$a=mostrar_antiguedad(1,$fec1,$fec2);
	$diasvac = $dvac + ($a-1<=0?0:$a-1);
	$diasbon = $dbon + ($a-1<=0?0:$a-1);
	
	//============ datos de prestamos
	$consulta=mysqli_query($enlace,"select sum(saldo) as total from prestamo where cedula='".$cedula."' and id='".$_SESSION['id_validar']."' ");
	$row=mysqli_fetch_array($consulta);
	$saldoprestamo=$row['total'];
	
	//============ datos de adelantos
	$consulta=mysqli_query($enlace,"select sum(monto) as total from prestacion_adelanto where cedula='".$cedula."' and id='".$_SESSION['id_validar']."' ");
	$row=mysqli_fetch_array($consulta);
	$saldoadelanto=$row['total'];

	//============ datos de adelantos
	$consulta=mysqli_query($enlace,"select sum(monto) as total from prestacion_interes where cedula='".$cedula."' and id='".$_SESSION['id_validar']."' ");
	$row=mysqli_fetch_array($consulta);
	$saldointeres=$row['total'];


	//====================================== SALIDA DE CALCULO
	//====================================== SALIDA DE CALCULO
	echo "<table rules=none border=1 cellpadding=2 cellspacing=0 align='center' style='border-width: 1px; border-color: 75263C;border-style: solid;'>";
	echo "<tr bgcolor='#43bced' height='25'>";
		echo "<th width='400' align = left><font color='black'> Conceptos </font></th>";
		echo "<th width='100' align = left><font color='black'> Desde </font></th>";
		echo "<th width='100' align = left><font color='black'> Hasta </font></th>";
		echo "<th width='200' align = left><font color='black'> Unidad </font></th>";
		echo "<th width='100' align = right><font color='black'> Cantidad </font></th>";
		echo "<th width='100' align = right><font color='black'> Diario </font></th>";
		echo "<th width='100' align = right><font color='black'> Sub-Total </font></th>";
	echo "</tr>";

	$totaldev=0; $totalded=0;
	///===================================== sueldos dias a pagar
	///===================================== sueldos dias a pagar
	if ($diaspagar>0) {
		if ($color) $tcolor="#dfdfd0";
		else $tcolor="white";
		echo '<tr bgcolor='.$tcolor.' >';
			echo "<td>Sueldo / Salario</td>";
			echo "<td></td>";
			echo "<td></td>";
			echo "<td>D&iacute;as</td>";
			echo "<td align=right>".number_format($diaspagar ,0)."</td>";
			echo "<td align=right>".number_format($smes/30 ,2)."</td>";
			echo "<td align=right>".number_format($smes/30*$diaspagar ,2)."</td>";
		echo "</tr>";
		$color=!$color;
		$totaldev += $smes/30*$diaspagar;
	}
	///===================================== cesta ticket dias a pagar
	///===================================== cesta ticket dias a pagar
	if ($diasticket>0) {
		if ($color) $tcolor="#dfdfd0";
		else $tcolor="white";
		echo '<tr bgcolor='.$tcolor.' >';
			echo "<td>Cesta Tickets a Pagar</td>";
			echo "<td></td>";
			echo "<td></td>";
			echo "<td>D&iacute;as</td>";
			echo "<td align=right>".number_format($diasticket ,0)."</td>";
			echo "<td align=right>".number_format($ticket ,2)."</td>";
			echo "<td align=right>".number_format($ticket*$diasticket ,2)."</td>";
		echo "</tr>";
		$color=!$color;
		$totaldev += $ticket*$diasticket;
	}
	
	///===================================== vacaciones vencidas
	///===================================== vacaciones vencidas
	if ($vac>0) {
		if ($color) $tcolor="#dfdfd0";
		else $tcolor="white";
		echo '<tr bgcolor='.$tcolor.' >';
			echo "<td>Vacaciones Anuales Vencidas (".$vac.")</td>";
			echo "<td></td>";
			echo "<td></td>";
			echo "<td>D&iacute;as</td>";
			echo "<td align=right>".number_format($diasvac,0)."</td>";
			echo "<td align=right>".number_format($smes/30,2)."</td>";
			echo "<td align=right>".number_format($smes/30*$diasvac*$vac,2)."</td>";
		echo "</tr>";
		$color=!$color;
		$totaldev += $smes/30*$diasvac*$vac;
		
		if ($color) $tcolor="#dfdfd0";
		else $tcolor="white";
		echo '<tr bgcolor='.$tcolor.' >';
			echo "<td >Bono Vacacional Vencidas (".$vac.")</td>";
			echo "<td></td>";
			echo "<td></td>";
			echo "<td>D&iacute;as</td>";
			echo "<td align=right>".number_format($diasbon,0)."</td>";
			echo "<td align=right>".number_format($smes/30,2)."</td>";
			echo "<td align=right>".number_format($smes/30*$diasbon*$vac,2)."</td>";
		echo "</tr>";
		$color=!$color;		
		$totaldev += $smes/30*$diasbon*$vac;
	}

	$a=mostrar_antiguedad(1,$fec1,$fec2);
	$mesvacacion = mostrar_antiguedad(2,$fec1,$fec2);
	$diasvac = $dvac + ($a<=0?0:$a);
	$diasbon = $dbon + ($a<=0?0:$a);
	
	//=============================== Vacaciones Fraccionadas
	//=============================== Vacaciones Fraccionadas
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td width='300'>Vacaciones Fraccionadas</td>";
		echo "<td></td>";
		echo "<td></td>";
		echo "<td >".number_format($mesvacacion,0)." Mes(es)</td>";
		echo "<td align=right>".number_format($diasvac/12*$mesvacacion,2)."</td>";
		echo "<td align=right>".number_format($smes/30,2)."</td>";
		echo "<td align=right>".number_format($smes/30*$diasvac/12*$mesvacacion,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$totaldev += $smes/30*$diasvac/12*$mesvacacion;
	
	//=============================== Bono Vacacional Vencidas
	//=============================== Bono Vacacional Vencidas
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td width='300'>Bono Vacacional Fraccionadas</td>";
		echo "<td></td>";
		echo "<td></td>";
		echo "<td >".number_format($mesvacacion,0)." Mes(es)</td>";
		echo "<td align=right>".number_format($diasbon/12*$mesvacacion,2)."</td>";
		echo "<td align=right>".number_format($smes/30,2)."</td>";
		echo "<td align=right>".number_format($smes/30*$diasbon/12*$mesvacacion,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$totaldev += $smes/30*$diasbon/12*$mesvacacion;
	
	//=============================== UTILIDADES 
	//=============================== UTILIDADES 

	$hoy=substr($fec2,0,4).'-01-01';
	if ($fec1>$hoy) $hoy = $fec1;
	
	$mesutilidad = mostrar_antiguedad(2,$hoy, $fec2);
	$utilidad = $duti/12*$mesutilidad*($smes/30);
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td >Utilidades del Per&iacute;odo</td>";
		echo "<td >".mostrar_fecha($hoy)."</td>";
		echo "<td >".mostrar_fecha($fec2)."</td>";
		echo "<td >".number_format($mesutilidad,2)." Meses</td>";
		echo "<td align=right>".number_format($duti/12*$mesutilidad,2)."</td>";
		echo "<td align=right>".number_format($smes/30,2)."</td>";
		echo "<td align=right>".number_format($utilidad,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$totaldev += $utilidad;

	//================================ prestaciones
	//================================ prestaciones
	$fec11x = $rowx['fechai'];
	$fec22x = $rowx['egreso'];
	$fec11 = substr($rowx['fechai'],0,7);
	$fec22 = substr($rowx['egreso'],0,7);
	$inicio=0; $tri=0; $salto=0; $anosx=0; $anos=0; $entrosueldo=0; 
	$acumulado=0; $intereses=0; $tdias=0; $prestaciones=0;$interesganados=0;
	$cuantosmeses=0;
	
	//============ datos de sueldo
	$consulta=mysqli_query($enlace,"select sueldo from personal_sueldo where id='".$_SESSION['id_validar']."' and substring(fec,1,7)='".$fec11."' and codigo='".$cedula."'") or die (mysqli_error($enlace));
	$row=mysqli_fetch_array($consulta);
	if (mysqli_num_rows($consulta)!=0) $sueldo=$row['sueldo'];
	
	while ($fec11x<$fec22x) {
			
			$cuantosmeses++;
			//====================== calcular años
			$anosx++;
			if ($anosx>12) {
				$anos++;			
				$anosx=1;
			}	
			
			//====================== mover fechas
			$a=substr($fec11x,0,4);	
			$d=substr($fec11x,8,2);	
			$m=substr($fec11x,5,2)+1;	
			if ($m>12) {
				$m='01';
				$a=$a+1;
			} else $m=(strlen($m)==1?('0'.$m):$m);	
			$fec11x=$a."-".$m."-".$d;
			
			//====================== ver cual periodo es
			$a=substr($fec11,0,4);	
			$d=substr($fec11,0,4);	
			$m=substr($fec11,5,2)+1;	
			if ($m>12) {
				$m='01';
				$a=$a+1;
			} else $m=(strlen($m)==1?('0'.$m):$m);	
			$fec11=$a."-".$m;

			//===================== buscar dias de utilidades en historico	
			$consulta=mysqli_query($enlace,"select dvac,duti from historico_parametro where id='".$_SESSION['id_validar']."' and anio='".$a."'") or die (mysqli_error($enlace));
			if (mysqli_num_rows($consulta)!=0) {
				$row=mysqli_fetch_array($consulta);
				$dvacx=$row['dvac'];
				$dutix=$row['duti'];
			} else {
				$dvacx=$dvac;
				$dutix=$duti;
			}
			
			//====================== salto de tres en tres desde 05-2012
			if ($tri==1) {
				$salto++; $dias=0;
				if ($salto==3) {
					$salto=0;
					$dias=15;
				}	
			} else {
				if ($fec11<='2012-04') {
					if ($fec11=='2012-04') $tri=1;
					$dias=5;	
				} else {
					$tri=1;
					$salto++; $dias=0;
					if ($salto==3) {
						$salto=0;
						$dias=15;
					}	
				}
			}

			//====================== calcular inicio
			$inicio++;
			if ($inicio<=3 && $fec11<'2012-04') $dias=0;

			//============ datos de adelantos
			$consulta=mysqli_query($enlace,"select sum(monto) as total from prestacion_adelanto where id='".$_SESSION['id_validar']."' and substring(fecha,1,7)='".$fec11."' and cedula='".$cedula."'") or die (mysqli_error($enlace));
			$row=mysqli_fetch_array($consulta);
			$adelanto=$row['total'];
			$consulta=mysqli_query($enlace,"select sum(monto) as total from prestacion_interes where id='".$_SESSION['id_validar']."' and substring(fecha,1,7)='".$fec11."' and cedula='".$cedula."'") or die (mysqli_error($enlace));
			$row=mysqli_fetch_array($consulta);
			$adeinteres=$row['total'];

			//============ datos de sueldo
			$consulta=mysqli_query($enlace,"select sueldo from personal_sueldo where id='".$_SESSION['id_validar']."' and substring(fec,1,7)='".$fec11."' and codigo='".$cedula."'") or die (mysqli_error($enlace));
			$row=mysqli_fetch_array($consulta);
			if (mysqli_num_rows($consulta)!=0) $sueldo=$row['sueldo'];
			$integral = ($sueldo/30) + ($dvacx/12*$sueldo/30/30) + ($dutix/12*$sueldo/30/30);
			
			//============ datos de interes
			if ($icon!=2) {
				$consulta=mysqli_query($enlace,"select mon as total from tab_interes where substring(fec,1,7)='".$fec11."'");
				$row=mysqli_fetch_array($consulta);
			}	
			if ($row['total']==0) $tcolor='red';
			else $tcolor='black';
			$interes=($row['total']==0?$interes:$row['total']);

			//============ calculo
			$acumulado += $integral*$dias - $adelanto;
						
			if ($prestaciones*$interes/100/12>0) {
				$interesganados += ($prestaciones*$interes/100/12)-$adeinteres;	
			}

			//============ dia adicional
			if ($anosx==12 && $anos>=1) {
				$diaa = $anos*2;
				$acumulado += $integral*$diaa;
			} else $diaa=0;	
			
			$tdias += $dias+$diaa;	
			$prestaciones += ($integral*$dias)+($integral*$diaa)-$adelanto;	
	}

	//================================ cuando es <3 meses
	if ($cuantosmeses<3) {	
			if ($cuantosdias>60) $sondias=15;
			else {
				if ($cuantosdias>30) $sondias=10;
				else $sondias=5;
			}
			
			if ($color) $tcolor="#dfdfd0";
			else $tcolor="white";
			echo '<tr bgcolor='.$tcolor.' >';
					echo "<td >Prestaciones en Garantia (Art. 142)</td>";
					echo "<td>".mostrar_fecha($fec1)."</td>";
					echo "<td>".mostrar_fecha($fec2)."</td>";
					echo "<td>D&iacute;as</td>";
					echo "<td align=right>".number_format($sondias,0)."</td>";
					echo "<td></td>";
					echo "<td align=right>".number_format($sondias*$integral+$saldoadelanto,2)."</td>";
			echo '</tr>';
			$color=!$color;
			$totaldev += $sondias*$integral+$saldoadelanto;

			if ($tipoe==1){
				if ($color) $tcolor="#dfdfd0";
				else $tcolor="white";
				echo '<tr bgcolor='.$tcolor.' >';
						echo "<td >Indemnizacion por Despido (Art. 92)</td>";
						echo "<td>".mostrar_fecha($fec1)."</td>";
						echo "<td>".mostrar_fecha($fec2)."</td>";
						echo "<td>D&iacute;as</td>";
						echo "<td align=right>".number_format(($cuantosmeses==1?5:10),0)."</td>";
						echo "<td></td>";
						echo "<td align=right>".number_format(($cuantosmeses==1?5:10)*$integral+$saldoadelanto,2)."</td>";
				echo '</tr>';
				$color=!$color;
				$totaldev += ($cuantosmeses==1?5:10)*$integral+$saldoadelanto;
			}
	}			
	//================================ cuando es >= 3 meses
	if ($cuantosmeses>=3) {	
			if ($color) $tcolor="#dfdfd0";
			else $tcolor="white";
			echo '<tr bgcolor='.$tcolor.' >';
					echo "<td >Prestaciones en Garantia (Art. 142)</td>";
					echo "<td>".mostrar_fecha($fec1)."</td>";
					echo "<td>".mostrar_fecha($fec2)."</td>";
					echo "<td>D&iacute;as</td>";
					echo "<td align=right>".number_format($tdias,0)."</td>";
					echo "<td></td>";
					echo "<td align=right>".number_format($prestaciones+$saldoadelanto,2)."</td>";
			echo '</tr>';
			$color=!$color;
			$totaldev += $prestaciones+$saldoadelanto;

			if ($dias==0) {	
					if ($color) $tcolor="#dfdfd0";
					else $tcolor="white";
					echo '<tr bgcolor='.$tcolor.' >';
						echo "<td >Deposito Ultimo Trimestre</td>";
						echo "<td>".mostrar_fecha($fec1)."</td>";
						echo "<td>".mostrar_fecha($fec2)."</td>";
						echo "<td>D&iacute;as</td>";
						echo "<td align=right>".number_format(15,0)."</td>";
						echo "<td align=right>".number_format($integral,2)."</td>";
						echo "<td align=right>".number_format($integral*15,2)."</td>";
					echo '</tr>';
					$color=!$color;
					$totaldev += $integral*15;
			}
			if ($tipoe==1){
				if ($color) $tcolor="#dfdfd0";
				else $tcolor="white";
				echo '<tr bgcolor='.$tcolor.' >';
						echo "<td >Indemnización por Despido (Art. 92)</td>";
						echo "<td>".mostrar_fecha($fec1)."</td>";
						echo "<td>".mostrar_fecha($fec2)."</td>";
						echo "<td>D&iacute;as</td>";
						echo "<td align=right>".number_format( ($dias==0?$tdias+15:$tdias),0 )."</td>";
						echo "<td></td>";
						echo "<td align=right>".number_format($prestaciones+$saldoadelanto+($dias==0?$integral*15:0) ,2)."</td>";
				echo '</tr>';
				$color=!$color;
				$totaldev += $prestaciones+$saldoadelanto+($dias==0?$integral*15:0);
			}
			
			
			if ($color) $tcolor="#dfdfd0";
			else $tcolor="white";
			echo '<tr bgcolor='.$tcolor.' >';
					echo "<td >Intereses de Prestaciones (Art. 142)</td>";
					echo "<td>".mostrar_fecha($fec1)."</td>";
					echo "<td>".mostrar_fecha($fec2)."</td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td align=right>".number_format($interesganados+$saldointeres,2)."</td>";
			echo '</tr>';
			$color=!$color;
			$totaldev += $interesganados+$saldointeres;
	}		
	
	//=============================== total devengo
	//=============================== total devengo
	echo "<tr bgcolor='#43bced' height='25'>";
		echo "<th align = right colspan=6><font color='black'> Total Devengado Bs. </font></th>";
		echo "<td align=right><font color='black'>".number_format($totaldev,2)."</font></td>";
	echo "</tr>";


	//=============================== total DEDUCCIONES
	//=============================== total DEDUCCIONES

	//=============================== total dias pagado no laborados
	$total=0;
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td colspan=5>D&iacute;as Pagados No Laborados</td>";
		echo "<td align='right'>$dpnl D&iacute;as</td>";
		echo "<td align='right'>".number_format($smes/30*$dpnl,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$total +=$smes/30*$dpnl;
	
	//=============================== total PRESTACIONES
	$total=0;
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td colspan=5>Adelantos de Prestaciones Sociales</td>";
		echo "<td align='right'></td>";
		echo "<td align='right'>".number_format($saldoadelanto,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$total +=$saldoadelanto;

	//=============================== total INTERESES
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td colspan=5>Adelantos de Intereses de Prestaciones Sociales</td>";
		echo "<td align='right'></td>";
		echo "<td align='right'>".number_format($saldointeres,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$total +=$saldointeres;
	
	//=============================== total PRESTAMOS
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td colspan=5>Adelantos de Prestamos Personales</td>";
		echo "<td align='right'></td>";
		echo "<td align='right'>".number_format($saldoprestamo,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$total +=$saldoprestamo;

	//=============================== total UTILIDADES
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td colspan=5>Adelantos de Utilidades</td>";
		echo "<td align='right'></td>";
		echo "<td align='right'>".number_format($adeuti,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$total +=$adeuti;

	//=============================== total VACACIONES
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td colspan=5>Adelantos de Vacaciones</td>";
		echo "<td align='right'></td>";
		echo "<td align='right'>".number_format($adevac,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$total +=$adevac;
	
	//=============================== total FIDEICOMISO
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td colspan=5>Deposito en FIDEICOMISO</td>";
		echo "<td align='right'></td>";
		echo "<td align='right'>".number_format($fideicomiso,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$total +=$fideicomiso;
		
	//=============================== total ISLR
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td colspan=5>Impuesto Sobre La Renta (I.S.L.R.)</td>";
		echo "<td align='right'>".number_format($islr,2)."</td>";
		echo "<td align='right'>".number_format($smes/30*$diaspagar*$islr/100,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$total +=$smes/30*$diaspagar*$islr/100;

	//=============================== total S.S.O.
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td colspan=5>Seguro Social Obligatorio (S.S.O.)</td>";
		echo "<td align='right'>".number_format($semana,2)."</td>";
		echo "<td align='right'>".number_format($smes*12/52*$semana*0.04,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$total +=$smes*12/52*$semana*0.04;

	//=============================== total RPE
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td colspan=5>Regimen de Prestaci&oacute;n de Empleo (R.P.E.)</td>";
		echo "<td align='right'>".number_format($semana,2)."</td>";
		echo "<td align='right'>".number_format($smes*12/52*$semana*0.005,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$total +=$smes*12/52*$semana*0.005;

	//=============================== total FAOV
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td colspan=5>F.A.O.V</td>";
		echo "<td align='right'>".number_format($faov,2)."</td>";
		echo "<td align='right'>".number_format($utilidad*$faov/100,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$total +=$smes/30*$faov/100;

	//=============================== total INCES
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
		echo "<td colspan=5>I.N.C.E.S.</td>";
		echo "<td align='right'>".number_format($ince,2)."</td>";
		echo "<td align='right'>".number_format($utilidad*$ince/100,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$total +=$utilidad*$ince/100;

	
	echo '<tr bgcolor="#43bced">';
		echo "<td colspan=6 align=right><b><font color='black'>Total Deducciones Bs.</b></font></td>";
		echo "<td align='right'><font color='black'>".number_format($total,2)."</font></td>";
	echo '</tr>';
	echo '<tr bgcolor="#F5F6CE">';
		echo "<td colspan=6 align=right><b><font color='black'>Total Neto a Pagar Bs.</b></font></td>";
		echo "<td align='right'><font color='black'><b>".number_format($totaldev-$total,2)."</b></font></td>";
	echo '</tr>';
	echo '</table>';
	mysqli_free_result($resultado);
	
	
	echo '</table>';
	mysqli_close($enlace);
?>