<?
require("conectar.php");
$hoyss=date("Y-m-d");
/*$sql="select count(distinct c.id_concepto) FROM conceptos as c 
INNER JOIN pagos as p ON p.id_concepto=c.id_concepto 
INNER JOIN clientes as cli on cli.id_cliente=c.id_cliente 
WHERE c.status_renta IN('PAGADO','ANTICIPO') and p.valadmon='s' and c.dia_salida >'2014-01-01' and c.checkout='0' and (c.id_cliente NOT IN(select c2.id_cliente from conceptos as c2 where c2.dia_inicio=c.dia_salida and c2.status_renta IN('PAGADO','ANTICIPO') )) and c.dia_salida<'$hoyss' group by p.valadmon ) as totmorosos";*/

$sql="SELECT pr.inicial, c.id_concepto,pr.id_complejo, d.no_depto,d.id_departamento,c.id_renta AS id_renta, cl.email as emailcli, c.id_cliente AS id_cliente, c.dia_inicio AS fechai,c.dia_salida AS fechas, cl.nombre AS nombre, cl.a_pat AS apat, cl.a_mat AS amat,pr.nombre AS propiedad,d.clave AS clave, concat(SUBSTRING(e.nombre, 1, 1),SUBSTRING(e.a_pat, 1, 1),SUBSTRING(e.a_mat, 1, 1)) as ejecutivo, e.email2 as emaileje, e.id_empleado as emples,  e.coordinador FROM conceptos AS c INNER JOIN renta AS r ON c.id_renta = r.id_renta 
INNER JOIN clientes AS cl ON c.id_cliente = cl.id_cliente 
INNER JOIN pagos AS p ON c.id_concepto = p.id_concepto 
INNER JOIN complejo AS pr ON c.id_complejo=pr.id_complejo 
INNER JOIN departamentos as d ON c.id_departamento=d.id_departamento 
INNER JOIN empleados as e ON cl.id_emp=e.id_empleado 
WHERE c.dia_salida >'2014-01-01'  AND p.valadmon='s' and c.checkout='0' and (c.id_cliente NOT IN(select c2.id_cliente from conceptos as c2 where c2.dia_inicio=c.dia_salida and c2.status_renta IN('PAGADO','ANTICIPO') AND c2.id_concepto<>c.id_concepto)) and c.dia_salida<'$hoyss' group by c.id_concepto";
$eje=mysql_query($sql);
while($rowmoro=mysql_fetch_array($eje)){
  echo "<p><a href='cedulas.php?idrenta=$rowmoro[id_renta]&idcliente=$rowmoro[id_cliente]&idconcepto=$rowmoro[id_concepto]' target='_blank' title='Ver renta'><img src='images/zoom.png' width='18' height='18'></a>cliente: <b>".htmlentities($rowmoro['nombre'])." ".htmlentities($rowmoro['apat'])." ".htmlentities($rowmoro['amat'])."</b> <br>Fecha de estancia: del <b>$rowmoro[fechai]</b> al <b>$rowmoro[fechas]</b><br>Ejecutivo:<b> $rowmoro[ejecutivo]</b><br>Coordinador:<b> $coordinador</b><br>Suite: <b>";if($rowmoro["id_complejo"]==1){echo"TS";}if($rowmoro["id_complejo"]==2){echo"M";} if($rowmoro["id_complejo"]==3){echo"CT";}if($rowmoro["id_complejo"]==4){echo"CC";}if($rowmoro["id_complejo"]==5){echo"TP";} echo$rowmoro["no_depto"]." ";echo"$rowmoro[clave]</b><br>observacion:<b>$rowmoro[observacion]</b><br>Noches: ".$nochesmoroso."<br>";
}
?>