<?
session_start();
require('../valtiempoinact.php');
require("../conectar.php");
require("libFormato.php");
extract($_GET);
$idcliente=$_GET["idcliente"];
$idrenta=$_GET["idrenta"];
$hoy=$_GET["hoy"];
?>
<!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/jquery-1.2.6.min.js"></script>
<link rel="stylesheet" href="css/pikaday.css">
<script>
function ver(val,n){
	   if(val=="EP" || val=="TIBJA" || val=="TIBECO" || val=="DECO" || val=="TC ECO" || val=="TC HABI" || val=="TIBHABI" || val=="TD ECO" || val=="TD HABI" || val=="DJA" || val=="EXTRANET" || val == "VA" || val=="CORTESIA" || val=="AIRBNB TRANSFERENCIA" || val=="INTERMEDIARIO DE PAGOS (OXXO,SEVEN)" || val=="NO SHOW"){
	     document.getElementById('moneda'+n).value="MXN";
	   }else{document.getElementById('moneda'+n).value="USD";}
	  }
function depas(id,n){
var origen=document.getElementById(id);
var sel=origen.selectedIndex;
var tx=origen[sel].text;
var v=origen[sel].value;
var destino=document.getElementById("departamento"+n);
destino.options.length = 0;
 if(v==""){destino.disabled=true;destino.length=0;}else{
  destino.disabled=false;
  destino.length=0;
  var indice=1; 
  <?
  $hoy=date("Y-m-d");
  $sql="SELECT id_departamento,clave,id_complejo FROM departamentos";
  $con=mysql_query($sql);
  while($ls=mysql_fetch_array($con)){
     $idcategoria=$ls["id_departamento"];
     $iddirectorio=$ls["id_complejo"];
     $categoria=$ls["clave"];
	 ?>
	 if(v==0){destino.options[indice]=new Option("GENERAL","0");}
	 if(v=="<?echo $iddirectorio?>"){
	   destino.options[indice]=new Option("<?echo $categoria?>","<?echo $idcategoria?>");
	   indice++;
	 }
	 
	 <?
  }
  ?>
  if(destino.length==2){
	 destino.options[1].selected=true;
   }
 }
}
function cambiacantidad(idpago,idcampo){
	 var monto = $("#cantidadmod"+idcampo).val();
	  var motivo = prompt("Por favor introduce el motivo", "");
	    var concepto = document.getElementById("concepto"+idcampo).value;
         var formapago = document.getElementById("formaPago"+idcampo).value;
          var moneda = document.getElementById("moneda"+idcampo).value;
           var propiedad = document.getElementById("propiedad"+idcampo).value;
            var departamento = document.getElementById("departamento"+idcampo).value;

            var fentrada = document.getElementById("fentrada"+idcampo).value;
            var fsalida = document.getElementById("fsalida"+idcampo).value;
	  if (motivo != null && motivo != "") {
        document.getElementById("msgcambiacantidad"+idcampo).innerHTML = motivo;
		var obs = motivo;
	    $.post("modificapago.php", {pago:idpago,campo:idcampo,monto:monto,motivo:obs,concepto:concepto,formapago:formapago,moneda:moneda,propiedad:propiedad,departamento:departamento,fentrada:fentrada,fsalida:fsalida}, function(data){
			$("#msgcambiacantidad"+idcampo).html(data);
		});
      }else{
		  alert("Debes capturas el motivo");
		  return false;
	  } 
}
function validapago(pago,accion,tipo,idren,idclien,idcon)
{

var ch=document.getElementById('val'+accion).checked;
var checado;
if(ch==true){checado="s";}else{checado="";}
 $.post("valpagoadmon.php", {pago:pago,valor:checado,tipopago:tipo,idrenta:idren,idcliente:idclien,idconcepto:idcon}, function(data){
	 $("#validado"+accion).html(data);
	 });
}
function ventana(id){

window.open("modificar_comp_pag.php?idpago="+id, "Titulo Pagina",  'width=820, height=230, top=250, left=150');
}
function ventanas(id){

window.open("comentariopag.php?idpago="+id, "Titulo Pagina",  'width=800, height=270, top=200, left=150');
}
function borrar3(id,td)
{
var f=confirm( "En verdad quieres borrar el pago?");
if(f==true)
	{
	 $.post("borrarpag.php", {id:id}, function(data,status){
	 if(status=="success")
 		{
 		alert("El pago a sido borrado");  
		$("#"+td).hide();
 		} });
	}
}
function borrar(id,td)
{
var motivo="motivo"+td;
var f=confirm( "En verdad quieres borrar el pago?");
if(f==true)
	{
	yq=prompt("Introduce el motivo por el que eliminaras el pago");
	    if(yq){
		 $.post("borrarpag_2.php", {id:id,motivo:yq}, function(data,status){
		 if(status=="success")
			{
			alert("El pago a sido borrado");  
			$("#"+td).html(data);
			} });
		}
	}
}
</script>
	      <style>
		  
		      .cont-busc{position:relative;height:auto;min-height:400px !important;font-family:arial;color:#086A87;top:10px;overflow-x:hidden;margin:auto;}
			  .cont-busc .bar-busc{position:relative;height:90px;font-family:arial;color:#086A87;top:0px;margin:auto;}
			  .cont-res{position:relative;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: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;width:100%;}
			  .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 .trs .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;}
			  .datos .trs .link:hover{background:#A5DF00;}
			  .datos .trs .linkeli{-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;-khtml-border-radius: 5px;background:#8A0808;padding:3px;text-decoration:none;float:left;color:#fff;}
              .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:10px;}
			  .datos .trb{min-height:20px !important;max-height:20px !important;height:20px !important;background:#ffffff;border-top:solid 1px #D8D8D8; color:#0D0D0D;font-size:9px;}
			  .datos .trb td{border-left:solid 1px #D8D8D8;padding-left:10px;}
			  .datos .trb td:first-child{border-left:none;}
			  .datos .trb .tds{background:#A4A4A4;}
			  .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;}
			   .inp{width:35px;text-align:right;font-size:10px;}
			   .inpd{width:55px;text-align:right;font-size:10px;}
			   .selec{width:80px;text-align:right;font-size:10px;}
			   
			   .campos{
					display: block;
					box-sizing: border-box;
					width: 100%;
					height: 2.4375rem;
					padding: .5rem;
					border: 1px solid #cacaca;
					margin: 0 0 1rem;
					font-family: inherit;
					font-size: 1rem;
					color: #0a0a0a;
					background-color: #fefefe;
					box-shadow: inset 0 1px 2px hsla(0,0%,4%,.1);
					border-radius: 0;
					transition: box-shadow .5s,border-color .25s ease-in-out;
					-webkit-appearance: none;
				   
			   }
			   .title {
					margin: 30px 20px;
					font-size: 20px;
					color: #004D96;
					font-weight: bold;
				}
	     </style>
	 </head>
	 <body>
	     <div class="cont-busc" style="overflow: auto">
		   <center>
	         <table class="datos">
			     <tr>
				     <td align="center" class="trs" colspan="18">
					 <a class="link" href="pagosvalidados.php" target="_blank" onClick="window.open(this.href, this.target, 'width=800,height=800'); return false;">Ver pagos</a>
					 <a href="pagosnoval.php?idcliente=<?echo $idcliente?>&idrenta=<?echo $idrenta?>&hoy=<?if($hoy==1){?>0<?}else{?>1<?}?>"><?if($hoy==1){?><?}else{?><?}?></a>Historial de pagos<a class="linkeli" href="pagoseliminados.php" target="_blank" onClick="window.open(this.href, this.target, 'width=800,height=800'); return false;">Pagos eliminados</a></td>
				 </tr>
				 <tr class="trb">
						     <td colspan='18' align="center" class="tds">PAGOS PARA RENTA</td>
					</tr>
				 <tr class="trb">
				     
				     <td align="center"><b>Fecha</b></td>
					 <td align="center"><b>Cliente</b></td>
					 <td align="center"><b>Concepto</b></td>
					 <td align="center"><b>Forma de pago</b></td>
					 <td align="center"><b>Cantidad $</b></td>
					 <td align="center"><b>Moneda</b></td>
					 <td align="center"><b>TC $</b></td>
					 <td align="center"><b>Propiedad</b></td>
					 <td align="center"><b>Periodo</b></td>
					 <td align="center"><b>Recibio</b></td>
					 <td align="center"><b>Comp.</b></td>
					 <td align="center"><b>Modificar comp.</b></td>
					 <td align="center"><b>Com</b></td>
                     <td align="center"><b>Eliminar pago</b></td>
					 <td align="center"><b>Valido</b></td>
					 <td align="center"><b>Val admon</b></td>
					 <td align="center"><b>Pago modificado</b></td>
					 <td align="center"><b>Actualizar</b></td>
				 </tr>
				 <?
				    // if($hoy==1){
					 $condicion="valadmon!='s'";
					 //}else{$condicion="1=1";}
				    	$sql="SELECT d.id_departamento as depa,cm.id_complejo,p.id_renta,p.comprobante,p.usu_val,p.id_pago,p.fecha as fecha,p.concepto as concepto,p.formapago as formapago, p.monto as cantidad, p.tipo_moneda as moneda, p.divisa as divisa, p.f_entrada as fentrada, p.f_salida as fsalida,p.valadmon, c.nombre as propiedad, d.clave as clave, e.nombre as nombre, e.a_pat as apat,p.id_concepto,p.valarq,concat(SUBSTRING(e.nombre, 1, 1),SUBSTRING(e.a_pat, 1, 1),SUBSTRING(e.a_mat, 1, 1)) as ejecutivo,e.nombre as nombreeje  FROM pagos as p  INNER JOIN complejo as cm ON p.propiedad=cm.id_complejo INNER JOIN complejo as c ON p.propiedad=c.id_complejo INNER JOIN  departamentos as d ON p.clave=d.id_departamento INNER JOIN empleados as e ON p.id_emp=e.id_empleado WHERE $condicion AND p.concepto in('RENTA','ANTICIPO','EXTRAS')  order by p.fecha desc";
					$re=mysql_query($sql);
					$k=1;
					while($ls=mysql_fetch_array($re)){
					     if($ls['valadmon']=='s'){$readonly="readonly";$ch="checked";$img="<img src='images/emok.png' width='15' height='15' border='0'>";}else{$readonly="";$ch="";$img="";}
						 //$renta="select pa.id_renta,r.id_cliente,c.a_pat,c.a_mat,c.nombre from pagos as pa,renta as r,clientes as c where pa.id_renta='$ls[id_renta]' and pa.id_renta=r.id_renta and r.id_cliente=c.id_cliente";
						 $renta="select pa.id_renta,r.id_cliente,c.a_pat,c.a_mat,c.nombre from pagos as pa INNER JOIN renta r ON pa.id_renta=r.id_renta 	
						 INNER JOIN clientes c ON r.id_cliente=c.id_cliente where pa.id_renta='$ls[id_renta]'";
						 $ejerenta=mysql_query($renta);
						 $rta=mysql_fetch_array($ejerenta);
						 $cliente=$rta['a_pat']." ".$rta['a_mat']." ".$rta['nombre'];
						 $nomcliente=htmlentities($cliente);
						 $idcliente=$rta['id_cliente'];
						 $idrenta=$rta['id_renta'];
						 $valarq=$ls['valarq'];
						 $select="SELECT nombre, a_pat FROM empleados WHERE id_empleado='$ls[usu_val]'";
						 $q=mysql_query($select);
						 $e=mysql_fetch_array($q);
						 $admonval=$e["nombre"]." ".$e["a_pat"];
						 $p++;
					    ?>
						 <tr id="a<?echo$p?>" class="trb">
						     
						     <td><?echo $ls['fecha']?></td>
							 <td>
 								<a href="cedulas.php?idcliente=<?echo$idcliente;?>&idrenta=<?echo$idrenta;?>&idconcepto=<?php echo $ls['id_concepto'];?>" target="_blank"><label style="font-size:8px;"><?echo $nomcliente;?></label></a>
							 </td>
						     <td>
 								<select name="concepto<?echo $k?>" id="concepto<?echo $k?>" class="selec">
							         <option value="<?php echo $ls['concepto'];?>" selected="selected"><?php echo $ls['concepto'];?></option>
								     <option value="RENTA">RENTA NUEVA</option> 
								     <option value="DEPOSITO">GARANTIA</option>
								     <option value="IMPUESTOS">IMPUESTOS</option>
								     <option value="SEGUIMIENTO">RENTA SEGUIMIENTO</option>
									 <option value="EXTRAS">EXTRAS</option>
						        </select>					   
						     </td>
						     <td>
						     	<select name="formaPago<?echo $k?>" id="formaPago<?echo $k?>" class="selec" onchange="javascript:ver(this.value,<?echo $k?>);" style="width:50px;">
								     <option value="<?php echo $ls['formapago']?>"><?php echo $ls['formapago']?></option>
								     <option value="EP">EFECTIVO</option>
			                         <option value="ED">EFECTIVO DOLARES</option>
								     <!--option value="TC ECO">TARJETA DE CREDITO ECONOSUITES</option-->
			                         <option value="TC HABI">TARJETA DE CREDITO HABITACIONES</option>
									 <!--option value="TD">TARJETA DE DEBITO ECONOSUITES</option-->
			                         <option value="TD HABI">TARJETA DE DEBITO HABITACIONES</option-->
			                         <!--option value="TS">TRANSFERENCIA SUIZA</option-->
								     <!--option value="TM">TRANSFERENCIA MERRYLINCH</option-->
								     <!--option value="TIBJA">TRANSFERENCIA INTERBANCARIA JOSE ALBERTO</option-->
								     <!--option value="TIBECO">TRANSFERENCIA INTERBANCARIA ECONOSUITES</option-->
			                         <option value="TIBHABI">TRANSFERENCIA INTERBANCARIA HABITACIONES</option>
								     <!--option value="DJA">DEPOSITO CUENTA JOSE ALBERTO</option-->
								     <!--option value="DECO">DEPOSITO ECONOSUITES</option-->
								     <option value="PP">PAYPAL</option>
								     <option value="EXTRANET">EXTRANET</option>
								     <option value="VA">VOUCHER ABIERTO</option>
								     <option value="CORTESIA">CORTESIA</option>
									 <option value="AIRBNB TRANSFERENCIA">AIRBNB TRANSFERENCIA</option>
									 <option value="INTERMEDIARIO DE PAGOS (OXXO,SEVEN)">INTERMEDIARIO DE PAGOS (OXXO,SEVEN)</option>
									 <option value="NO SHOW">NO SHOW</option>
                 	     		 </select> 					     	
						     </td>
						     <td align="right">
							 	<input type="text" name="cantidadmod<?php echo$k;?>" id="cantidadmod<?php echo$k;?>" value="<?php echo $ls['cantidad'];?>" class="inpd"><div id="msgcambiacantidad<?php echo$k;?>"></div>
							 </td>
							 <!--font style="float:left">$</font> <?echo Moneda2($ls['cantidad']);?></td-->
						     <td>
						     	<input type="text" name="moneda<?php echo $k;?>" id="moneda<?php echo $k;?>" value="<?php echo $ls['moneda'];?>" class="inpd">					     
						     </td>
						     <td align="right"><?echo $ls['divisa']?></td>
						     <td>
						     	<select name="propiedad<?php echo $k;?>" id="propiedad<?php echo $k;?>" class="selec" onchange="depas(this.id,<?php echo $k?>);">
			                         <option value="<?php echo  $ls['id_complejo'];?>"><?php echo  $ls['propiedad'];?></option>
						             <?php
						                $sqld=mysql_query("select id_complejo,nombre from complejo",$db_conexion);
						                while($prop=mysql_fetch_array($sqld))
						                     {
						                      echo "<option value='$prop[id_complejo]' style='font-size:10.5px;'>$prop[nombre]</option>";
						                     }
						             ?>
						        </select>
						        <select name="departamento<?php echo $k;?>" id="departamento<?php echo $k;?>" class="selec">
		                           <option value="<?php echo $ls['depa'];?>"><?php echo $ls['clave'];?></option>
					            </select>     	
						     </td>
						     <td>
						     	<input type="text" id="fentrada<?php echo $k; ?>" name="fentrada<?php echo $k; ?>" size="18" value="<?php echo $ls['fentrada'];?>" class="inpd" readOnly>
						     	/<input type="text" id="fsalida<?php echo $k; ?>" name="fsalida<?php echo $k; ?>" size="18" value="<?php echo $ls['fsalida'];?>" class="inpd" readOnly>
						    	<script src="js/moment.js"></script>
								<script src="js/pikaday.js"></script>
								<script>
								var picker = new Pikaday(
								{
									field: document.getElementById('fentrada<?php echo $k; ?>'),
									format : "YYYY-MM-DD",
									firstDay: 1,
									minDate: new Date(1930, 0, 1),
									maxDate: new Date(<?php echo date('Y')+5;?>, 12, 31),
									yearRange: [1930,<?php echo date('Y')+5;?>]
								});
								</script>
								<script>
								var picker = new Pikaday(
								{
									field: document.getElementById('fsalida<?php echo $k; ?>'),
									format : "YYYY-MM-DD",
									firstDay: 1,
									minDate: new Date(1930, 0, 1),
									maxDate: new Date(<?php echo date('Y') + 5;?>, 12, 31),
									yearRange: [1930,<?php echo date('Y')+5;?>]
								});
								</script>

						     <?php //echo $ls['entrada']."/".$ls['salida']?></td>

						     <td title="<?echo htmlentities($ls['nombreeje']." ".$ls['apat']." ".$ls['amat']);?>"><?echo htmlentities($ls['ejecutivo']);?></td>
						 
						     <td><?if($ls["comprobante"]==""){echo "";}else{?><a href="<?echo $ls["comprobante"];?>" target="_blank"><img src="images/zoom.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></a><?}?></td>
						     <td><img onclick="ventana(<?echo $ls["id_pago"];?>)" src="images/zoom.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></td>
 <td><img onclick="ventanas(<?echo $ls["id_pago"];?>)" src="images/zoom.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></td>
						      <td><?if($valarq=='s'){}else{?><img onclick="borrar('<?echo $ls["id_pago"];?>','<?echo"a$p"?>' )" src="images/borrar.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante">&nbsp;&nbsp;&nbsp;
							  <?}?>
							  <!--<a href="#" onclick="borrar2('<?echo $ls["id_pago"];?>','<?echo"a$p"?>' )"></a>-->
							  </td>
	
						     	 <td><?echo $admonval?></td>
						     <td><input type="checkbox" id="val<?echo$k;?>" name="val<?echo$k;?>" <?echo$ch;?> value="s" onclick="javascript:validapago('<?echo$ls['id_pago']?>','<?echo$k?>','RENTA','<?echo$idrenta?>','<?echo$idcliente?>','<?echo$ls['id_concepto'];?>');"><div id="validado<?echo$k;?>" style="position:absolute;width:15px;height:15px;margin-top:-17px;margin-left:17px"><?echo$img;?></div></td>
							 <td>
							   <?php 
							      $sqlpagmod = "SELECT COUNT(idpago) as pagosmod FROM bitacorapagos WHERE idpago = ".$ls['id_pago'];
								  $ejecutapagmod = mysql_query($sqlpagmod);
								  $regpagmod = mysql_fetch_array($ejecutapagmod);
								  if($regpagmod['pagosmod'] > 0){ ?>
									  <a href="bitacorapagos.php?idp=<?php echo $ls['id_pago'];?>" target="_blank" onClick="window.open(this.href, this.target, 'width=500,height=600'); return false;">Ver</a>
								  <?php } ?>
							 </td>
							 <td><a href="javascript:cambiacantidad('<?php echo$ls['id_pago']?>','<?php echo$k;?>');">Actualizar</a></td>
						 </tr>
						<?
						$k++;
					}
					if($k==1){
					    ?>
						<tr class="trb">
						     <td colspan='18' align="center">No se encontraron pagos nuevos por el concepto de RENTA</td>
						 </tr>
						<?
					}
					?>
					<tr class="trb">
						     <td colspan='18' align="center" class="tds">PAGOS DE  IMPUESTOS</td>
					</tr>
					<tr class="trb">
				     <td align="center"><b>Fecha</b></td>
					 <td align="center"><b>Cliente</b></td>
					 <td align="center"><b>Concepto</b></td>
					 <td align="center"><b>Forma de pago</b></td>
					 <td align="center"><b>Cantidad $</b></td>
					 <td align="center"><b>Moneda</b></td>
					 <td align="center"><b>TC $</b></td>
					 <td align="center"><b>Propiedad</b></td>
					 <td align="center"><b>Periodo</b></td>
					 <td align="center"><b>Recibio</b></td>
					 <td align="center"><b>Comp.</b></td>
					 <td align="center"><b>modificar comp.</b></td>
                     <td align="center"><b>Com</b></td>
					 <td align="center"><b>Eliminar pago</b></td>
					 <td align="center"><b>Valido</b></td>
					 <td align="center"><b>Val admon</b></td>
					 <td align="center"><b>Pago modificado</b></td>
					 <td align="center"><b>Actualizar</b></td>
				    </tr>
				    <?
					$sql="SELECT d.id_departamento as depa,cm.id_complejo,p.id_renta,p.comprobante,p.usu_val,p.id_pago,p.fecha as fecha,p.concepto as concepto,p.formapago as formapago, p.monto as cantidad, p.tipo_moneda as moneda, p.divisa as divisa, p.f_entrada as entrada, p.f_salida as salida,p.valadmon, c.nombre as propiedad, d.clave as clave, e.nombre as nombre, e.a_pat as apat,p.id_concepto,concat(SUBSTRING(e.nombre, 1, 1),SUBSTRING(e.a_pat, 1, 1),SUBSTRING(e.a_mat, 1, 1)) as ejecutivo,e.nombre as nombreeje  FROM pagos as p  INNER JOIN complejo as cm ON p.propiedad=cm.id_complejo INNER JOIN complejo as c ON p.propiedad=c.id_complejo INNER JOIN  departamentos as d ON p.clave=d.id_departamento INNER JOIN empleados as e ON p.id_emp=e.id_empleado WHERE $condicion AND p.concepto='IMPUESTOS' order by p.fecha desc";
					$re=mysql_query($sql);
					//$k=1;
					while($ls=mysql_fetch_array($re)){
					     if($ls['valadmon']=='s'){$readonly="readonly";$ch="checked";$img="<img src='images/emok.png' width='15' height='15' border='0'>";}else{$readonly="";$ch="";$img="";}
						 //$renta="select pa.id_renta,r.id_cliente,c.a_pat,c.a_mat,c.nombre from pagos as pa,renta as r,clientes as c where pa.id_renta='$ls[id_renta]' and pa.id_renta=r.id_renta and r.id_cliente=c.id_cliente";
						 $renta="select pa.id_renta,r.id_cliente,c.a_pat,c.a_mat,c.nombre from pagos as pa INNER JOIN renta r ON pa.id_renta=r.id_renta 	
						 INNER JOIN clientes c ON r.id_cliente=c.id_cliente where pa.id_renta='$ls[id_renta]'";
						 $ejerenta=mysql_query($renta);
						 $rta=mysql_fetch_array($ejerenta);
						 $cliente=$rta['a_pat']." ".$rta['a_mat']." ".$rta['nombre'];
						 $nomcliente=htmlentities($cliente);
						 $idcliente=$rta['id_cliente'];
						 $idrenta=$rta['id_renta'];
						 
						 $select="SELECT nombre, a_pat FROM empleados WHERE id_empleado='$ls[usu_val]'";
						 $q=mysql_query($select);
						 $e=mysql_fetch_array($q);
						 $admonval=$e["nombre"]." ".$e["a_pat"];
						 $r++;
					    ?>
						 <tr id="c<?echo$r?>" class="trb">
						   
						     <td><?echo $ls['fecha']?></td>
							 <td><a href="cedulas.php?idcliente=<?echo$idcliente;?>&idrenta=<?echo$idrenta;?>&idconcepto=<?php echo $ls['id_concepto'];?>" target="_blank"><label style="font-size:8px;"><?echo $nomcliente;?></label></a></td>
						     <td>
						       <select name="concepto<?echo $k?>" id="concepto<?echo $k?>" class="selec">
							         <option value="<?php echo $ls['concepto'];?>" selected="selected"><?php echo $ls['concepto'];?></option>
								     <option value="RENTA">RENTA NUEVA</option> 
								     <option value="DEPOSITO">GARANTIA</option>
								     <option value="IMPUESTOS">IMPUESTOS</option>
								     <option value="SEGUIMIENTO">RENTA SEGUIMIENTO</option>
									 <option value="EXTRAS">EXTRAS</option>
						        </select>
						     </td>
						     <td>
						         <select name="formaPago<?echo $k?>" id="formaPago<?echo $k?>" class="selec" onchange="javascript:ver(this.value,<?echo $k?>);" style="width:50px;">
								     <option value="<?php echo $ls['formapago']?>"><?php echo $ls['formapago']?></option>
								     <option value="EP">EFECTIVO</option>
			                         <option value="ED">EFECTIVO DOLARES</option>
								     <!--option value="TC ECO">TARJETA DE CREDITO ECONOSUITES</option-->
			                         <option value="TC HABI">TARJETA DE CREDITO HABITACIONES</option>
									 <!--option value="TD">TARJETA DE DEBITO ECONOSUITES</option-->
			                         <option value="TD HABI">TARJETA DE DEBITO HABITACIONES</option-->
			                         <!--option value="TS">TRANSFERENCIA SUIZA</option-->
								     <!--option value="TM">TRANSFERENCIA MERRYLINCH</option-->
								     <!--option value="TIBJA">TRANSFERENCIA INTERBANCARIA JOSE ALBERTO</option-->
								     <!--option value="TIBECO">TRANSFERENCIA INTERBANCARIA ECONOSUITES</option-->
			                         <option value="TIBHABI">TRANSFERENCIA INTERBANCARIA HABITACIONES</option>
								     <!--option value="DJA">DEPOSITO CUENTA JOSE ALBERTO</option-->
								     <!--option value="DECO">DEPOSITO ECONOSUITES</option-->
								     <option value="PP">PAYPAL</option>
								     <option value="EXTRANET">EXTRANET</option>
								     <option value="VA">VOUCHER ABIERTO</option>
								     <option value="CORTESIA">CORTESIA</option>
									 <option value="AIRBNB TRANSFERENCIA">AIRBNB TRANSFERENCIA</option>
									 <option value="INTERMEDIARIO DE PAGOS (OXXO,SEVEN)">INTERMEDIARIO DE PAGOS (OXXO,SEVEN)</option>
									 <option value="NO SHOW">NO SHOW</option>
                 	     		 </select> </td>
							 <td align="right">
							 <input type="text" name="cantidadmod<?php echo$k;?>" id="cantidadmod<?php echo$k;?>" value="<?php echo $ls['cantidad'];?>" class="inpd"><div id="msgcambiacantidad<?php echo$k;?>"></div></td>
						     <!--font style="float:left">$</font> <?echo Moneda2($ls['cantidad']);?></td-->
						     <td><input type="text" name="moneda<?php echo $k;?>" id="moneda<?php echo $k;?>" value="<?php echo $ls['moneda'];?>" class="inpd"></td>
						     <td align="right"><?echo $ls['divisa']?></td>
						     <td>
						     	<select name="propiedad<?php echo $k;?>" id="propiedad<?php echo $k;?>" class="selec" onchange="depas(this.id,<?php echo $k?>);">
			                         <option value="<?php echo  $ls['id_complejo'];?>"><?php echo  $ls['propiedad'];?></option>
						             <?php
						                $sqld=mysql_query("select id_complejo,nombre from complejo",$db_conexion);
						                while($prop=mysql_fetch_array($sqld))
						                     {
						                      echo "<option value='$prop[id_complejo]' style='font-size:10.5px;'>$prop[nombre]</option>";
						                     }
						             ?>
						        </select>
						        <select name="departamento<?php echo $k;?>" id="departamento<?php echo $k;?>" class="selec">
		                           <option value="<?php echo $ls['depa'];?>"><?php echo $ls['clave'];?></option>
					            </select>
						     </td>
						     <td>
						     	<input type="text" id="fentrada<?php echo $k; ?>" name="fentrada<?php echo $k; ?>" size="18" value="<?php echo $ls['entrada'];?>" class="inpd" readOnly>
						     	/<input type="text" id="fsalida<?php echo $k; ?>" name="fsalida<?php echo $k; ?>" size="18" value="<?php echo $ls['salida'];?>" class="inpd" readOnly>
								<script>
									var picker = new Pikaday(
									{
										field: document.getElementById('fentrada<?php echo $k; ?>'),
										format : "YYYY-MM-DD",
										firstDay: 1,
										minDate: new Date(1930, 0, 1),
										maxDate: new Date(<?php echo date('Y')+5;?>, 12, 31),
										yearRange: [1930,<?php echo date('Y')+5;?>]
									});
									</script>
									<script>
									var picker = new Pikaday(
									{
										field: document.getElementById('fsalida<?php echo $k; ?>'),
										format : "YYYY-MM-DD",
										firstDay: 1,
										minDate: new Date(1930, 0, 1),
										maxDate: new Date(<?php echo date('Y')+5;?>, 12, 31),
										yearRange: [1930,<?php echo date('Y')+5;?>]
									});
								</script>
						     <?php //echo $ls['entrada']."/".$ls['salida']?></td>
						     <td title="<?echo htmlentities($ls['nombreeje']." ".$ls['apat']." ".$ls['amat']);?>"><?echo htmlentities($ls['ejecutivo']);?></td>
						     <td><?if($ls["comprobante"]==""){echo "";}else{?><a href="<?echo $ls["comprobante"];?>" target="_blank"><img src="images/zoom.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></a><?}?></td>
							 <td><img onclick="ventana(<?echo $ls["id_pago"];?>)" src="images/zoom.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></td>
<td><img onclick="ventanas(<?echo $ls["id_pago"];?>)" src="images/zoom.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></td>
							   <td><img onclick="borrar('<?echo $ls["id_pago"];?>','<?php echo"c$r"?>' )" src="images/borrar.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></td>
							 <td><?echo $admonval?></td>
						     <td><input type="checkbox" id="val<?echo$k;?>" name="val<?echo$k;?>" <?echo$ch;?> value="s" onclick="javascript:validapago('<?echo$ls['id_pago']?>','<?echo$k?>','IMPUESTOS','<?echo$idrenta?>','<?echo$idcliente?>','<?echo$ls['id_concepto'];?>');"><div id="validado<?echo$k;?>" style="position:absolute;width:15px;height:15px;margin-top:-17px;margin-left:17px"><?echo$img;?></div></td>
							 <td>
							   <?php 
							      $sqlpagmod = "SELECT COUNT(idpago) as pagosmod FROM bitacorapagos WHERE idpago = ".$ls['id_pago'];
								  $ejecutapagmod = mysql_query($sqlpagmod);
								  $regpagmod = mysql_fetch_array($ejecutapagmod);
								  if($regpagmod['pagosmod'] > 0){ ?>
									  <a href="bitacorapagos.php?idp=<?php echo $ls['id_pago'];?>" target="_blank" onClick="window.open(this.href, this.target, 'width=500,height=600'); return false;">Ver</a>
								  <?php } ?>
							 </td>
							  <td><a href="javascript:cambiacantidad('<?php echo$ls['id_pago']?>','<?php echo$k;?>');">Actualizar</a></td>
						 </tr>
						<?
						$k++;
					}
					if($k==1){
					    ?>
						<tr class="trb">
						     <td colspan='18' align="center">No se encontraron pagos nuevos por el concepto de IMPUESTOS</td>
						 </tr>
						<?
					}
					?>
					<tr class="trb">
						     <td colspan='18' align="center" class="tds">PAGOS PARA RENTA EN SEGUIMIENTO</td>
					</tr>
					<tr class="trb">
				     <td align="center"><b>Fecha</b></td>
					 <td align="center"><b>Cliente</b></td>
					 <td align="center"><b>Concepto</b></td>
					 <td align="center"><b>Forma de pago</b></td>
					 <td align="center"><b>Cantidad $</b></td>
					 <td align="center"><b>Moneda</b></td>
					 <td align="center"><b>TC $</b></td>
					 <td align="center"><b>Propiedad</b></td>
					 <td align="center"><b>Periodo</b></td>
					 <td align="center"><b>Recibio</b></td>
					 <td align="center"><b>Comp.</b></td>
					 <td align="center"><b>modificar comp.</b></td>
				     <td align="center"><b>Com</b></td>
					 <td align="center"><b>Eliminar pago</b></td>
					 <td align="center"><b>Valido</b></td>
					 <td align="center"><b>Val admon</b></td>
					 <td align="center"><b>Pago modificado</b></td>
					 <td align="center"><b>Actualizar</b></td>
				    </tr>
				    <?
					$sql="SELECT d.id_departamento as depa,cm.id_complejo,p.id_renta,p.comprobante,p.usu_val,p.id_pago,p.fecha as fecha,p.concepto as concepto,p.formapago as formapago, p.monto as cantidad, p.tipo_moneda as moneda, p.divisa as divisa, p.f_entrada as entrada, p.f_salida as salida,p.valadmon, c.nombre as propiedad, d.clave as clave, e.nombre as nombre, e.a_pat as apat,p.id_concepto,concat(SUBSTRING(e.nombre, 1, 1),SUBSTRING(e.a_pat, 1, 1),SUBSTRING(e.a_mat, 1, 1)) as ejecutivo,e.nombre as nombreeje  FROM pagos as p  INNER JOIN complejo as cm ON p.propiedad=cm.id_complejo INNER JOIN complejo as c ON p.propiedad=c.id_complejo INNER JOIN  departamentos as d ON p.clave=d.id_departamento INNER JOIN empleados as e ON p.id_emp=e.id_empleado WHERE $condicion AND p.concepto='SEGUIMIENTO' order by p.fecha desc";
					$re=mysql_query($sql);
					//$k=1;
					while($ls=mysql_fetch_array($re)){
					     if($ls['valadmon']=='s'){$readonly="readonly";$ch="checked";$img="<img src='images/emok.png' width='15' height='15' border='0'>";}else{$readonly="";$ch="";$img="";}
						 //$renta="select pa.id_renta,r.id_cliente,c.a_pat,c.a_mat,c.nombre from pagos as pa,renta as r,clientes as c where pa.id_renta='$ls[id_renta]' and pa.id_renta=r.id_renta and r.id_cliente=c.id_cliente";
						 $renta="select pa.id_renta,r.id_cliente,c.a_pat,c.a_mat,c.nombre from pagos as pa INNER JOIN renta r ON pa.id_renta=r.id_renta 	
						 INNER JOIN clientes c ON r.id_cliente=c.id_cliente where pa.id_renta='$ls[id_renta]'";
						 $ejerenta=mysql_query($renta);
						 $rta=mysql_fetch_array($ejerenta);
						 $cliente=$rta['a_pat']." ".$rta['a_mat']." ".$rta['nombre'];
						 $nomcliente=htmlentities($cliente);
						 $idcliente=$rta['id_cliente'];
						 $idrenta=$rta['id_renta'];
						 
						 $select="SELECT nombre, a_pat FROM empleados WHERE id_empleado='$ls[usu_val]'";
						 $q=mysql_query($select);
						 $e=mysql_fetch_array($q);
						 $admonval=$e["nombre"]." ".$e["a_pat"];
						 $r++;
					    ?>
						 <tr id="c<?echo$r?>" class="trb">
						   
						     <td><?echo $ls['fecha']?></td>
							 <td><a href="cedulas.php?idcliente=<?echo$idcliente;?>&idrenta=<?echo$idrenta;?>&idconcepto=<?php echo $ls['id_concepto'];?>" target="_blank"><label style="font-size:8px;"><?echo $nomcliente;?></label></a></td>
						     <td>
						     	<select name="concepto<?echo $k?>" id="concepto<?echo $k?>" class="selec">
							         <option value="<?php echo $ls['concepto'];?>" selected="selected"><?php echo $ls['concepto'];?></option>
								     <option value="RENTA">RENTA NUEVA</option> 
								     <option value="DEPOSITO">GARANTIA</option>
								     <option value="IMPUESTOS">IMPUESTOS</option>
								     <option value="SEGUIMIENTO">RENTA SEGUIMIENTO</option>
									 <option value="EXTRAS">EXTRAS</option>
						        </select>
						     </td>
						     <td>
						     	<select name="formaPago<?echo $k?>" id="formaPago<?echo $k?>" class="selec" onchange="javascript:ver(this.value,<?echo $k?>);" style="width:50px;">
								     <option value="<?php echo $ls['formapago']?>"><?php echo $ls['formapago']?></option>
								     <option value="EP">EFECTIVO</option>
			                         <option value="ED">EFECTIVO DOLARES</option>
								     <!--option value="TC ECO">TARJETA DE CREDITO ECONOSUITES</option-->
			                         <option value="TC HABI">TARJETA DE CREDITO HABITACIONES</option>
									 <!--option value="TD">TARJETA DE DEBITO ECONOSUITES</option-->
			                         <option value="TD HABI">TARJETA DE DEBITO HABITACIONES</option-->
			                         <!--option value="TS">TRANSFERENCIA SUIZA</option-->
								     <!--option value="TM">TRANSFERENCIA MERRYLINCH</option-->
								     <!--option value="TIBJA">TRANSFERENCIA INTERBANCARIA JOSE ALBERTO</option-->
								     <!--option value="TIBECO">TRANSFERENCIA INTERBANCARIA ECONOSUITES</option-->
			                         <option value="TIBHABI">TRANSFERENCIA INTERBANCARIA HABITACIONES</option>
								     <!--option value="DJA">DEPOSITO CUENTA JOSE ALBERTO</option-->
								     <!--option value="DECO">DEPOSITO ECONOSUITES</option-->
								     <option value="PP">PAYPAL</option>
								     <option value="EXTRANET">EXTRANET</option>
								     <option value="VA">VOUCHER ABIERTO</option>
								     <option value="CORTESIA">CORTESIA</option>
									 <option value="AIRBNB TRANSFERENCIA">AIRBNB TRANSFERENCIA</option>
									 <option value="INTERMEDIARIO DE PAGOS (OXXO,SEVEN)">INTERMEDIARIO DE PAGOS (OXXO,SEVEN)</option>
									 <option value="NO SHOW">NO SHOW</option>
                 	     		 </select>
						     </td>
							 <td align="right">
							 <input type="text" name="cantidadmod<?php echo$k;?>" id="cantidadmod<?php echo$k;?>" value="<?php echo $ls['cantidad'];?>" class="inpd" ><div id="msgcambiacantidad<?php echo$k;?>"></div></td>
						     <!--td align="right"><font style="float:left">$</font> <?echo Moneda2($ls['cantidad']);?></td-->
						     <td><input type="text" name="moneda<?php echo $k;?>" id="moneda<?php echo $k;?>" value="<?php echo $ls['moneda'];?>" class="inpd"></td>
						     <td align="right"><?echo $ls['divisa']?></td>
						     <td>
						     	<select name="propiedad<?php echo $k;?>" id="propiedad<?php echo $k;?>" class="selec" onchange="depas(this.id,<?php echo $k?>);">
			                         <option value="<?php echo  $ls['id_complejo'];?>"><?php echo  $ls['propiedad'];?></option>
						             <?php
						                $sqld=mysql_query("select id_complejo,nombre from complejo",$db_conexion);
						                while($prop=mysql_fetch_array($sqld))
						                     {
						                      echo "<option value='$prop[id_complejo]' style='font-size:10.5px;'>$prop[nombre]</option>";
						                     }
						             ?>
						        </select>
						        <select name="departamento<?php echo $k;?>" id="departamento<?php echo $k;?>" class="selec">
		                           <option value="<?php echo $ls['depa'];?>"><?php echo $ls['clave'];?></option>
					            </select>
						     </td>
						     <td>
						     	<input type="text" id="fentrada<?php echo $k; ?>" name="fentrada<?php echo $k; ?>" size="18" value="<?php echo $ls['entrada'];?>" class="inpd" readOnly>
						     	/<input type="text" id="fsalida<?php echo $k; ?>" name="fsalida<?php echo $k; ?>" size="18" value="<?php echo $ls['salida'];?>" class="inpd" readOnly>
								<script>
									var picker = new Pikaday(
									{
										field: document.getElementById('fentrada<?php echo $k; ?>'),
										format : "YYYY-MM-DD",
										firstDay: 1,
										minDate: new Date(1930, 0, 1),
										maxDate: new Date(<?php echo date('Y')+5;?>, 12, 31),
										yearRange: [1930,<?php echo date('Y')+5;?>]
									});
									</script>
									<script>
									var picker = new Pikaday(
									{
										field: document.getElementById('fsalida<?php echo $k; ?>'),
										format : "YYYY-MM-DD",
										firstDay: 1,
										minDate: new Date(1930, 0, 1),
										maxDate: new Date(<?php echo date('Y')+5;?>, 12, 31),
										yearRange: [1930,<?php echo date('Y')+5;?>]
									});
								</script>
						     <?php echo $ls['entrada']."/".$ls['salida']?></td>
						     <td title="<?echo htmlentities($ls['nombreeje']." ".$ls['apat']." ".$ls['amat']);?>"><?echo htmlentities($ls['ejecutivo']);?></td>
						     <td><?if($ls["comprobante"]==""){echo "";}else{?><a href="<?echo $ls["comprobante"];?>" target="_blank"><img src="images/zoom.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></a><?}?></td>
							 <td><img onclick="ventana(<?echo $ls["id_pago"];?>)" src="images/zoom.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></td>
<td><img onclick="ventanas(<?echo $ls["id_pago"];?>)" src="images/zoom.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></td>
							   <td><img onclick="borrar('<?echo $ls["id_pago"];?>','<?php echo"c$r"?>' )" src="images/borrar.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></td>
							 <td><?echo $admonval?></td>
						     <td><input type="checkbox" id="val<?echo$k;?>" name="val<?echo$k;?>" <?echo$ch;?> value="s" onclick="javascript:validapago('<?echo$ls['id_pago']?>','<?echo$k?>','SEGUIMIENTO','<?echo$idrenta?>','<?echo$idcliente?>','<?echo$ls['id_concepto'];?>');"><div id="validado<?echo$k;?>" style="position:absolute;width:15px;height:15px;margin-top:-17px;margin-left:17px"><?echo$img;?></div></td>
							 <td>
							   <?php 
							      $sqlpagmod = "SELECT COUNT(idpago) as pagosmod FROM bitacorapagos WHERE idpago = ".$ls['id_pago'];
								  $ejecutapagmod = mysql_query($sqlpagmod);
								  $regpagmod = mysql_fetch_array($ejecutapagmod);
								  if($regpagmod['pagosmod'] > 0){ ?>
									  <a href="bitacorapagos.php?idp=<?php echo $ls['id_pago'];?>" target="_blank" onClick="window.open(this.href, this.target, 'width=500,height=600'); return false;">Ver</a>
								  <?php } ?>
							 </td>
							 <td><a href="javascript:cambiacantidad('<?php echo$ls['id_pago']?>','<?php echo$k;?>');">Actualizar</a></td>
						 </tr>
						<?
						$k++;
					}
					if($k==1){
					    ?>
						<tr class="trb">
						     <td colspan='18' align="center">No se encontraron pagos nuevos por el concepto de RENTA EN SEGUIMIENTO</td>
						 </tr>
						<?
					}
					?>
					<tr class="trb">
						     <td colspan='18' align="center" class="tds">PAGOS PARA DEPOSITO EN GARANTIA</td>
					</tr>
					<tr class="trb">
				    
				     <td align="center"><b>Fecha</b></td>
					 <td align="center"><b>Cliente</b></td>
					 <td align="center"><b>Concepto</b></td>
					 <td align="center"><b>Forma de pago</b></td>
					 <td align="center"><b>Cantidad $</b></td>
					 <td align="center"><b>Moneda</b></td>
					 <td align="center"><b>TC $</b></td>
					 <td align="center"><b>Propiedad</b></td>
					 <td align="center"><b>Periodo</b></td>
					 <td align="center"><b>Recibio</b></td>
					 <td align="center"><b>Comp.</b></td>
					 <td align="center"><b>modificar comp.</b></td>
					 <td align="center"><b>Com</b></td>
					 <td align="center"><b>Eliminar pago</b></td>
					 <td align="center"><b>Valido</b></td>
					 <td align="center"><b>Val admon</b></td>
					 <td align="center"><b>Pago modificado</b></td>
					 <td align="center"><b>Actualizar</b></td>
				    </tr>
				    <?
					$sql="SELECT d.id_departamento as depa,cm.id_complejo,p.id_concepto,p.id_renta,p.comprobante,p.usu_val,p.id_pago,p.fecha as fecha,p.concepto as concepto,p.formapago as formapago, p.monto as cantidad, p.tipo_moneda as moneda, p.divisa as divisa, p.f_entrada as entrada, p.f_salida as salida,p.valadmon, c.nombre as propiedad, d.clave as clave, e.nombre as nombre, e.a_pat as apat,concat(SUBSTRING(e.nombre, 1, 1),SUBSTRING(e.a_pat, 1, 1),SUBSTRING(e.a_mat, 1, 1)) as ejecutivo,e.nombre as nombreeje  FROM pagos as p  INNER JOIN complejo as cm ON p.propiedad=cm.id_complejo INNER JOIN complejo as c ON p.propiedad=c.id_complejo INNER JOIN  departamentos as d ON p.clave=d.id_departamento INNER JOIN empleados as e ON p.id_emp=e.id_empleado WHERE $condicion AND p.concepto='DEPOSITO' order by p.fecha desc";
					$re=mysql_query($sql);
					//$k=1;
					while($ls=mysql_fetch_array($re)){
					     if($ls['valadmon']=='s'){$readonly="readonly";$ch="checked";$img="<img src='images/emok.png' width='15' height='15' border='0'>";}else{$readonly="";$ch="";$img="";}
						 //$renta="select pa.id_renta,r.id_cliente,c.a_pat,c.a_mat,c.nombre from pagos as pa,renta as r,clientes as c where pa.id_renta='$ls[id_renta]' and pa.id_renta=r.id_renta and r.id_cliente=c.id_cliente";
						 $renta="select pa.id_renta,r.id_cliente,c.a_pat,c.a_mat,c.nombre from pagos as pa INNER JOIN renta r ON pa.id_renta=r.id_renta 	
						 INNER JOIN clientes c ON r.id_cliente=c.id_cliente where pa.id_renta='$ls[id_renta]'";
						 $ejerenta=mysql_query($renta);
						 $rta=mysql_fetch_array($ejerenta);
						 $cliente=$rta['a_pat']." ".$rta['a_mat']." ".$rta['nombre'];
						 $nomcliente=htmlentities($cliente);
						 $idcliente=$rta['id_cliente'];
						 $idrenta=$rta['id_renta'];
						 
						 $select="SELECT nombre, a_pat FROM empleados WHERE id_empleado='$ls[usu_val]'";
						 $q=mysql_query($select);
						 $e=mysql_fetch_array($q);
						 $admonval=$e["nombre"]." ".$e["a_pat"];
						 $l++;
					    ?>
						 <tr id="f<?echo$l;?>" class="trb">
						    
						     <td><?echo $ls['fecha']?></td>
							 <td><a href="cedulas.php?idcliente=<?echo$idcliente;?>&idrenta=<?echo$idrenta;?>&idconcepto=<?php echo $ls['id_concepto'];?>" target="_blank"><label style="font-size:8px;"><?echo html_entity_decode($nomcliente);?></label></a></td>
						     <td>
						     	<select name="concepto<?echo $k?>" id="concepto<?echo $k?>" class="selec">
							         <option value="<?php echo $ls['concepto'];?>" selected="selected"><?php echo $ls['concepto'];?></option>
								     <option value="RENTA">RENTA NUEVA</option> 
								     <option value="DEPOSITO">GARANTIA</option>
								     <option value="IMPUESTOS">IMPUESTOS</option>
								     <option value="SEGUIMIENTO">RENTA SEGUIMIENTO</option>
									 <option value="EXTRAS">EXTRAS</option>
						        </select>
						     </td>
						     <td>
						     	<select name="formaPago<?echo $k?>" id="formaPago<?echo $k?>" class="selec" onchange="javascript:ver(this.value,<?echo $k?>);" style="width:50px;">
								     <option value="<?php echo $ls['formapago']?>"><?php echo $ls['formapago']?></option>
								     <option value="EP">EFECTIVO</option>
			                         <option value="ED">EFECTIVO DOLARES</option>
								     <!--option value="TC ECO">TARJETA DE CREDITO ECONOSUITES</option-->
			                         <option value="TC HABI">TARJETA DE CREDITO HABITACIONES</option>
									 <!--option value="TD">TARJETA DE DEBITO ECONOSUITES</option-->
			                         <option value="TD HABI">TARJETA DE DEBITO HABITACIONES</option-->
			                         <!--option value="TS">TRANSFERENCIA SUIZA</option-->
								     <!--option value="TM">TRANSFERENCIA MERRYLINCH</option-->
								     <!--option value="TIBJA">TRANSFERENCIA INTERBANCARIA JOSE ALBERTO</option-->
								     <!--option value="TIBECO">TRANSFERENCIA INTERBANCARIA ECONOSUITES</option-->
			                         <option value="TIBHABI">TRANSFERENCIA INTERBANCARIA HABITACIONES</option>
								     <!--option value="DJA">DEPOSITO CUENTA JOSE ALBERTO</option-->
								     <!--option value="DECO">DEPOSITO ECONOSUITES</option-->
								     <option value="PP">PAYPAL</option>
								     <option value="EXTRANET">EXTRANET</option>
								     <option value="VA">VOUCHER ABIERTO</option>
								     <option value="CORTESIA">CORTESIA</option>
									 <option value="AIRBNB TRANSFERENCIA">AIRBNB TRANSFERENCIA</option>
									 <option value="INTERMEDIARIO DE PAGOS (OXXO,SEVEN)">INTERMEDIARIO DE PAGOS (OXXO,SEVEN)</option>
									 <option value="NO SHOW">NO SHOW</option>
                 	     		 </select>
						     </td>
							 
							 <td align="right">
							 <input type="text" name="cantidadmod<?php echo$k;?>" id="cantidadmod<?php echo$k;?>" value="<?php echo $ls['cantidad'];?>" class="inpd" ><div id="msgcambiacantidad<?php echo$k;?>"></div></td>
							 <!--td align="right"><font style="float:left">$</font> <?echo Moneda2($ls['cantidad']);?></td-->
						     <td><input type="text" name="moneda<?php echo $k;?>" id="moneda<?php echo $k;?>" value="<?php echo $ls['moneda'];?>" class="inpd"></td>
						     <td align="right"><?echo $ls['divisa']?></td>
						     <td>
						     	<select name="propiedad<?php echo $k;?>" id="propiedad<?php echo $k;?>" class="selec" onchange="depas(this.id,<?php echo $k?>);">
			                         <option value="<?php echo  $ls['id_complejo'];?>"><?php echo  $ls['propiedad'];?></option>
						             <?php
						                $sqld=mysql_query("select id_complejo,nombre from complejo",$db_conexion);
						                while($prop=mysql_fetch_array($sqld))
						                     {
						                      echo "<option value='$prop[id_complejo]' style='font-size:10.5px;'>$prop[nombre]</option>";
						                     }
						             ?>
						        </select>
						        <select name="departamento<?php echo $k;?>" id="departamento<?php echo $k;?>" class="selec">
		                           <option value="<?php echo $ls['depa'];?>"><?php echo $ls['clave'];?></option>
					            </select>
						     </td>
						     <td>
						     	<input type="text" id="fentrada<?php echo $k; ?>" name="fentrada<?php echo $k; ?>" size="18" value="<?php echo $ls['entrada'];?>" class="inpd" readOnly>
						     	/<input type="text" id="fsalida<?php echo $k; ?>" name="fsalida<?php echo $k; ?>" size="18" value="<?php echo $ls['salida'];?>" class="inpd" readOnly>
								<script>
									var picker = new Pikaday(
									{
										field: document.getElementById('fentrada<?php echo $k; ?>'),
										format : "YYYY-MM-DD",
										firstDay: 1,
										minDate: new Date(1930, 0, 1),
										maxDate: new Date(<?php echo date('Y')+5;?>, 12, 31),
										yearRange: [1930,<?php echo date('Y')+5;?>]
									});
									</script>
									<script>
									var picker = new Pikaday(
									{
										field: document.getElementById('fsalida<?php echo $k; ?>'),
										format : "YYYY-MM-DD",
										firstDay: 1,
										minDate: new Date(1930, 0, 1),
										maxDate: new Date(<?php echo date('Y')+5;?>, 12, 31),
										yearRange: [1930,<?php echo date('Y')+5;?>]
									});
								</script>
								<?php //echo $ls['entrada']."/".$ls['salida']?></td>
						     <td title="<?echo htmlentities($ls['nombreeje']." ".$ls['apat']." ".$ls['amat']);?>"><?echo htmlentities($ls['ejecutivo']);?></td>
						     <td><?if($ls["comprobante"]==""){echo "";}else{?><a href="<?echo $ls["comprobante"];?>" target="_blank"><img src="images/zoom.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></a><?}?></td>
							  <td><img onclick="ventana(<?echo $ls["id_pago"];?>)" src="images/zoom.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></td>
<td><img onclick="ventanas(<?echo $ls["id_pago"];?>)" src="images/zoom.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></td>
							  <td><img onclick="borrar('<?echo $ls["id_pago"];?>','<?echo"f$l"?>' )" src="images/borrar.png" width="18" height="18" border='0' style="margin-left:-5px;" alt="Ver comprobante"></td>

							 <td><?echo $admonval?></td>
						     <td><input type="checkbox" id="val<?echo$k;?>" name="val<?echo$k;?>" <?echo$ch;?> value="s" onclick="javascript:validapago('<?echo$ls['id_pago']?>','<?echo$k?>','DEPOSITO','<?echo$idrenta?>','<?echo$idcliente?>','<?echo$ls['id_concepto'];?>');"><div id="validado<?echo$k;?>" style="position:absolute;width:15px;height:15px;margin-top:-17px;margin-left:17px"><?echo$img;?></div></td>
							 <td>
							   <?php 
							      $sqlpagmod = "SELECT COUNT(idpago) as pagosmod FROM bitacorapagos WHERE idpago = ".$ls['id_pago'];
								  $ejecutapagmod = mysql_query($sqlpagmod);
								  $regpagmod = mysql_fetch_array($ejecutapagmod);
								  if($regpagmod['pagosmod'] > 0){ ?>
									  <a href="bitacorapagos.php?idp=<?php echo $ls['id_pago'];?>" target="_blank" onClick="window.open(this.href, this.target, 'width=500,height=600'); return false;">Ver</a>
								  <?php } ?>
							 </td>
							 <td><a href="javascript:cambiacantidad('<?php echo$ls['id_pago']?>','<?php echo$k;?>');">Actualizar</a></td>
						 </tr>
						<?
						$k++;
					}
					if($k==1){
					    ?>
						<tr class="trb">
						     <td colspan='15' align="center">No se encontraron pagos nuevos por el concepto de DEPOSITO</td>
						 </tr>
						<?
					}
				 ?>
		     </table>
			 <br>
			 <br>
			 <br>
			 <br>
			 <br>
			</center>
		 </div>
	 </body>
</html>	