<?
session_start();
require('../valtiempoinact.php');
require("../conectar.php");
require("libFormato.php");
$idcliente=$_GET["idcliente"];
$idrenta=$_GET["idrenta"];

/*$url = "http://www.sat.gob.mx/sitio_internet/home.asp";
$palabra = "Tipo de cambio";
$x = 1;
$fd = @fopen($url, "r");
while($line=@fgets($fd,1000))
     {
      $pos = strpos ($line, $palabra);
	  if($pos)
	    {
		 $line;
		 $glosa = " ";
		 $line2=fgets($fd,1000);
		 $valor=strip_tags($glosa.trim($line));
		  function fPasarNumero($str)
		 {
		  $caracteres ="%[^0-9 \. \- ]%";
		  $str=preg_replace($caracteres,"",$str);
		  return $str;
		 }
		 $convmxn=fPasarNumero($valor);
		 $convmxn=str_replace(" ","",$convmxn);
		 $convmxn=round($convmxn,2);
		}
     }
	 @fclose($fd);*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
	<script language='javascript' src="js/popcalendar.js"></script> 
	<script>
	 function abrir(page, name) {
	          newWindow = window.open(page,name,'directories=no,location=no,status=no,scrollbars=yes,width=1000px,height='+screen.height+',left=0,top=0');
  	          newWindow.creator=self;
  	          newWindow.focus(); 
             }
	</script>
	<style>
		     .cont-busc{position:relative;width:850px;height:auto;min-height:400px !important;font-family:arial;color:#086A87;top:10px;overflow-x:hidden;margin:auto;}
			  .cont-busc .bar-busc{position:relative;width:900px;height:90px;font-family:arial;color:#086A87;top:0px;margin:auto;}
			  .cont-res{position:relative;width:900px;font-family:arial;color:#086A87;top:0px;margin:auto;}
			  .datos{border:0;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;-khtml-border-radius: 5px;border-collapse: collapse;color:#0d0d0d;font-family:arial;}
			  .datos .tl{-moz-box-shadow:inset 0 0 20px #000000;-webkit-box-shadow: inset 0 0 20px #000000;box-shadow: inset 0 0 20px #000000;}
			  .datos .trs{min-height:30px !important;max-height:30px !important;height:30px !important;background:url(images/tcancion.jpg) repeat-x;color:#ffffff;font-size:12px;}
			  .datos .tl .link{-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;-khtml-border-radius: 5px;background:#86B404;padding:3px;text-decoration:none;float:left;margin-left:10px;font-size:11px;}
			  .datos .tl .link:hover{background:#A5DF00;}
              .datos .trsb{min-height:15px !important;max-height:15px !important;height:15px !important;background:url(images/tcancion2.png);color:#58D3F7;font-size:12px;}
			  .datos .trsb td{border-left:solid 1px #6E6E6E;}
			  .datos .trsb td:first-child{border-left:none;}
			  .datos .tr{min-height:20px !important;max-height:20px !important;height:20px !important;background:#ffffff;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:13px;}
			  .datos .trb{min-height:20px !important;max-height:20px !important;height:20px !important;background:#ffffff;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:13px;}
			  .datos .trb td{border-left:solid 1px #D8D8D8;padding-left:10px;}
			  .datos .trb td:first-child{border-left:none;}
			  .datos .trssb{min-height:15px !important;max-height:15px !important;height:15px !important;background:url(images/tcancion2.png);color:#848484;}	
			  .datos .tr td{border-left:solid 1px #D8D8D8;padding-left:10px;}
			  .datos .tr td:first-child{border-left:none;}
	          .datos .tr:hover{background:#01A9DB;color:#ffffff;}	
	          .datos .tr:hover a{color:#ffffff;}
              .datos .tr1{min-height:20px !important;max-height:20px !important;height:20px !important;background:#E0F8F7;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:13px;}	
              .datos .tr1 td{border-left:solid 1px #D8D8D8;padding-left:10px;}
			  .datos .tr1 td:first-child{border-left:none;}
	          .datos .tr1:hover{background:#01A9DB;color:#ffffff;}	
	          .datos .tr1:hover a{color:#ffffff;}	
			  .datos .activo{min-height:20px !important;max-height:20px !important;height:20px !important;background:#F3E2A9;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:13px;}
			  .ipt{border:none;background:none;color:#ffffff;font-weight:bold;text-align:right;}
			  .loading{position:fixed;left:50%;top:50%;width:250px;height:70px;margin-left:-125px;margin-top:-35px;display:none;background:url(images/bkloading.png);background-repeat:no-repeat;color:#ffffff;padding-top:25px;text-align:center;font-family:arial;font-size:12px;}
               .rentas{position:absolute;top:40px;width:800px;left:50%;margin-left:-421px;border:solid 1px  #D8D8D8; background:#FFFFFF; display:none;padding:20px;-Moz-box-shadow: 0 0 85px #000;-webkit-box-shadow: 0 0 85px #000; box-shadow: 0 0 85px #000;}
               .rentatab{border-collapse:collapse;color:#0d0d0d;font-family:arial;font-size:12px;}
               .rentatab .filatit{min-height:20px !important;max-height:20px !important;height:20px !important;background:#D8D8D8;border-top:solid 1px #D8D8D8;font-size:13px;}			   
               .rentatab .fila{min-height:20px !important;max-height:20px !important;height:20px !important;background:#ffffff;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:12px;}
               .rentatab .fila td{border-left:solid 1px #D8D8D8;padding-left:5px;}
               .rentatab .fila td:first-child{border-left:none;}
               .cerrar{float:right;margin-top:-20px;margin-right:-20px;}			   
	     </style>
	     <script>
		 var inc=1;
     var ids=new Array();
     function crearpago(idcont,div,fe,fs){
	      //idconr=id de la tabla
	      //div=divisa
	      //fe=fecha entrada
	      //fs=fecha salida
	     idn=inc;
		 ids[idn-1]=idn;
	     var marco=document.getElementById("pagos"+idcont);
		 var tr,td;
		 tr=objeto("tr","f"+idn,"","","trs");
		 td=objeto("td","","","","","center");
		 inp=inputs("text","fechareg"+idn,"fechareg[]","<?echo date("Y-m-d");?>","6","");
		 inp.setAttribute('onclick',"popUpCalendar(this, forma.fechareg"+idn+", 'yyyy-mm-dd');")
		 inp.setAttribute('readonly',"true");
		 a=document.createElement("a");
		 a.innerHTML="<img src='img/cal.gif'>"
		 a.setAttribute("href","javascript:popUpCalendar(document.getElementById('fechareg"+idn+"'), forma.fechareg"+idn+", 'yyyy-mm-dd');");
		 td.appendChild(inp);
		 td.appendChild(a);
		 tr.appendChild(td);
		 
		 td=objeto("td","","","","","center");
		 inp=inputs("text","cantidad"+idcont+idn,"cantidad[]","","6","");
		 inp.setAttribute('onkeyup',"calcula('"+idn+"','"+idcont+"')");
		 td.appendChild(inp);
		 tr.appendChild(td);
		 
		 td=objeto("td","","","","","center");
		 td.innerHTML="<select name='moneda[]' id='moneda"+idcont+idn+"' style='width:50px;font-size:10.5px;' onchange=\"calcula('"+idn+"','"+idcont+"')\"><option value=''></option><option value='USD'>USD</option><option value='MXN'>MXN</option></select>";
		 tr.appendChild(td);
		 
		 td=objeto("td","","","","","center");
		 td.innerHTML=" $";
		 inp=inputs("text","divisa"+idcont+idn,"divisa[]",div,"6","ipt");
		 inp.setAttribute('readonly','true');
		 td.appendChild(inp);
		 tr.appendChild(td);

		 td=objeto("td","","","","","center");
		 td.innerHTML="<select name='formadepago[]' id='formadepago"+idn+"' style='width:70px;font-size:10.5px;'><option value=''></option><option value='EFECTIVO'>EFECTIVO</option><option value='TERMINAL'>TERMINAL</option><option value='TRANSFERENCIA'>TRANSFERENCIA</option><option value='PAGO ELECTRONICO'>PAGO ELECTRONICO</option></select>";
		 tr.appendChild(td);
		 
		 td=objeto("td","","","","","center");
		 td.innerHTML="<select name='concepto[]' id='concepto"+idcont+idn+"' style='width:70px;font-size:10.5px;' onchange=\"calcula('"+idn+"','"+idcont+"')\"><option value=''></option><option value='RENTA'>RENTA</option><option value='DEPOSITO'>DEPOSITO</option></select>";
		 tr.appendChild(td);
		 
		 td=objeto("td","","","","","center");
		 inp=inputs("text","fentrada"+idn,"fentrada[]",fe,"6","ipt");
		 inp.setAttribute('readonly',"true");
		 td.appendChild(inp);
		 tr.appendChild(td);
		 
		 td=objeto("td","","","","","center");
		 inp=inputs("text","fsalida"+idn,"fsalida[]",fs,"6","ipt");
		 inp.setAttribute('readonly',"true");
		 td.appendChild(inp);
		 tr.appendChild(td);
		 
		 td=objeto("td","","","","","center");
		 a=document.createElement("a");
		 a.href="javascript:remover("+idn+",'"+idcont+"')";
		 a.innerHTML="<img src='images/cerrardiv.png' width='15' height='15'>";
		 td.appendChild(a);
		 tr.appendChild(td);
		 
		 marco.appendChild(tr);
		 var nopagos=document.getElementById("nopagos"+idcont).value;
		 document.getElementById("nopagos"+idcont).value=parseInt(nopagos)+1;
		 inc++;
	 }
	 
	 
	 function remover(id,idcont){	
	     var marco=document.getElementById("pagos"+idcont);
         marco.removeChild(document.getElementById("f"+id));
		 calcula(id,idcont);
		  var nopagos=document.getElementById("nopagos"+idcont).value;
		 document.getElementById("nopagos"+idcont).value=parseInt(nopagos)-1;
	 }
	 function objeto(t,i,a,h,c,al){
	     //   t = tipo de elemento
	     //   i = id de elemento
	     //   a = ancho de elemento
	     //   h = altura de elemento
	     //   c = clase de elemento
	     //   al = align de elemento
	     //   n = nombre de elemento
	     e=document.createElement(t);
		 e.id=i;
		 e.setAttribute('width',a);
		 e.setAttribute('height',h);
		 e.setAttribute('class',c);
		 e.setAttribute('align',al);
		 return e;
	 }
	 function inputs(t,i,n,v,s,c){
	     //   t = tipo de input
	     //   i = id de input
	     //   n = nombre de input
	     //   v = valor de input
	     //   s = size de input
	     e=document.createElement("input");
		 e.type=t;
		 e.id=i;
		 e.name=n;
		 e.value=v;
		 e.size=s;
		 e.setAttribute("class",c);
		 return e;
	 }
	
	function calcula(id,idtab){
	 var totalpagardep=document.getElementById("totaldep"+idtab).value;
	 var depositousd=document.getElementById("pagadousddep"+idtab);
	 var pagadousddeph=document.getElementById("pagadousddeph"+idtab);
	 var depositomxn=document.getElementById("pagadomxndep"+idtab);
	 var pagadomxndeph=document.getElementById("pagadomxndeph"+idtab);
	 
	 var totalpagar=document.getElementById("total"+idtab).value;
	 var pagadousd=document.getElementById("pagadousd"+idtab);
	 var pagadousdh=document.getElementById("pagadousdh"+idtab);
	 var pagadomxn=document.getElementById("pagadomxn"+idtab);	 
	 var pagadomxnh=document.getElementById("pagadomxnh"+idtab);
	 var restante=document.getElementById("restante"+idtab);
	 
	
	 
	 var restantedep=document.getElementById("restantedep"+idtab);
	var pagadous=0;
	var pagadomx=0;
	var depositous=0;
	var depositomx=0;
	var cont=0;
	for(i=1;i<=inc;i++){
	     if(document.getElementById("cantidad"+idtab+i)){
             var cant=document.getElementById("cantidad"+idtab+i).value;
	         var moneda=document.getElementById("moneda"+idtab+i).value;
	         var divisa=document.getElementById("divisa"+idtab+i).value;
	         var concepto=document.getElementById("concepto"+idtab+i).value;	
	         if(cant==""){
	         cant=0;
	         }
	 
	         if(moneda!=""){
	             if(concepto=="RENTA"){
		             if(moneda=="USD"){
			             pagadous= pagadous+parseFloat(pagadousdh.value)+parseFloat(cant);
			            }
			         if(moneda=="MXN"){
			             pagadomx= pagadomx+parseFloat(pagadomxnh.value)+parseFloat(cant);
			            }
		            }
				if(concepto=="DEPOSITO"){
				     if(moneda=="USD"){
					     depositous=depositous+parseFloat(pagadousddeph.value)+parseFloat(cant);
					    }
					 if(moneda=="MXN"){
			             depositomx= depositomx+parseFloat(pagadomxndeph.value)+parseFloat(cant);
			            }
				    }
	            }
				cont++;
	        }
	   }
	    
		if(cont>0){
	    pagadousd.value= pagadous.toFixed(2);
	    pagadomxn.value= pagadomx.toFixed(2);
		
	    depositousd.value= depositous.toFixed(2);
	    depositomxn.value= depositomx.toFixed(2);
		
		pagadomxnusd=parseFloat(pagadomxn.value/divisa);
		
		depositomxnusd=parseFloat(depositomxn.value/divisa);
		}else{
		pagadousd.value= cont.toFixed(2);
	    pagadomxn.value= cont.toFixed(2);
		
	    depositousd.value= cont.toFixed(2);
	    depositomxn.value= cont.toFixed(2);
		
		pagadomxnusd=0;
		depositomxnusd=0;
		}
		
		pagadoreal=parseFloat(pagadousd.value)+pagadomxnusd;
		resto=totalpagar-pagadoreal.toFixed(2);
		restante.value=resto.toFixed(2);
		
		
		depositoreal=parseFloat(depositousd.value)+depositomxnusd;
		restodep=totalpagardep-depositoreal.toFixed(2);
		restantedep.value=restodep.toFixed(2);
	}
	     </script>
<!-- PARA LA FECHA DE CIERRE -->
<script language="javascript" src="calendario_cierre/calendar_db.js"></script>
<link type="text/css" href="calendario_cierre/calendar.css" rel="stylesheet" />
<!-- PARA LA FECHA DE CIERRE -->
    </head>
    <body>
	 <?
	    if($_GET["p"]=="1"){
	     if(isset($_POST["registrar"])){
			 $fechareg=$_POST[fechareg];
			 $cantidad=$_POST[cantidad];
			 $moneda=$_POST[moneda];
			 $divisa=$_POST[divisa];
			 $formadepago=$_POST[formadepago];
			 $concepto=$_POST[concepto];
			 $fentrada=$_POST[fentrada];
			 $fsalida=$_POST[fsalida];
			 $total=$_POST[total];
			 $nopagos=$_POST[nopagos];
			 $pagadousd=$_POST[pagadousd];
			 $pagadomxn=$_POST[pagadomxn];
			 $restante=$_POST[restante];
			 $totaldep=$_POST[totaldep];
			 $pagadousddep=$_POST[pagadousddep];
			 $pagadomxndep=$_POST[pagadomxndep];
			 $restantedep=$_POST[restantedep];
			 
			 foreach($idconcepto as $indice=>$valor){
			 for($i=0;$i<$nopagos[$indice];$i++){
			     $idconcepto[$indice];
			     $propiedad[$indice];
			     $clave[$indice];
			     $total[$indice];
			     $pagadousd[$indice];
			     $pagadomxn[$indice];
			     $restante[$indice];
			     $totaldep[$indice];
			     $pagadousddep[$indice];
			     $pagadomxndep[$indice];
			     $restantedep[$indice];
			     $fechareg[$i];
			     $cantidad[$i];
			     $moneda[$i];
			     $divisa[$i];
			     $formadepago[$i];
			     $concepto[$i];
			     $fentrada[$i];
			     $fsalida[$i];
				 
				 $sql="INSERT INTO pagos(id_pago,id_renta,id_concepto,id_emp,fecha,formapago,monto,divisa,concepto,tipo_moneda,f_entrada,f_salida,propiedad,clave) VALUES ('','$idrenta','$idconcepto[$indice]','$_SESSION[usuario_id]',' $fechareg[$i]','$formadepago[$i]','$cantidad[$i]','$divisa[$i]','$concepto[$i]','$moneda[$i]','$fentrada[$i]','$fsalida[$i]','$propiedad[$indice]','$clave[$indice]')";
				 if(mysql_query($sql)){
				   /*  if($concepto[$i]=="RENTA"){
					     
					     if($restante[$indice]>0){
						    $status="ANTICIPO";
						 }
						 if($restante[$indice]<=0){
						    $status="PAGADO";
						 }
						 
				         $sql="UPDATE conceptos SET status_renta='$status' WHERE id_concepto='$idconcepto[$indice]'";
				         mysql_query($sql);*/
						?>
						<script>
						 abrir("imprimepago.php?idcliente=<?echo $idcliente?>&idrenta=<?echo $idrenta?>&hoy=1","Imprimir pago");
						</script>
						<?
					 /*}*/
				 }
			    }
			 }
			 ?>
			 <script>alert('EL PAGO SE HA REGISTRADO CORRECTAMENTE');</script>
			 <?
		 }
    }
	 ?>
	 <form name="forma" action="pagos.php?idcliente=<?echo $idcliente?>&idrenta=<?echo $idrenta?>&p=1" method="post">
	 <?
	  $sql="SELECT c.id_concepto as idc,c.dia_inicio as fe,c.tipomoneda as tipomoneda, c.dia_salida as fs, cp.nombre as nombre, d.clave as clave, c.subtotal as total, c.deposito as deposito,c.id_departamento as depto,c.id_complejo as propiedad,c.divisa as divisa FROM conceptos as c INNER JOIN complejo as cp ON c.id_complejo=cp.id_complejo INNER JOIN departamentos as d ON c.id_departamento=d.id_departamento WHERE id_cliente='$idcliente' AND id_renta='$idrenta'";
	 $con=mysql_query($sql);
	 $i=1;
	 //echo $convmxn+0.40
	 while($ls=mysql_fetch_array($con)){
	 $convmxn=$ls['divisa'];
	 ?>
	    <table class="datos" width="800" align="center" id="pagos<?echo $i?>">
		     <tr>
			    <td colspan="9" class="tl" align="center"><a class="link" href="javascript:crearpago('<?echo $i?>','<?echo $convmxn;?>','<?echo $ls["fe"]?>','<?echo $ls["fs"]?>');">agregar pago</a> Departamento <?echo $ls["nombre"]." ".$ls["clave"];?>
				<input type="hidden" name="idconcepto[]" id="idconcepto<?echo $i?>" value="<?echo $ls["idc"];?>">
				<input type="hidden" name="propiedad[]" id="propiedad<?echo $i?>" value="<?echo $ls["propiedad"];?>">
				<input type="hidden" name="clave[]" id="clave<?echo $i?>" value="<?echo $ls["depto"];?>">
				<a class="link" href="javascript:abrir('imprimepago.php?idcliente=<?echo $idcliente?>&idrenta=<?echo $idrenta?>','Pagos')">imprimir pagos</a>
				</td>
		     </tr>
             <tr class="trsb">
	            <td align="center">Fecha</td>
	            <td align="center">Cantidad</td>
	            <td align="center">Moneda</td>
	            <td align="center">Divisa</td>
	            <td align="center">Forma de pago</td>
	            <td align="center">Concepto</td>
	            <td align="center">F. de ingreso</td>
	            <td align="center">F. de salida</td>
	            <td align="center">Borrar</td>
             </tr>
        </table>
	    <table class="datos" width="800" align="center" id="totales">
		    <tr class="trsb"><td colspan="2" align="right">Detalles  de pago ESTANCIA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>
		    <tr class="trs">
	            <td align="right">Monto a pagar</td>
	            <td align="right" width="200">$<input type="text" name="total[]" size="10"value="<?if($ls["tipomoneda"]=="MXN"){echo round($ls["total"]/$ls["divisa"],2);}else{echo $ls["total"];}?>" id="total<?echo $i?>" class="ipt" readonly>USD</td>
             </tr>
			 <?
			 $sql="SELECT * FROM pagos WHERE id_concepto='$ls[idc]' AND id_renta='$idrenta' AND concepto='RENTA'";
			 $re=mysql_query($sql);
			 $no=0;
			 $pagadousdv=0;
			 while($l=mysql_fetch_array($re)){
			     $mon=$l["tipo_moneda"];
				 $cantidad=$l["monto"];
				 if($mon=="USD"){
				     $pagadousdv=$pagadousdv+$cantidad;
				 }
				 if($mon=="MXN"){
				     $pagadomxnv=$pagadomxnv+$cantidad;
					 $montousd=$cantidad/$l["divisa"];
					 $pagadomxnvusd=$pagadomxnvusd+$montousd;
				 }
				 $no++;
			 }
			 ?>
			 <tr class="trs">
	            <td align="right">Monto pagado USD</td>
	            <td align="right"  width="200">
				     $<input type="text" name="pagadousd[]" size="10" value="<?echo Moneda2($pagadousdv);?>" id="pagadousd<?echo $i?>" class="ipt" readonly>USD
				     <input type="hidden" name="pagadousdh[]" size="10" value="<?echo Moneda2($pagadousdv);?>" id="pagadousdh<?echo $i?>" class="ipt" readonly>
				</td>
             </tr>
			 <tr class="trs">
	            <td align="right">Monto pagado MXN</td>
	            <td align="right" width="200">$<input type="text" name="pagadomxn[]" size="10" value="<?echo Moneda2($pagadomxnv);?>" id="pagadomxn<?echo $i?>" class="ipt" readonly>MXN<input type="hidden" name="pagadomxnh[]" size="10" value="<?echo Moneda2($pagadomxnv);?>" id="pagadomxnh<?echo $i?>" class="ipt" readonly>
				</td>
             </tr>
			 <tr class="trs">
	            <td align="right">Restante</td>
	            <td align="right">$<input type="text" name="restante[]" size="10" value="<?echo Moneda2($ls["total"]-($pagadousdv+$pagadomxnvusd));?>" id="restante<?echo $i?>" class="ipt" readonly>USD</td>
             </tr>
			   <tr class="trsb"><td colspan="2" align="right">Detalles  de pago DEPOSITO EN GARANTIA &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>
		    <tr class="trs">
	            <td align="right">Monto a pagar</td>
	            <td align="right" width="200">$<input type="text" name="totaldep[]" size="10"value="<?echo $ls["deposito"]?>" id="totaldep<?echo $i?>" class="ipt" readonly>USD</td>
             </tr>
			 <?
			 $pagadomxnv=0;
			 $pagadousdv=0;
			 $cantidad=0;
			 $montousd=0;
			 $mon="";
			 $pagadomxnvusd=0;
			 $sql="SELECT * FROM pagos WHERE id_concepto='$ls[idc]' AND id_renta='$idrenta' AND concepto='DEPOSITO'";
			 $re=mysql_query($sql);
			 while($l=mysql_fetch_array($re)){
			     $mon=$l["tipo_moneda"];
				 $cantidad=$l["monto"];
				 if($mon=="USD"){
				     $pagadousdv=$pagadousdv+$cantidad;
				 }
				 if($mon=="MXN"){
				     $pagadomxnv=$pagadomxnv+$cantidad;
					 $montousd=$cantidad/$l["divisa"];
					 $pagadomxnvusd=$pagadomxnvusd+$montousd;
				 }
				 //$no++;
			 }
			 ?>
			 <tr class="trs">
	            <td align="right">Monto pagado USD<input type="hidden" name="nopagos[]" id="nopagos<?echo $i?>" value="0"></td>
	            <td align="right"  width="200">
				     $<input type="text" name="pagadousddep[]" size="10" value="<?echo Moneda2($pagadousdv);?>" id="pagadousddep<?echo $i?>" class="ipt" readonly>USD
				     <input type="hidden" name="pagadousddeph[]" size="10" value="<?echo Moneda2($pagadousdv);?>" id="pagadousddeph<?echo $i?>" class="ipt" readonly>
				</td>
             </tr>
			 <tr class="trs">
	            <td align="right">Monto pagado MXN</td>
	            <td align="right" width="200">
				     $<input type="text" name="pagadomxndep[]" size="10" value="<?echo Moneda2($pagadomxnv);?>" id="pagadomxndep<?echo $i?>" class="ipt" readonly>MXN
				     <input type="hidden" name="pagadomxndeph[]" size="10" value="<?echo Moneda2($pagadomxnv);?>" id="pagadomxndeph<?echo $i?>" class="ipt" readonly>
				</td>
             </tr>
			 <tr class="trs">
	            <td align="right">Restante</td>
	            <td align="right">$<input type="text" name="restantedep[]" size="10" value="<?echo Moneda2($ls["deposito"]-($pagadousdv+$pagadomxnvusd));?>" id="restantedep<?echo $i?>" class="ipt" readonly>USD</td>
             </tr>
		</table>
		<?
		 $i++;
		 	 $pagadomxnv=0;
			 $pagadousdv=0;
			 $cantidad=0;
			 $montousd=0;
			 $mon=0;
			 $pagadomxnvusd=0;
     	}
		?>
		 <table class="datos" width="800" align="center">
		     <tr class="trs">
			     <td colspan="2" align="center"><input type="submit" name="registrar" id="registrar" value="Guardar"></td>
	         </tr>
		 </table>
     </form>	     
    </body>
</html>