<?php
//ob_start();
include('./inc/php/variabili.php');
include('./inc/php/funzioni.php');
include('./inc/php/classeDatabase.php');
$myDb = new database($dbHost, $dbUser, $dbPass, $dbName);
$myDb -> connect();
$query = 'SELECT i.*, cat.categoria, cat.id AS id_categoria, col.codice, com.comune, t.tipologia, ';
$query .= 'IF(';
$query .= '(SELECT rib.prezzo FROM '.TABLE_RIBASSO.' AS rib WHERE i.id=rib.id_immobile LIMIT 1),';
$query .= '(SELECT rib.prezzo FROM '.TABLE_RIBASSO.' AS rib WHERE i.id=rib.id_immobile ORDER BY id DESC LIMIT 1),';
$query .= 'i.prezzo';
$query .= ') as prezzo ';
$query .= ' FROM '.TABLE_IMMOBILE.' AS i';
$query .= ' LEFT JOIN '.TABLE_CATEGORIA.' AS cat ON (cat.id=i.categoria)';
$query .= ' LEFT JOIN '.TABLE_COLLABORATORE.' AS col ON (col.id=i.interni_acquisito_da)';
$query .= ' LEFT JOIN '.TABLE_COMUNE.' AS com ON (com.id=i.comune)';
$query .= ' LEFT JOIN '.TABLE_TIPOLOGIA.' AS t ON (t.id=i.tipologia)';
$query .= ' WHERE (i.stato="on" OR i.stato="ghost") AND i.home="1" AND i.approved_once="1"';
$query .= ' ORDER BY RAND() DESC LIMIT 4';
$query1 = 'SELECT i.*, cat.categoria, cat.id AS id_categoria, col.codice, com.comune, t.tipologia, ';
$query1 .= 'IF(';
$query1 .= '(SELECT rib.prezzo FROM '.TABLE_RIBASSO.' AS rib WHERE i.id=rib.id_immobile LIMIT 1),';
$query1 .= '(SELECT CONCAT("€ ", REPLACE(FORMAT(rib.prezzo,0), ",", ".")) FROM '.TABLE_RIBASSO.' AS rib WHERE i.id=rib.id_immobile ORDER BY id DESC LIMIT 1),';
$query1 .= 'CONCAT("€ ", REPLACE(FORMAT(i.prezzo,0), ",", "."))';
$query1 .= ') as prezzo ';
$query1 .= ' FROM '.TABLE_IMMOBILE.' AS i';
$query1 .= ' LEFT JOIN '.TABLE_CATEGORIA.' AS cat ON (cat.id=i.categoria)';
$query1 .= ' LEFT JOIN '.TABLE_COLLABORATORE.' AS col ON (col.id=i.interni_acquisito_da)';
$query1 .= ' LEFT JOIN '.TABLE_COMUNE.' AS com ON (com.id=i.comune)';
$query1 .= ' LEFT JOIN '.TABLE_TIPOLOGIA.' AS t ON (t.id=i.tipologia)';
$query1 .= ' WHERE (i.stato="on" OR i.stato="ghost") AND i.home="1" AND i.approved_once="1" AND i.casa_vacanza="1"';
$query1 .= ' ORDER BY RAND() DESC LIMIT 1';//echo $query1;
$immo = $myDb -> query($query);
//debug($immo);
if($case_vacanza=$myDb -> query($query1)){
$immo[3]=$case_vacanza[0];
}
$immobili=$immo;
$TotImmobili = $myDb -> query('SELECT i.id FROM '.TABLE_IMMOBILE.' AS i WHERE i.stato="on" OR i.stato="ghost"');
$miniature = array();
/*
*/
foreach ($immobili as $immobile) {
if (is_dir($dir = $dirImgImmobili.$immobile['id'].'/')) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (!is_dir($dir.$file) && preg_match("/_primopiano\.jpg$/", $file) && is_file($dir.$file)) {
$pathImage=$dirImgImmobili.'/'.$immobile['id'];
if(isset($immobile['homeimg']))
$miniature[$immobile['id']] = str_replace('.jpg','_primopiano.jpg',$immobile['homeimg']);
else
$miniature[$immobile['id']] = $file;
break;
} else {
$pathImage=$dirImgImmobili;
$miniature[$immobile['id']] = '../default_primopiano.jpg';
}
}
closedir($dh);
}
}
}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="IT" />
<meta name="description" content="Corriga Immobiliare S.r.l. è un'agenzia di Cagliari leader nel settore dell'intermediazione immobiliare e creditizia. Il modo migliore per trovare casa." />
<meta name="abstract" content="Agenzia immobiliare specializzata nella vendita, acquisto e locazione di immobili residenziali, commerciali e turistici a Cagliari, Assemini, Quartu, Selargius, Pirri, Monserrato, Elmas, Villasimius, Sassari" />
<meta name="keywords" content="agenzia, affitti, case, vacanze, sardegna, cagliari, tipologia, piano, villa, trivano, casa, vendita, appartamenti, selargius, attico, quartu, immobile, immobiliare, camere, cerco, acquisto, posto, auto, corriga, piergiorgio, abitabile, cucina, corrigaimmobiliare, quadrivano, costruzione, soggiorno, elmas, open, space, bivano, pentavano, indipendente, centrale, affitto, litorale, ampio, giardino, costantinopoli, verande, terrazza, cantina, monolocale, immobili, pirri, villasimius" />
<meta name="robots" content="index,follow" />
<meta name="Classification" content="General" />
<meta name="revisit-after" content="7 days" />
<meta name="rating" content="General" />
<meta name="distribution" content="Global" />
<meta name="author" content="http://www.corrigaimmobiliare.it/" />
<meta name="copyright" content="Corriga Immobiliare S.r.l." />
<meta name="DC.title" content="Corriga Immobiliare Agenzia Cagliari, Sardegna" />
<meta name="geo.placename" content="Cagliari,Sardegna" />
<meta name="verify-v1" content="BMRGev0yxsQPgUOUkoIgVI3rKRjY8QQivezNgS8gdVY=" />
<meta name="y_key" content="080a95ddddda250e" />
<title>Agenzia Corriga Immobiliare - Cagliari, Sardegna</title>
<link rel="stylesheet" type="text/css" href="./css/corrigaimmobiliare.css" />
<link rel="shortcut icon" href="./img/favicon.ico" />
<!--[if IE 6]><link rel="stylesheet" type="text/css" href="./css/corrigaimmobiliare_ie6.css" /><![endif]-->
<!-- <link rel="stylesheet" type="text/css" href="webpresentatori/style/wp.css"/>-->
</head>
<body onload="FlvBoxReposition('corrigaf500x450ord138929','right');" onresize="FlvBoxReposition('corrigaf500x450ord138929','right')">
<?
include('./inc/php/menuTop.php');
?>
<div id="corpo">
<? include('./inc/php/testa.php'); ?>
<? include('./inc/php/colonna2.php'); ?>
<div id="primopiano">
<table cellspacing="0">
<tr><td colspan="3" class="griglia"> </td></tr>
<tr>
<? foreach ($immobili as $k=>$immobile) { ?>
<td class="scheda" valign="top">
<div class="first_line">
<a href="./immobili.php?categoria=<?=$immobile['id_categoria'];?>" class="categoria"><?=ucfirst($immobile['categoria']);?></a>
<? if(isset($immobile['vero_affare']) && $immobile['vero_affare']==1){ ?>
<div style="background:url(./img/ico_veroaffare_small.png) no-repeat;" title="vero affare"></div>
<? } ?>
<? if(isset($immobile['casa_vacanza']) && $immobile['casa_vacanza']==1){ ?>
<div style="background:url(./img/ico_casevacanza_small.png) no-repeat;" title="casa vacanze" ></div>
<? } ?>
</div>
<div class="second_line">
<a href="./scheda.php?immobile=<?=$immobile['codice'] . $immobile['id'];?>" class="immagine">
<img src="<?=$dirImg;?>frame.png" width="130" height="97" class="frame" alt="" />
<img src="<?=$dirImgImmobili.'/'.$immobile['id'].'/'.$miniature[$immobile['id']]?>" width="130" height="97" alt="" title="" />
</a>
<div>
<p><?=$immobile['comune'] . ' - '.$immobile['zona'];?></p>
<p class="classe_energetica">Classe energetica: <?=$immobile['classe_energetica'];?></p>
<p class="descrizione"><?=$immobile['descrizione'];?></p>
<?php
if ($immobile['prezzo']==0) echo '<p><strong>Da definire</strong></p>';
elseif ($immobile['prezzo']==1) echo '<p><strong>Trattativa riservata</strong></p>';
else echo '<p><strong>Euro '.number_format($immobile['prezzo'], 0, ',', '.').'</strong></p>';
?>
</div>
</div>
<a href="./scheda.php?immobile=<?=$immobile['codice'] . $immobile['id'];?>" class="dettagli">dettagli
<?php
if($immobile['casa_vacanza']==1) echo 'e disponibilità'
?>
</a>
</td>
<? switch (++$k) {
case 1:
case 3:
print '<td class="griglia verticale"> </td>';
break;
case 2:
print '</tr><tr><td colspan="3" class="griglia"> </td></tr><tr>';
break;
default:
break;
}
} ?>
</tr>
<tr><td colspan="3" class="griglia"> </td></tr>
</table>
<div id="totaleimmobili">Scegli tra i nostri <strong><?=count($TotImmobili);?></strong> immobili.</div>
<div id="ico_legend">
<div><img src="./img/ico_casevacanza_small.png" width="30" height="30" align="left" alt="" /><span>Casa Vacanze</span></div>
<div><img style="margin-top:3px" width="30" height="30" src="./img/ico_veroaffare_small.png" align="left" alt="" /><span>Vero Affare</span></div>
</div>
</div>
<br style="clear:both;" />
</div>
<div class="riga" style="margin-top:20px">
<? include('./inc/php/piede.php'); ?>
</div>
<div id="FlvBox" class="FlvBox">
</div>
<script type="text/javascript" src="./inc/js/mootools.js"></script>
<script type="text/javascript" src="./js/corrigaimmobiliare.js"></script>
<!-- riferimenti "web pesentatori" -->
<script type="text/javascript" src="webpresentatori/js/swfobject22.js"></script>
<script type="text/javascript" src="webpresentatori/js/wp.js"></script>
<!-- fine riferimenti "web pesentatori" -->
<script type="text/javascript">
flv_onLoad = "FIRST"; // FIRST , ALWAYS
flv_FirstVisit = "PLAY" ; // PLAY , PAUSE , HIDE
flv_OtherVisit = "HIDE" ; // PLAY , PAUSE , HIDE
flvPath = "http://www.corrigaimmobiliare.it/webpresentatori/";
swfPath = "http://www.corrigaimmobiliare.it/webpresentatori/";
flv_onCompleted = "CLOSE" ; // NONE , LINK , CLOSE
flv_onPaused = "CLOSE" ; // NONE , LINK , CLOSE
// flv_onPlaying = "NONE" ; // NONE , CUSTOM
FlvPlayer('FlvBox', 'corrigaf500x450ord138929', 'corrigaf500x450ord138929.flv', 500, 450, null, null);
// setTimeout("FlvBoxReposition('NomeDelFLV','LEFT')", 1000);
window.onload = window.onscroll =
window.onresize = function(){FlvBoxReposition('corrigaf500x450ord138929','right')};
function fnc__onPlaying(){}
function fnc__onCompleted(){}
function fnc__onPaused(){}
</script>
</body>
</html>
<?
$myDb -> disconnect();
?>