<?php 
///////////////////////////////////////////////// inicio del programa ////////////////////////////////////////////////////////////////
session_start();

if (isset($_SESSION['tipousuario']))
		{if ($_SESSION['tipousuario']=='1')
		header ('location:menu_personal.php');
		}
		
		
if  (trim($_SESSION['nombre_validar'])=='') header ('location:index.php');
require('fphp.php');
$enlace=cargar_conexion();
menu();
echo "<b>Opciones:</b> 
&nbsp;&nbsp;<img border = 0 src='img2/apuntes.png' alt='Regresar'>:<a href='prestaciones_parametro_historico.php?'>Cargar Historico de D&iacute;as de Utilidades</a>
</font><hr>";
echo "<h2>M&oacute;dulo de Par&aacute;metros para C&aacute;lculos de Prestaciones</h2>";

///////////////////////////////////////////////// graba registros  ////////////////////////////////////////////////////////////////
if ($_POST['graba']==1 ) {
	$query = "update empresa set sueldominimo='".$_POST['sueldominimo']."',ticket='".$_POST['ticket']."',ince='".$_POST['ince']."',duti='".$_POST['duti']."',dvac='".$_POST['dvac']."',dbon='".$_POST['dbon']."',icon='".$_POST['icon']."' where id='".$_SESSION['id_validar']."' ";
	$consulta = mysqli_query($enlace,$query) or die ("no se pudo realizar la consulta...".mysqli_error($enlace));
}

$consulta="select * from empresa where id='".$_SESSION['id_validar']."' ";
$resultado = mysqli_query($enlace,$consulta) or die('verificaci&oacute; del c&oacute;digo fall&oacute;: ' . mysqli_error($enlace));
$num_rows = mysqli_num_rows($resultado);

if ($num_rows!=0) {
		$row=mysqli_fetch_array($resultado);
		echo "<form name = 'entrada' action = '".$_SERVER['PHP_SELF']."' method = 'POST'  enctype='multipart/form-data'>";
		echo "<input type = 'hidden' name = 'graba' value = '1'>";
		echo "<table align ='center'>";
		
		echo "<tr>";
			echo "<td align = 'right1'> D&iacute;as de Utilidades: </td>";
			echo "<td align = 'left'> <input type = 'text' name = 'duti' size = '10' maxlength = '3' value = '".$row['duti']."' ></td>";
		echo "</tr>";
		
		echo "<tr>";
			echo "<td align = 'right1'> D&iacute;as de Vacaciones: </td>";
			echo "<td align = 'left'> <input type = 'text' name = 'dvac' size = '10' maxlength = '2' value = '".$row['dvac']."' ></td>";
		echo "</tr>";

		echo "<tr>";
			echo "<td align = 'right1'> D&iacute;as de Bono Vacacional: </td>";
			echo "<td align = 'left'> <input type = 'text' name = 'dbon' size = '10' maxlength = '2' value = '".$row['dbon']."' ></td>";
		echo "</tr>";

		echo "<tr>";
			echo "<td align = 'right1'> Monto Cesta Tickets x D&iacute;a: </td>";
			echo "<td align = 'left'> <input type = 'text' name = 'ticket' size = '10' maxlength = '9' value = '".$row['ticket']."' ></td>";
		echo "</tr>";
		echo "<tr>";
			echo "<td align = 'right1'> Porcentaje INCES: </td>";
			echo "<td align = 'left'> <input type = 'text' name = 'ince' size = '10' maxlength = '5' value = '".$row['ince']."' ></td>";
		echo "</tr>";
		echo "<tr>";
			echo "<td align = 'right1'> Monto Sueldo M&iacute;nimo: </td>";
			echo "<td align = 'left'> <input type = 'text' name = 'sueldominimo' size = '10' maxlength = '10' value = '".$row['sueldominimo']."' ></td>";
		echo "</tr>";
		
		echo "<tr>";
			echo "<td align = 'right1'> Int/Prestaciones en Contabilidad? </td>";
			echo "<td align = 'left'> 
			<select name = 'icon' >
				<option value='1' ".($row['icon']==0||$row['icon']==1?'selected':'').">SI 
				<option value='2' ".($row['icon']==2?'selected':'').">NO 
			</select></td>";
		echo "</tr>";

		echo "</table>";
		echo "<table align ='center'>";
		echo "<tr><td><input type = 'submit' value = 'Grabar Cambios'></td></form>";
		echo "	<script language='javascript' type='text/javascript'>";
		echo "		document.entrada.nombre.focus()";
		echo "	</script>";
} else {
		echo "No hay Empresas Creadas...";
}

echo "</font></body>";
echo "</html>";
?>