<?php
	


		session_start();
		include('../conexion.php'); 

	if($_SESSION['tipo_usu']=='a' or $_SESSION['tipo_usu']=='u'  or $_SESSION['tipo_usu']=='c'){
		}else{
			header('location:acceso_denegado.php');
		}



 $numrec=$_GET["numrec"];


$query="SELECT * FROM terminal_pagos_clientes WHERE numrec='$numrec'";

$rs_busqueda = $mysqli->query($query);
$fila = $rs_busqueda->fetch_array();
$cdgcli = $fila["cdgcli"];	
$fecrec = $fila["fecrec"];
$fecrec= implode("-", array_reverse(explode("-", $fecrec))); 
$monabo = $fila["montot"];
$dsccli = $fila["dsccli"];
$salant = $fila["salant"];
$salact = $fila["salact"];
$detrec = $fila["detrec"];



?>
<html>
	<head>
		<title>Facturas</title>
		<link href="../estilos/estilos.css" type="text/css" rel="stylesheet">
		<link href="../calendario/calendar-blue.css" rel="stylesheet" type="text/css">
      		<script type="text/JavaScript" language="javascript" src="../calendario/calendar.js"></script>
		<script type="text/JavaScript" language="javascript" src="../calendario/lang/calendar-sp.js"></script>
		<script type="text/JavaScript" language="javascript" src="../calendario/calendar-setup.js"></script>
          
        	<script src="../jquery/jquery-1.3.2.js" type="text/javascript"></script>
		<script src="../jquery/jquery.maskedinput-1.2.2.js" type="text/javascript"></script>
		<script type="text/javascript" src="../funciones/validar.js"></script>
        


  <script src="..//jquery-maskmoney/src/jquery.maskMoney.js" type="text/javascript"></script>

		<script language="javascript">
		



  $(function() {
   // $('#currency').maskMoney();
//$("#monabo").maskMoney({thousands:',', decimal:'.', allowZero:true, prefix: ' '});
//$("#monabo").maskMoney({thousands:',', decimal:'.',precision:2});
//$("#salact").maskMoney({thousands:',', decimal:'.',precision:2});
//$("#salant").maskMoney({thousands:',', decimal:'.',precision:2});
//$("#totalpago").maskMoney({thousands:',', decimal:'.',precision:2});

	  })



  window.onkeydown = tecla;

  function tecla(event) {
  if( event.keyCode > 111 && event.keyCode < 123 || event.keyCode ==27	) {    num = event.keyCode;

if(num==113)abreVentana(); // f3  busqueda de clientes 
if(num==118){ validar_Recibo(); } // f8 guardar e imprimir 
//if(num==120){ ConsultarArticulo();  }//f9 guardar e imprimir
///if(num==121) validar_Recibo();
	    //f10 guardar e imprimir 

  }  
  }

		
		
		
		

	
	
		
		
		var cursor;
		if (document.all) {
		// Está utilizando EXPLORER
		cursor='hand';
		} else {
		// Está utilizando MOZILLA/NETSCAPE
		cursor='pointer';
		}
		
	
		
		function nueva_Recibo() {
			location.href="Nuevo_Recibo.php";
		}
		
		function buscar() {
			var cadena;
			cadena=hacer_cadena_busqueda();
			document.getElementById("cadena_busqueda").value=cadena;
			document.getElementById("form_busqueda").submit();
			  document.getElementById("monabo").value="";
			  document.getElementById("monabo").select();

			  

		}
		
		
		
		
		function hacer_cadena_busqueda() {
			var cdgcli=document.getElementById("cdgcli").value;
			var dsccli=document.getElementById("dsccli").value;
			//var numfactura=document.getElementById("numfactura").value;			
			//var cboEstados=document.getElementById("cboEstados").value;
			//var fechainicio=document.getElementById("vehpla").value;
			//var fechafin=document.getElementById("fechafin").value;
			var cadena="";
			cadena="~"+cdgcli+"~"+dsccli+"~";
			return cadena;
			}



	

/////////////////////////////////////////////////////////  validar abono ////////////////////////////////////////////////


			
		
		function limpiar() { 
			document.getElementById("form_busqueda").reset();
			document.getElementById("form_busqueda").submit();
		}
		
		function abreVentana(){
			miPopup = window.open("ver_clientes2.php","miwin","width=700,height=650,scrollbars=yes");
			document.getElementById("monabo").select();
			miPopup.focus();
		}
		
		function validarcliente(){
			var codigo=document.getElementById("cdgcli").value;
			miPopup = window.open("comprobarcliente.php?cdgcli="+codigo,"frame_datos1","width=700,height=80,scrollbars=yes");
			document.getElementById("monabo").select();
			
		}	
		
		
		function ceros(obj) {
		  numCeros = '00000'; // pon el nº de ceros que necesites
		  valor = obj.value;
		  valor = numCeros.substring(0,numCeros.length-valor.length)+valor;
		  obj.value = valor; 
		
		}
		
		
				


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

//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_Recibo();			//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 validar_Recibo()
			{
				
				
				if (confirm(" Desea Aplicar el Abono ? "))
	  
	             document.getElementById('bloquea').style.display='block';
				
				var mensaje="";
				if (document.getElementById("dsccli").value=="") mensaje+="  - Cliente\n";
				if (document.getElementById("monabo").value=="") mensaje+="  - Total del Abono\n";
				if (document.getElementById("monabo").value=="0.00") mensaje+="  - Total del Abono\n";
				if (document.getElementById("monabo").value=="0") mensaje+="  - Total del Abono\n";
		

								
				if (mensaje!="") {
				
					alert("Atencion, Los Siguientes campos no pueden estar en blanco:\n\n"+mensaje);
					
					 document.getElementById('bloquea').style.display='none';
			
				} else {
			
		
					document.getElementById("form_busqueda").submit();
					
		
	
			}}
			
			
			
				
						function cancelar() {
			location.href="index.php";
		}



   	function inicio() {
			
			

			document.getElementById("cdgli").select();
		}

 

				
				
  
			
	
	
	
		

		</script>
	</head>
			<body onLoad=" inicio();  nobackbutton();">
		<div id="">
			<div id="zonaVentanas">
				<div align="center">
				  <div id="" class="contenidoRecibo">
				<form id="form_busqueda" name="form_busqueda" method="post" action="guardar_recibo.php" >
					<table class="fuente8" width="100%" cellspacing=0 cellpadding=0 border=0>					
						<input id="accion" name="accion" value="alta" type="hidden">
						<input name="numrec"  id="numrec" value="<?php echo $numrec?>"  type="hidden">
				
						<tr>
						  <td>&nbsp;</td>
						  <td>&nbsp;</td>
						  <td>&nbsp;</td>
						  <td colspan="2">&nbsp;</td>
						  <td>&nbsp;</td>
						  <td>&nbsp;</td>
						  <td>&nbsp;</td>
						  <td colspan="2">&nbsp;</td>
					  </tr>
						<tr>
						  <td>&nbsp;</td>
						  <td>&nbsp;</td>
						  <td>&nbsp;</td>
						  <td colspan="2">&nbsp;</td>
						  <td>&nbsp;</td>
						  <td>Recibo N. </td>
						  <td><input id="cdgcli2"  autocomplete="off" type="text" class="cajaGrande" name="cdgcli2" maxlength="10" readonly=""  value="<?php echo $numrec?>"  style='text-align:center;'   ></td>
						  <td colspan="2">&nbsp;</td>
					  </tr>
						<tr>
						  <td>&nbsp;</td>
						  <td>&nbsp;</td>
						  <td>&nbsp;</td>
						  <td colspan="2">&nbsp;</td>
						  <td>&nbsp;</td>
						  <td>&nbsp;</td>
						  <td>&nbsp;</td>
						  <td colspan="2">&nbsp;</td>
					  </tr>
						<tr>
						  <td>&nbsp;</td>
						  <td>&nbsp;</td>
						  <td>&nbsp;</td>
						  <td colspan="2">&nbsp;</td>
						  <td width="11%">&nbsp;</td>
						  <td width="8%">Fecha</td>
						  <td><input id="cdgcli3"  autocomplete="off" type="text" class="cajaGrande" name="cdgcli3" maxlength="10" readonly=""  value="<?php echo $fecrec?>"  style='text-align:center;'   ></td>
						  <td colspan="2">&nbsp;</td>
					  </tr>
						<tr>
						  <td width="0%" rowspan="2">&nbsp;</td>
						  <td width="10%">Nombre</td>
						  <td width="0%">&nbsp;</td>
						  <td width="25%">&nbsp;</td>
						  <td width="0%"><div align="right"></div></td>
						  <td>&nbsp;</td>
						  <td>&nbsp;</td>
						  <td width="22%">&nbsp;</td>
						  <td colspan="2" ><div align="left"></div></td>
				      </tr>
						<tr>
						  <td><input id="cdgcli"  autocomplete="off" type="text" class="cajaGrande" name="cdgcli" maxlength="10" readonly=""  value="<?php echo $cdgcli?>"  style='text-align:center;'   ></td>
						  <td colspan="5"><input id="dsccli"  name="dsccli" type="text" class="cajaGrande" maxlength="45"  readonly=""   value="<?php echo $dsccli?>" ></td>
					      <td>&nbsp;</td>
					      <td>&nbsp;</td>
					      <td>&nbsp;</td>
					  </tr>
						<tr>
						  <td rowspan="14">&nbsp;</td>
						  <td colspan="2">&nbsp;</td>
						  <td colspan="5" rowspan="3"><div align="right"></div></td>
						  <td colspan="2" >&nbsp;</td>
					  </tr>
						<tr>
						  <td>&nbsp;</td>
						  <td>&nbsp;</td>
						  <td colspan="2" >&nbsp;</td>
					  </tr>
						<tr>
						  <td colspan="2">&nbsp;</td>
						  <td colspan="2" >&nbsp;</td>
					  </tr>
						
						
						<tr>
						  <td colspan="2">&nbsp;</td>
						  <td colspan="5">&nbsp;</td>
						  <td colspan="2" >&nbsp;</td>
					  </tr>
						
						
						<tr>
						  <td height="18" colspan="7"><div align="center">Saldo Anterior </div></td>
						  <td colspan="2" >&nbsp;</td>
					  </tr>
						<tr>
						  <td height="18" colspan="7"><input  autocomplete="off" name="monabo2" type="text"   class="fuente_pagos" id="monabo2"  style='text-align:center;'  readonly=""  value="<?php echo number_format( $salant,2 ) ?>" onFocus="siguienteCampo ='detrec';" ></td>
						  <td colspan="2" >&nbsp;</td>
					  </tr>
						<tr>
						  <td height="18" colspan="7">&nbsp;</td>
						  <td colspan="2" >&nbsp;</td>
					  </tr>
						<tr>
						  <td height="18" colspan="7"><div align="center">Abono</div></td>
						  <td colspan="2" >&nbsp;</td>
					  </tr>
						<tr>
						  <td height="18" colspan="7"><input  autocomplete="off" name="monabo22" type="text"   class="fuente_pagos" id="monabo22"  style='text-align:center;'  readonly=""  value="<?php echo number_format( $monabo,2 ) ?>" onFocus="siguienteCampo ='detrec';" ></td>
						  <td colspan="2" >&nbsp;</td>
					  </tr>
						<tr>
						  <td height="18" colspan="7">&nbsp;</td>
						  <td colspan="2" >&nbsp;</td>
					  </tr>
						<tr>
						  <td height="18" colspan="7"><div align="center">Saldo Actual </div></td>
						  <td colspan="2" >&nbsp;</td>
					  </tr>
						<tr>
						  <td height="18" colspan="7"><input  autocomplete="off" name="monabo" type="text"   class="fuente_pagos" id="monabo"  style='text-align:center;'  readonly=""  value="<?php echo number_format( $salact,2 ) ?>" onFocus="siguienteCampo ='detrec';" ></td>
						  <td colspan="2" >&nbsp;</td>
					  </tr>
						<tr>
						  <td height="18" colspan="7">&nbsp;</td>
						  <td colspan="2" >&nbsp;</td>
						  <td>&nbsp;</td>
					  </tr>
						<tr>
						  <td height="18" colspan="7"><div align="center">Detalle 
					        <input id="detrec"  name="detrec" type="text" class="fuente_articulos" maxlength="100"   readonly=""  value="<?php echo $detrec?>"    onFocus="siguienteCampo ='fin';" >
						  </div></td>
						  <td colspan="2" >&nbsp;</td>
						  <td>&nbsp;</td>
					  </tr>
						
						<tr>
						  <td height="18" colspan="7">&nbsp;</td>
						  <td colspan="2" >&nbsp;</td>
						  <td>&nbsp;</td>
					  </tr>
						<tr>
						  <td height="18" colspan="7">&nbsp;</td>
						  <td colspan="2" >&nbsp;</td>
						  <td>&nbsp;</td>
					  </tr>
						
						

						<tr>
						  <td colspan="8">&nbsp;</td>
						  <td width="6%">&nbsp;</td>
					  </tr>
						<tr>
						  <td colspan="9">&nbsp;</td>
					  </tr>
						<tr>
						  <td colspan="9">&nbsp;</td>
					  </tr>
						<tr>
						  <td colspan="9">&nbsp;</td>
                        </tr>
				    </table>
					<div id="frmResultado"> </div>
					<input type="hidden" id="iniciopagina" name="iniciopagina">
				    <div id="">
                      <div align="center"><img src="../img/Symbol-Delete_48x48-32.png" alt="Borrar" width="48" height="48" border="0" align="right" class="aCentro" title="Salir" onClick="cancelar()" onMouseOver="style.cursor=cursor">
					  
                          <input id="codfamilia" name="codfamilia" value="<?php echo $codfamilia?>" type="hidden">
                          <input id="codfacturatmp" name="codfacturatmp" value="<?php echo $codfacturatmp?>" type="hidden">
                          <input id="preciototal2" name="preciototal" value="<?php echo $preciototal?>" type="hidden">
                      </div>
			      </div>
				    <input type="hidden" id="cadena_busqueda" name="cadena_busqueda">
				</form>
			  
				<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>
					
					
				<iframe id="frame_datos1" name="frame_datos1" width="0" height="0" frameborder="0">
					<ilayer width="0" height="0" id="frame_datos" name="frame_datos"></ilayer>
					</iframe>
					
			<iframe id="frame_datos3" name="frame_datos3" width="0" height="0" frameborder="0">
					<ilayer width="0" height="0" id="frame_datos3" name="frame_datos3"></ilayer>
					</iframe>


			  <div id="bloquea" class="cargando" style="display:none;">
<img style="margin-left: 5%;margin-top: 15%" alt="Espere..." src="../img/procesando.gif" />

</div>  

			  </form>
			 </div>
		  </div>
    </div>
		
	</body>
</html>
