<?
session_start();
require('../valtiempoinact.php');
require("../conectar.php");
require("funciones.php");
$id_renta=$_POST["idrenta"];	
$sql="SELECT r.id_renta,r.folio,r.id_coordinador,r.id_ejecutivo,r.subtotal,r.iva,r.total,r.tipomoneda,r.formapago,r.restante,r.id_cliente,concat(c.nombre,' ',c.a_pat,' ',c.a_mat) as clinte FROM renta as r INNER JOIN clientes as c ON r.id_cliente=c.id_cliente WHERE id_renta='$id_renta' ";
$con=mysql_query($sql);
$re=mysql_fetch_array($con);

$sqlC="select id_concepto from conceptos where id_renta='$re[id_renta]'";
$ejeC=mysql_query($sqlC);
$regC=mysql_fetch_array($ejeC);
$idconceptoC=$regC['id_concepto'];
?>
<a href="javascript:$('.rentas').slideUp('slow');" class="cerrar"><img src="images/embad.png"></a>
<table class="rentatab" width="800">
     <tr class="filatit">
	     <th align="center" colspan="6"><?echo $re["clinte"];?></th>
     </tr>
	 <tr class="filatit">
	     <!--<td align="center">Folio</td>-->
	    
	     <td align="center">Modificar</td>
	     <td align="center">Renovar</td>
		 <!--<td align="center">Cedula</td>-->
		 <td align="center">Bitacora</td>
		 <td align="center">Pagos y Contratos</td> 
		 <td align="center">Convenio</td>
		 <!--<td align="center">Subir docs</td>
		 -->
		 <!--<td align="center">Prueba pagos</td>-->
     </tr>
    <?
	$idcliente=$re["id_cliente"];
	?>
	
	 <tr class="fila">
	     <!--<td><?echo $re["folio"]?></td>-->
	    
		 <td align="center">
		   <a target="_blank" href="regmodificar2.php?idcliente=<?echo$idcliente?>&idrenta=<?echo$re["id_renta"]?>"><img src="images/mod.png">
		 </td>
		 <td align="center">
		   <a target="_blank" href="regmodificar3.php?idcliente=<?echo$idcliente?>&idrenta=<?echo$re["id_renta"]?>"><img src="images/mod.png">
		 </td>
		 <!--<td align="center">
		    <a target="_blank" href="cedulas.php?idcliente=<?echo$idcliente?>&idrenta=<?echo$re["id_renta"]?>&idconcepto=<?echo$idconceptoC;?>"><img src="images/fpago.png" width="20" height="20">
		 </td>-->
		 <td align="center">
		    <a target="_blank" href="bitacorapros.php?idcliente=<?echo$idcliente?>&idrenta=<?echo$re["id_renta"]?>"><img src="images/fpago.png" width="20" height="20">
		 </td>
		 <td align="center">
		    <a target="_blank" href="listacontratoregistro.php?idcliente=<?echo$idcliente?>&idrenta=<?echo$re["id_renta"]?>"><img src="images/fpago.png" width="20" height="20">
		 </td>
		  <td align="center">
		    <a target="_blank" href="documentos-convenio.php?idcliente=<?echo$idcliente?>&idrenta=<?echo$re["id_renta"]?>"><img src="images/fpago.png" width="20" height="20">
		 </td>
		<!-- <td align="center">
		    <a target="_blank" href="subirdocscliente.php?idcliente=<?echo$idcliente?>&idrenta=<?echo$re["id_renta"]?>"><img src="images/fpago.png" width="20" height="20">
		 </td>-->
		  <!--<td align="center">
		    <a  href="pladePagos.php?idcliente=<?echo$idcliente?>&idrenta=<?echo$re["id_renta"]?>"><img src="images/fpago.png" width="20" height="20">
		 </td>
		 <td align="center">
		    <a target="_blank" href="pagos3.php?idcliente=<?echo$idcliente?>&idrenta=<?echo$re["id_renta"]?>"><img src="images/fpago.png" width="20" height="20">
		 </td>-->
	 </tr><!--
	<?/* $sqlas=" SELECT d.id_complejo as id_com,c.divisa,c.deposito,c.id_concepto,c.subtotal, c.impuesto as iva, c.total, c.tipomoneda, d.no_depto, d.clave from conceptos as c
INNER JOIN pagos as p ON p.id_renta=c.id_renta
 INNER JOIN departamentos as d ON d.id_departamento=c.id_departamento where c.id_renta='$re[id_renta]' and p.monto>0  group by c.id_concepto";
$cos=mysql_query($sqlas);

?>
<?

while($co=mysql_fetch_array($cos))
{
$totalpagado=0;
$resto=0;
$sqlsa="SELECT monto, tipo_moneda,divisa from pagos where id_concepto='$co[id_concepto]'";
$pag=mysql_query($sqlsa);
while($pa=mysql_fetch_array($pag))
{
if($pa["tipo_moneda"]=="MXN"){$totalpagado=$pa["monto"]+$totalpagado; }
if($pa["tipo_moneda"]=="USD"){$totalpagado=($pa["monto"]*$pa["divisa"])+$totalpagado; }

}
?>
<tr class="filatit">
		<td align="center">Departamento</td>
                <td align="center">Divisa</td>
		<td align="center">Subtotal</td>
	    <td align="center">Deposito en garantia</td>
		<td align="center">IVA</td>
	    <td align="center">Total de renta</td>
	    <td align="center">Total de pagos</td>
		<td align="center">Restante</td>
</tr>
<tr class="fila">	 
		 <td align="center"><? if($co["id_com"]==1){echo"TS";}if($co["id_com"]==2){echo"M";} if($co["id_com"]==3){echo"CT";}if($co["id_com"]==4){echo"CC";}if($co["id_com"]==5){echo"TP";} echo$co["no_depto"]." ".$co["clave"] ?></td>
                 <td align="center"><?echo moneda($co["divisa"]);?></td>
		 <td align="right"><?echo moneda($co["subtotal"])." ".$co["tipomoneda"];?></td>
		 <td align="right"><?echo moneda($co["deposito"])." ".$co["tipomoneda"];?></td>
	     <td align="right"><?echo moneda($co["iva"])." ".$co["tipomoneda"];?></td>
	     <td align="right"><?echo moneda($co["total"])." ".$co["tipomoneda"];?></td>
	     <td align="right"><?echo moneda($totalpagado)." MXN ";?></td>
<?
if($co["tipomoneda"]=="USD"){$totl=($co["total"]*$co["divisa"]);}
else{$totl=$co["total"];}
 $resto=$totl-$totalpagado;
?>		
		<td align="right"><?echo moneda($resto)." MXN ";?></td>
</tr>
<?}
	  
	*/  ?>
</table>-->
<?