/DEV/DISPLAY/modules/search_data.php
PHP | 421 lines | 284 code | 59 blank | 78 comment | 87 complexity | 4364cb0bd020273a0b7d81f2fad9fac8 MD5 | raw file
- <?php if($_global['dev'] == 1 && isset($_GET['cmt']) && $_GET['cmt'] == 'on') { ?>
- <!-- begin : <?php echo __FILE__; ?> -->
- <?php } ?>
- <?php
-
- // checks cookie
- switch ($_global["self"])
- {
- case "detail.php" :
- case "detail_coloc.php" :
-
- if ($skip_cookie == false)
- {
- $idx = (isset($_REQUEST["search"]) ? $_REQUEST["search"] : 0);
- $search_request = $aLISearchHistoryCookieValue[$idx];
- }
-
- break;
- case "resultats_alerte.php" :
- if ($skip_cookie == false)
- {
- $idx = (isset($_REQUEST["search"]) ? $_REQUEST["search"] : 0);
- $search_request = $aLISearchHistoryCookieValue[$idx];
- }
- break;
- case "popup_send_to_friend.php" :
- $idx = (isset($_REQUEST["search"]) ? $_REQUEST["search"] : 0);
- $search_request = $aLISearchHistoryCookieValue[$idx];
- break;
- }
-
- // patches
- if ($_global["self"] != "resultats_agences.php")
- {
- // area
- if ($search_request["area"] == "") $search_request["area"] = -1;
- // price
- if ($search_request["price"] == "") $search_request["price"] = -1;
- // search summary
- if($_global['page']=='resultats') $search_summary = get_all_summary($search_request,true,true);
- else $search_summary = get_all_summary($search_request,true,false);
- }
- // action
- if ($search_agency == true)
- {
- $search_action = "/resultats_agence_annonces.php";
- }
- else
- {
- $search_action = "/recherche_nat.php";
- }
- // pour agence sans annonce(s)
- if ($_global["self"] == "resultats_agence_annonces.php") {
- // agence sans annonce (=> msg)
- if (!$is_agence_avec_annonces) {
- $site = strtoupper($_global["site"]);
- $trad = "_".$_global["lang"];
- $lang = strtoupper($_global["lang"]);
- $agency["lct_id"] = $agency["hierarchy"][2]["lct_id"];
- $loc_id = $agency["lct_id"];
- $sql = "
- SELECT
- CASE FILS.lct_parent_id
- WHEN 100 THEN
- 'PARIS'
- ELSE
- FILS.lct_name".$trad." END AS lct_name,
- FILS.lct_id, FILS.lct_post_code, FILS.lct_parent_id AS lct_parent, PARENT.lct_name".$trad." AS lct_parent_name, PARENT.lct_post_code AS lct_parent_post_code
- FROM T_LOCALITY_LCT_".$site." AS FILS
- INNER JOIN T_LOCALITY_LCT_".$site." AS PARENT ON FILS.lct_parent_id = PARENT.lct_id
- WHERE FILS.lct_id = ".$loc_id."
- ";
- //echo "<hr>$sql<hr>";
- $chemin = pdoquery($sql);
- $value = $chemin[0];
- // code postal du département
- if ($value['lct_parent_post_code'] != '') $departement_post_code = clean_loc($value['lct_parent_post_code']);
- if (strlen($departement_post_code) == 3) {
- $departement_post_code = substr($departement_post_code, 0, 3);
- } else {
- $departement_post_code = substr($departement_post_code, 0, 2);
- }
- // ville
- $lct_id_ville_sql = $agency["lct_id"];
- //
- $sql = "
- SELECT lct_id,
- lct_level,
- lct_post_code,
- lct_name,
- lct_parent_id,
- lct_sal_pondering,
- lct_rnt_pondering
- FROM T_LOCALITY_LCT_FR
- WHERE lct_id = '".$lct_id_ville_sql."'
- ORDER BY lct_post_code ASC
- ";
- //echo "<hr>$sql<hr>";
- $liste_ville = pdoquery($sql);
- //
- $post_code_ville = $liste_ville[0]["lct_post_code"];
- $sal_count_ville = $liste_ville[0]["lct_sal_pondering"];
- $rnt_count_ville = $liste_ville[0]["lct_rnt_pondering"];
- // département
- $depart_sql = $liste_ville[0]['lct_parent_id'];
- //
- $sql = "
- SELECT lct_id,
- lct_level,
- lct_post_code,
- lct_name
- FROM T_LOCALITY_LCT_FR
- WHERE lct_id = '".$depart_sql."'
- AND lct_level = 1
- ORDER BY lct_post_code ASC
- ";
- //echo "<hr>$sql<hr>";
- $liste_depart = pdoquery($sql);
- //
- $post_code_depart = $liste_depart[0]["lct_post_code"];
- // villes et département (vente)
- $sal_locality = array();
- //
- // département
- if (!(string_begins_with($post_code_depart, '98') && (strlen($post_code_depart) == 2))) { // tout sauf Monaco
- foreach ($liste_depart as $key => $val) {
- $lct_id = $val['lct_id'];
- $lct_level = $val['lct_level'];
- if (string_begins_with($post_code_depart, '97') || string_begins_with($post_code_depart, '98')) { // DOM-TOM
- $code_postal = substr($val['lct_post_code'], 0, 3);
- } else if (string_begins_with($post_code_depart, '98') && (strlen($post_code_depart) == 2)) { // Monaco
- $code_postal = substr($val['lct_post_code'], 0, 2);
- } else { // autres départements
- $code_postal = substr($val['lct_post_code'], 0, 2);
- }
- $name_locality_long = ucwords2(strtolower($val['lct_name']));
- $name_locality_middle = $name_locality_long;
- $name_locality_short = $name_locality_long;
- /*$sal_locality[] = array(
- "lct_id" => $lct_id,
- "lct_level" => $lct_level,
- "code_postal" => $code_postal,
- "name_long" => $name_locality_long,
- "name_middle" => $name_locality_middle,
- "name_short" => $name_locality_short
- );*/
- }
- if (($post_code_ville != "75000") && ($post_code_ville != "13000") && ($post_code_ville != "69000")) {
- $is_ville_avec_arrondissements = false;
- $sql = "
- SELECT *
- FROM (
- SELECT lct_id,
- lct_level,
- lct_post_code,
- lct_name,
- lct_sal_pondering AS lct_pondering
- FROM T_LOCALITY_LCT_FR
- WHERE lct_post_code LIKE '".$code_postal."%'
- AND lct_level = 2
- ORDER BY lct_sal_pondering DESC
- LIMIT 0, 30
- ) AS t_loc ORDER BY lct_name
- ";
- //echo "<hr>$sql<hr>";
- $liste = pdoquery($sql);
- } else {
- $is_ville_avec_arrondissements = true;
- if ($post_code_ville == "75000") { // Paris
- $lct_ids = array(23599, 23601, 23602, 23603, 23604, 23605, 23606, 23607, 23609, 23589, 23590, 23591, 23592, 23593, 23594, 23595, 23596, 23597, 23598, 23600);
- } else if ($post_code_ville == "69000") { // Lyon
- $lct_ids = array(36119, 36120, 36121, 36122, 36123, 36124, 36125, 36126, 36127);
- } else if ($post_code_ville == "13000") { // Marseille
- $lct_ids = array(36102, 36104, 36105, 36106, 36107, 36108, 36109, 36110, 36111, 36112, 36113, 36114, 36115, 36116, 36117, 36118);
- }
- $sql = "
- SELECT *
- FROM (
- SELECT lct_id,
- lct_level,
- lct_post_code,
- lct_name,
- lct_sal_pondering AS lct_pondering
- FROM T_LOCALITY_LCT_FR
- WHERE lct_id IN (".implode(", ", $lct_ids).")
- AND lct_level = 2
- ORDER BY lct_sal_pondering DESC
- LIMIT 0, 30
- ) AS t_loc ORDER BY lct_name
- ";
- //echo "<hr>$sql<hr>";
- $liste = pdoquery($sql);
- }
- }
- // villes
- $name_locality_long_prev = "";
- foreach ($liste as $key => $val) {
- //if (($post_code_ville != "75000") && ($post_code_ville != "13000") && ($post_code_ville != "69000")) {
- $lct_id = $val['lct_id'];
- $lct_level = $val['lct_level'];
- $code_postal = $val['lct_post_code'];
- $name_locality_long = ucwords2(strtolower($val['lct_name']));
- $name_locality_middle = truncate2($name_locality_long, 30, "...");
- $name_locality_short = truncate2($name_locality_long, 20, "...");
- $name_locality_href = clean_loc_url(strtolower($val['lct_name']));
- $nbre_annces = $val['lct_pondering'];
- //if ($name_locality_long != $name_locality_long_prev) { // évite les éventuels doublons
- $sal_locality[] = array(
- "lct_id" => $lct_id,
- "lct_level" => $lct_level,
- "code_postal" => $code_postal,
- "name_long" => $name_locality_long,
- "name_middle" => $name_locality_middle,
- "name_short" => $name_locality_short,
- "name_href" => $name_locality_href,
- "nbre_annces" => $nbre_annces
- );
- //}
- $name_locality_long_prev = $name_locality_long;
- //}
- }
- // villes et département (vente)
- $rnt_locality = array();
- //
- // département
- if (!(string_begins_with($post_code_depart, '98') && (strlen($post_code_depart) == 2))) { // tout sauf Monaco
- foreach ($liste_depart as $key => $val) {
- $lct_id = $val['lct_id'];
- $lct_level = $val['lct_level'];
- if (string_begins_with($post_code_depart, '97') || string_begins_with($post_code_depart, '98')) { // DOM-TOM
- $code_postal = substr($val['lct_post_code'], 0, 3);
- } else if (string_begins_with($post_code_depart, '98') && (strlen($post_code_depart) == 2)) { // Monaco
- $code_postal = substr($val['lct_post_code'], 0, 2);
- } else { // autres départements
- $code_postal = substr($val['lct_post_code'], 0, 2);
- }
- $name_locality_long = ucwords2(strtolower($val['lct_name']));
- $name_locality_middle = $name_locality_long;
- $name_locality_short = $name_locality_long;
- /*$rnt_locality[] = array(
- "lct_id" => $lct_id,
- "lct_level" => $lct_level,
- "code_postal" => $code_postal,
- "name_long" => $name_locality_long,
- "name_middle" => $name_locality_middle,
- "name_short" => $name_locality_short
- );*/
- }
- if (($post_code_ville != "75000") && ($post_code_ville != "13000") && ($post_code_ville != "69000")) {
- $is_ville_avec_arrondissements = false;
- $sql = "
- SELECT *
- FROM (
- SELECT lct_id,
- lct_level,
- lct_post_code,
- lct_name,
- lct_rnt_pondering AS lct_pondering
- FROM T_LOCALITY_LCT_FR
- WHERE lct_post_code LIKE '".$code_postal."%'
- AND lct_level = 2
- ORDER BY lct_rnt_pondering DESC
- LIMIT 0, 30
- ) AS t_loc ORDER BY lct_name
- ";
- //echo "<hr>$sql<hr>";
- $liste = pdoquery($sql);
- } else {
- $is_ville_avec_arrondissements = true;
- if ($post_code_ville == "75000") { // Paris
- $lct_ids = array(23599, 23601, 23602, 23603, 23604, 23605, 23606, 23607, 23609, 23589, 23590, 23591, 23592, 23593, 23594, 23595, 23596, 23597, 23598, 23600);
- } else if ($post_code_ville == "69000") { // Lyon
- $lct_ids = array(36119, 36120, 36121, 36122, 36123, 36124, 36125, 36126, 36127);
- } else if ($post_code_ville == "13000") { // Marseille
- $lct_ids = array(36102, 36104, 36105, 36106, 36107, 36108, 36109, 36110, 36111, 36112, 36113, 36114, 36115, 36116, 36117, 36118);
- }
- $sql = "
- SELECT *
- FROM (
- SELECT lct_id,
- lct_level,
- lct_post_code,
- lct_name,
- lct_rnt_pondering AS lct_pondering
- FROM T_LOCALITY_LCT_FR
- WHERE lct_id IN (".implode(", ", $lct_ids).")
- AND lct_level = 2
- ORDER BY lct_rnt_pondering DESC
- LIMIT 0, 30
- ) AS t_loc ORDER BY lct_name
- ";
- //echo "<hr>$sql<hr>";
- $liste = pdoquery($sql);
- }
- }
- // villes
- $name_locality_long_prev = "";
- foreach ($liste as $key => $val) {
- //if (($post_code_ville != "75000") && ($post_code_ville != "13000") && ($post_code_ville != "69000")) {
- $lct_id = $val['lct_id'];
- $lct_level = $val['lct_level'];
- $code_postal = $val['lct_post_code'];
- $name_locality_long = ucwords2(strtolower($val['lct_name']));
- $name_locality_middle = truncate2($name_locality_long, 30, "...");
- $name_locality_short = truncate2($name_locality_long, 20, "...");
- $name_locality_href = clean_loc_url(strtolower($val['lct_name']));
- $nbre_annces = $val['lct_pondering'];
- //if ($name_locality_long != $name_locality_long_prev) { // évite les éventuels doublons
- $rnt_locality[] = array(
- "lct_id" => $lct_id,
- "lct_level" => $lct_level,
- "code_postal" => $code_postal,
- "name_long" => $name_locality_long,
- "name_middle" => $name_locality_middle,
- "name_short" => $name_locality_short,
- "name_href" => $name_locality_href,
- "nbre_annces" => $nbre_annces
- );
- //}
- $name_locality_long_prev = $name_locality_long;
- //}
- }
- $post_code = $liste_ville[0]["lct_post_code"];
- $departement = $liste_depart[0]["lct_name"];
- $count_sal_cols = intval(sizeof($sal_locality)/3); // on repartit tous les resultats sur 3 colonnes
- $count_rnt_cols = intval(sizeof($rnt_locality)/3); // on repartit tous les resultats sur 3 colonnes
- }
- }
-
- // pour modules/bloc_image_resu_edition.php + modules/bloc_seo_agence_immobilier.php
- if (($_global["self"] == "resultats.php") && ($_global['univers'] != 8) ) {
-
- // bloc_image_resu_edition.php
-
- parse_str($_SERVER["QUERY_STRING"], $url_parameters);
-
- // removes useless parameters
- unset($url_parameters["offset"]);
- unset($url_parameters["map"]);
-
- // adds page parameter
- $url_parameters["page"] = $_global["self"];
-
- // build iframe url
- $sMapLink = add_parameters("ve_map_300.php?".http_build_query($url_parameters));
-
- // search if the post code of the locality is referenced in an edition
- $post_codes = explode(",", $search_parameters['lzip'][0]);
- //$post_code = $search_parameters['lzip'][0];
- //echo "<hr>post_codes = ".print_r($post_codes, true); echo "<hr>"; //exit;
-
- /*foreach ($post_codes as $post_code) {
-
- $post_code = trim($post_code);
- $tab_edition = get_edition_from_post_code($post_code);
- //echo "<hr>post_code = ".$post_code." / tab_edition = "; print_r($tab_edition); echo "<hr>"; //exit;
-
- // dès qu'un n° d'édition est trouvé, on sort
- if (!is_null($tab_edition)) break;
-
- }*/
-
- $lockey1 = $search_request["loc_key1"];
- $loctab = explode("_", $lockey1);
-
- /*
- if ($loctab[1] == '98') {
- $loc_found['lct_name'] = 'toutes communes';
- } else {
- $loc_found = get_loc_key($search_parameters["loc_key1"]);
- }*/
-
- }
-
- ?>
- <?php if($_global['dev'] == 1 && isset($_GET['cmt']) && $_GET['cmt'] == 'on') { ?>
- <!-- //end : <?php echo __FILE__; ?> -->
- <?php } ?>