<?session_start();

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."' ";
	$resultado = mysqli_query($enlace,$consulta) or die($consulta . mysqli_error($enlace));
	$row=mysqli_fetch_array($resultado);
	mysqli_free_result($resultado);
	
	echo "<center><font face='verdana' color=red size=4>[Vacaciones 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');
	$row=mysqli_fetch_array($consulta);
	$ince=$row['ince'];
	$dvac=$row['dvac'];
	$dbon=$row['dbon'];
	$duti=$row['duti'];
	
	//=========== datos de prestaciones
	$consultax="select * from prestacion where cedula='".$cedula."' ";
	$resultadox = mysqli_query($enlace,$consultax) or die('verificaci&oacute; del c&oacute;digo fall&oacute;: ' . mysqli_error($enlace));
	$rowx=mysqli_fetch_array($resultadox);
	$smes = $rowx['smes'];
	$dias = $rowx['dias'];
	$fec1 = $rowx['fechai'];
	$fec2 = $rowx['egreso'];
	$vac = $rowx['vacacion'];
	$semana=0;
	if ($dias>1 && $dias<=7) $semana=1;
	if ($dias>7) $semana=2;
		
	echo "<table rules=none border=0 cellpadding=2 cellspacing=0 align='center'>";
	echo "<tr bgcolor='#43bced'>";
	echo "<th align = left><font color='white'> Concepto </font></th>";
	echo "<th align = left><font color='white'> Cantidad </font></th>";
	echo "<th align = right><font color='white'> Dias </font></th>";
	echo "<th align = right><font color='white'> Bs/Diario </font></th>";
	echo "<th align = right><font color='white'> Monto Bs </font></th>";

	$total=0;	
	if ($vac!=0) {
			$a=mostrar_antiguedad(1,$fec1,$fec2);
			$diasvac = $dvac + ($a-1<=0?0:$a-1);
			$diasbon = $dbon + ($a-1<=0?0:$a-1);
			//=============================== Vacaciones Anuales Vencidas
			if ($color) $tcolor="#dfdfd0";
			else $tcolor="white";
			echo '<tr bgcolor='.$tcolor.' >';
			echo "<td width='300'>Vacaciones Anuales Vencidas</td>";
			echo "<td width='80' align=right>".number_format($vac,0)." Año(s)</td>";
			echo "<td width='80' align=right>".number_format($diasvac,0)."</td>";
			echo "<td width='80' align=right>".number_format($smes/30,2)."</td>";
			echo "<td width='80' align=right>".number_format($smes/30*$diasvac*$vac,2)."</td>";
			echo '</tr>';
			$color=!$color;
			$total += ($smes/30*$diasvac*$vac);
			//=============================== Bono Vacacional Vencidas
			if ($color) $tcolor="#dfdfd0";
			else $tcolor="white";
			echo '<tr bgcolor='.$tcolor.' >';
			echo "<td width='300'>Bono Vacacional Vencidas</td>";
			echo "<td width='80' align=right>".number_format($vac,0)." Año(s)</td>";
			echo "<td width='80' align=right>".number_format($diasbon,0)."</td>";
			echo "<td width='80' align=right>".number_format($smes/30,2)."</td>";
			echo "<td width='80' align=right>".number_format($smes/30*$diasbon*$vac,2)."</td>";
			echo '</tr>';
			$color=!$color;
			$total += ($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
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
	echo "<td width='300'>Vacaciones Fraccionadas</td>";
	echo "<td width='80' align=right>".number_format($mesvacacion,0)." Mes(es)</td>";
	echo "<td width='80' align=right>".number_format($diasvac/12*$mesvacacion,2)."</td>";
	echo "<td width='80' align=right>".number_format($smes/30,2)."</td>";
	echo "<td width='80' align=right>".number_format($smes/30*$diasvac/12*$mesvacacion,2)."</td>";
	echo '</tr>';
	$color=!$color;
	//=============================== Bono Vacacional Vencidas
	if ($color) $tcolor="#dfdfd0";
	else $tcolor="white";
	echo '<tr bgcolor='.$tcolor.' >';
	echo "<td width='300'>Bono Vacacional Fraccionadas</td>";
	echo "<td width='80' align=right>".number_format($mesvacacion,0)." Mes(es)</td>";
	echo "<td width='80' align=right>".number_format($diasbon/12*$mesvacacion,2)."</td>";
	echo "<td width='80' align=right>".number_format($smes/30,2)."</td>";
	echo "<td width='80' align=right>".number_format($smes/30*$diasbon/12*$mesvacacion,2)."</td>";
	echo '</tr>';
	$color=!$color;
	$total += ($smes/30*$diasvac/12*$mesvacacion) + ($smes/30*$diasbon/12*$mesvacacion);
	
	echo '<tr bgcolor="#43bced">';
	echo "<td colspan=4><font color='white'>Totales Bs.</font></td>";
	echo "<td width='100' align='right'><font color='white'><input name='aa' size=7 value='".number_format($total,2)."'></font></td>";
	echo '</tr>';
	echo '</table>';
	
	mysqli_close($enlace);
?>