<script type="text/javascript">
// dias es el total de días trabajados
// sueldo es el sueldo básico del empleado
// indice corresponde al input text que se debe actualizar
var sq;
var dd;
var dv;
function calcula(dias, sueldo_diario, indice) {
sq = document.getElementById('sueldo_quinc' + indice).value = (parseFloat(dias) * parseFloat(sueldo_diario)).toFixed(2);
}
function deducciones(otros_desc, ivss, paro_for, lph, indice2) {
dd= document.getElementById('total_deducc' + indice2).value = (parseFloat(otros_desc) + parseFloat(ivss) + parseFloat(paro_for) + parseFloat(lph)).toFixed(2);
}
function total_dev(otros_ing, sq, dd, indice3) {
dv = document.getElementById('total_deveng' + indice3).value = ((parseFloat(otros_ing) + parseFloat(sq)) - parseFloat(dd)).toFixed(2);
}
function Mostrar()
{
msg="Opcion 1:"+sq+"\n";
msg+="Opcion 2:"+dd+"\n";
alert(msg);
}
function totalizar(){
var chks = document.getElementsByName('total_deveng[]');
var totales = 0;
for(var i = 0; i < chks.length; i++) {
var valor = parseFloat(chks[i].value);
if(isNaN(valor) == false) {
totales += parseFloat(chks[i].value);
}
}
document.getElementById("total").value = totales;
}
</script>
<br />
<?php if($_SESSION['user']==true){ ?>
<form action="nomina_reg.php" method="post" name="form1" >
<table width="750" border="0" class="tabla2">
<tr>
<td colspan="5" class="td2" bgcolor="#95bce2">UNIDAD EDUCATIVA EL MILAGRO DE LA PERLA</td>
</tr>
<tr>
<td colspan="5">NOMINA PARA EL PAGO DE SUELDOS EMPLEADOS</td>
</tr>
<tr>
<td width="26%">
<div class="demo">
<p>Fecha Desde: <input type="text" id="datepicker_1" name="desde" class="fechador"></p>
</div>
</td>
<td width="26%">
<div class="demo">
<p>Fecha Hasta: <input type="text" id="datepicker_2" name="hasta" class="fechador"></p>
</div>
</td>
</tr>
</table>
<br />
<table width="750" border="1" bordercolor="#95bce2" class="tabla3">
<tr bgcolor="#95bce2 ">
<td width="3%" class="td3">Nº</td>
<td width="3%" class="td3">CI</td>
<td width="10%" class="td3">APELLIDOS</td>
<td width="11%" class="td3">NOMBRES</td>
<td width="4%" class="td3">DIAS</td>
<td width="8%" class="td3">SUELDO BÁSICO</td>
<td width="8%" class="td3">SUELDO DIARIO</td>
<td width="8%" class="td3">SUELDO B. QUINCENA</td>
<td width="8%" class="td3">IVSS</td>
<td width="8%" class="td3">PARO FORSOZO</td>
<td width="8%" class="td3">LPH</td>
<td width="8%" class="td3">OTROS DESCUENT</td>
<td width="8%" class="td3">OTROS INGRESOS</td>
<td width="8%" class="td3">TOTAL DEDUCCIONES</td>
<td width="8%" class="td3">TOTAL DEVENGADO</td>
</tr>
<?php
$indice = 1;
$indice2 = 1;
$indice3 = 1;
$rs = mysql_query("SELECT * FROM empleados ORDER BY id_empleado ASC"); }
$ivss = number_format(($result['sueldo_basico']*4/100),2,'.',''); $paro_for = number_format(($result['sueldo_basico']*0.5/100),2,'.',''); $sueldo_diario = number_format(($result['sueldo_basico']/30),2,'.','');
?>
<tr>
<td><?php echo $result['id_empleado']; ?><input type="hidden" name="id_empleado[]" value="<?php echo $result['id_empleado']; ?>" /></td>
<td><?php echo $result['ci']; ?><input type="hidden" name="ci[]" value="<?php echo $result['ci']; ?>" /></td>
<td><?php echo "{$result['papellido']} {$result['sapellido']}"; ?><input type="hidden" name="papellido[]" value="<?php echo $result['papellido']; ?>" /></td>
<td><?php echo "{$result['pnombre']} {$result['snombre']}"; ?><input type="hidden" name="pnombre[]" value="<?php echo $result['pnombre']; ?>" /></td>
<td><input name="dias[]" type="text" id="dias<?php echo $indice; ?>" size="2" value="" onBlur="calcula(this.value, '<?php echo $sueldo_diario; ?>', <?php echo $indice; ?>);" /></td>
<td><label name="sueldo_basico" id="sueldo_basico" size="2" readonly="readonly" value="" ><?php echo $result['sueldo_basico']; ?><input type="hidden" name="sueldo_basico[]" value="<?php echo $result['sueldo_basico']; ?>" /></label></td>
<td><input type="text" name="sueldo_diario[]" id="sueldo_diario" size="5" readonly="readonly" value="<?php echo $sueldo_diario; ?>" ></td>
<td><input name="sueldo_quinc[]" type="text" id="sueldo_quinc<?php echo $indice; ?>" size="5" value="" readonly="readonly" /></td>
<td><input type="text" name="ivss[]" id="ivss" size="3" readonly="readonly" value="<?php echo $ivss; ?>" /></td>
<td><input type="text" name="paro_for[]" id="paro_for" size="3" readonly="readonly" value="<?php echo $paro_for; ?>" ></td>
<td><input type="text" name="lph[]" id="lph" size="3" readonly="readonly" value="<?php echo $lph; ?>" ></td>
<td><input name="otros_desc[]" type="text" id="otros_desc<?php echo $indice2; ?>" size="5" value="" onBlur="deducciones(this.value, '<?php echo $ivss; ?>', '<?php echo $paro_for; ?>', '<?php echo $lph; ?>', <?php echo $indice2; ?>);" /></td>
<td><input name="otros_ing[]" type="text" id="otros_ing<?php echo $indice3; ?>" size="5" value="" onChange="total_dev(this.value, sq, dd, <?php echo $indice3; ?>);" /></td>
<td><input name="total_deducc[]" type="text" id="total_deducc<?php echo $indice2; ?>" size="5" value="" readonly="readonly" /></td>
<td><input name="total_deveng[]" type="text" id="total_deveng<?php echo $indice3; ?>" size="5" value="" readonly="readonly" /></td>
</tr>
<?php
$indice ++;
$indice2 ++;
$indice3 ++;
} // fin de while
?> <tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td class="td3">TOTAL</td>
<td><input type="text" id="total" name="total" size="5" value="" readonly="readonly" onMouseOver="javascript:totalizar();" /></td>
</tr>
</table>
<tr>
<th colspan="2"><input type="submit" name="button" id="button" value="Guardar" /> - <input type="reset" name="Reset" id="button" value="Borrar" />
</th>
</tr>
</form>