<script>
	function NuevoAbono(numfac) {
			parent.location.href="NuevoAbono.php?numfac=" + numfac;
		}


function validar_monto(salact,monabo)
			{
	if (monabo < salact ){

		alert("Atencion, el abono es mayor que el saldo ")
			
			} else {
				alert("Atencion, el abono es memor al saldo:\n\n"+monabo);
	
				}
		}
				///////////////////////////////////////////////////////MASCARA NUMERICA //////////////////////////////////////////////
		




salact=""
monabo=""
//nombre del primer campo en la secuencia
siguienteCampo = ""
//nombre del formlario
nombreForm = ""

//funcion que gestiona el evento
function TelcaPulsada1( e ) {

   if ( window.event != null)				//IE4+
      tecla = window.event.keyCode;
   else if ( e != null ) 				//N4+ o W3C compatibles
      tecla = e.which;
   else
      return;
	
   if (tecla == 13) { 					//se pulso enter
      if ( siguienteCampo == 'fin' ) {			//fin de la secuencia, hace el submit
        validar_Monto(salact,monabo);		//eliminar este alert para uso normal
         return false					//sustituir por return true para hacer el submit
      } else { 						//da el foco al siguiente campo
         eval('document.' + nombreForm + '.' + siguienteCampo + '.select()')
         return false
      }
   }
}

document.onkeydown = TelcaPulsada1;			//asigna el evento pulsacion tecla a la funcion
if (document.captureEvents)				//netscape es especial: requiere activar la captura del evento
	document.captureEvents(Event.KEYDOWN)

	
	function pon_prefijo(baseporpagar,basetotpago) {
	parent.document.form_busqueda.saldoporpagar.value=baseporpagar;		
	parent.document.form_busqueda.totalpago.value=basetotpago;
	parent.document.form_busqueda.monabo.value="0.00";
	parent.document.form_busqueda.pagacon.value="0.00";
	parent.document.form_busqueda.vuelto.value="0.00";



}
	
</script>

<html>
<link href="../estilos/estilos.css" type="text/css" rel="stylesheet">
<body onLoad="nobackbutton();">
<?php 

include ("../conexion.php");
  $cdgcli=$_POST["cdgcli"];
  $numrec=$_POST["numrec"];
 
  	$totabo        =0;
	$basesalfac    =0;
	$baseintereses =0;
	$baseabono     =0;
	$baseabonoint  =0;
	$saldo_total   =0;
	$basetotpago   =0;
    $basetotpago2  =0;
    $baseporpagar  =0;
    $basesaldos    =0;
?>

<div id="xdetalleAW">
  <iframe id="frame_datos" name="frame_datos" width="0%" height="0" frameborder="0">
  <ilayer width="0" height="0" id="frame_datos" name="frame_datos"></ilayer>
  </iframe>

  <table class="fuente8" width="100%" cellspacing=0 cellpadding=0 border=0 ID="Table1">
<?php
$contador=0;	
$sel_lineas=" SELECT * FROM pagos_clientes_recibos_lineas WHERE numrec='$numrec' ORDER BY numlinea ASC ";
if ($resultado = $mysqli->query($sel_lineas)) 

    while ($fila = $resultado->fetch_assoc()) {
		
        $numlinea = $fila["numlinea"];
        $salfac   = $fila["salfac"];
      	$numfactura    = $fila["numfac"];
		$numfactura    = substr($numfactura, -10);
		$numfac   = $fila["numfac"];
		$monabo   = $fila["monabo"];
		$totfac   = $fila["totfac"];
		$monint   = $fila["monint"];
		$intfac   = $fila["intfac"];
		$fecfac   = $fila["fecfac"];
		$fecfac= implode("-", array_reverse(explode("-", $fecfac)));

	
	$totabo=$monabo+$monint;
	$basesalfac=$basesalfac+$totfac;
	$baseintereses=$baseintereses+$intfac;
	$baseabono=$monabo+$baseabono;
	$baseabonoint=$monint+$baseabonoint;


		if ($contador % 2) { $fondolinea="itemParTabla"; } else { $fondolinea="itemImparTabla"; } ?>
			<tr class="<?php echo $fondolinea?>">
				<td width="8%"><div align="center"><?php echo $numfactura?></div></td>
				<td width="8%"><div align="center"><?php echo $fecfac?></div></td>
				<td width="10%"><div align="right"><?php echo number_format($totfac,2,".",",")?></div></td>
				<td width="10%"><div align="right"><?php echo number_format($intfac,2,".",",")?></div></td>
				<td width="10%"><div align="right"><?php echo number_format($monabo,2,".",",")?></div></td>
				<td width="10%"><div align="right"><?php echo number_format($monint,2,".",",")?></div></td>
				<td width="10%"><div align="right"><?php echo number_format($totabo,2,".",",")?></div></td>
				<td width="10%"><div align="right"><?php echo number_format($salfac,2,".",",")?></div></td>
		    </tr>
		
<?php 
$basetotpago=$baseabono+$baseabonoint;
$basesaldos=$basesalfac-$baseabono;
$baseporpagar=$basesalfac+$baseintereses;
$basetotpago=number_format($basetotpago,2,".",",");
 

if ($result = $mysqli->query("SELECT * FROM pagos_clientes_recibos_lineastmp   WHERE numrec='$numrec'" )) {
   $filas = $result->num_rows;
   $result->close();

$contador++;
}

	
}


?>


</table>
<blockquote>&nbsp;	</blockquote>
</div>

<div id="ztotalesawrecibos" >
			<table width="100%" border=0  cellpadding=0 cellspacing=0>
			  <tr>
			    <td width="15%" bgcolor="#FFFFFF" >TOTALES</td>
			    <td width="8%" align="right">&nbsp;</td>
			    <td width="10%" align="right"><input  border="0" name="basesalfac"  class="cajaGrande" type="text" id="basesalfac" style='text-align:right;' value="<?php echo number_format($basesalfac,2,".",",");?>" align="right" readonly></td>
			    <td width="11%" align="right"><input  name="baseintereses" class="cajaGrande" style='text-align:right;' type="text" id="baseintereses"  value="<?php echo number_format($baseintereses,2,".",",");?>" align="right"  border="0" readonly></td>
			    <td width="12%" align="right"><input  name="baseabono"  class="cajaGrande"style='text-align:right;' type="text" id="baseabono"  value="<?php echo number_format($baseabono,2,".",",");?>" align="right" readonly>			      <b></td>
			    <td width="10%"  align="right"><input  name="baseabonoint" type="text" id="baseabonoint"  class="cajaGrande"style='text-align:right;' value="<?php echo number_format($baseabonoint,2,".",".");?>"  align="right" readonly></td>
			    <td width="10%"  align="right"><input   name="basetotpago" class="cajaGrande" style='text-align:right;' type="text" id="basetotpago"  value="<?php echo $basetotpago;?>" readonly></td>
			    <td width="9%"  align="right"><input name="basesaldos" type="text"  class="cajaGrande" id="basesaldos" style='text-align:right;' value="<?php echo number_format($basesaldos,2,".",",");?>" readonly>			    </td>
	  </tr>
			</table>
     
		
</div>

</body>
</html>