PageRenderTime 40ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/DEV/DISPLAY/modules/search_data.php

https://github.com/chrisbst35/LI_LEMONDE
PHP | 421 lines | 284 code | 59 blank | 78 comment | 87 complexity | 4364cb0bd020273a0b7d81f2fad9fac8 MD5 | raw file
  1. <?php if($_global['dev'] == 1 && isset($_GET['cmt']) && $_GET['cmt'] == 'on') { ?>
  2. <!-- begin : <?php echo __FILE__; ?> -->
  3. <?php } ?>
  4. <?php
  5. // checks cookie
  6. switch ($_global["self"])
  7. {
  8. case "detail.php" :
  9. case "detail_coloc.php" :
  10. if ($skip_cookie == false)
  11. {
  12. $idx = (isset($_REQUEST["search"]) ? $_REQUEST["search"] : 0);
  13. $search_request = $aLISearchHistoryCookieValue[$idx];
  14. }
  15. break;
  16. case "resultats_alerte.php" :
  17. if ($skip_cookie == false)
  18. {
  19. $idx = (isset($_REQUEST["search"]) ? $_REQUEST["search"] : 0);
  20. $search_request = $aLISearchHistoryCookieValue[$idx];
  21. }
  22. break;
  23. case "popup_send_to_friend.php" :
  24. $idx = (isset($_REQUEST["search"]) ? $_REQUEST["search"] : 0);
  25. $search_request = $aLISearchHistoryCookieValue[$idx];
  26. break;
  27. }
  28. // patches
  29. if ($_global["self"] != "resultats_agences.php")
  30. {
  31. // area
  32. if ($search_request["area"] == "") $search_request["area"] = -1;
  33. // price
  34. if ($search_request["price"] == "") $search_request["price"] = -1;
  35. // search summary
  36. if($_global['page']=='resultats') $search_summary = get_all_summary($search_request,true,true);
  37. else $search_summary = get_all_summary($search_request,true,false);
  38. }
  39. // action
  40. if ($search_agency == true)
  41. {
  42. $search_action = "/resultats_agence_annonces.php";
  43. }
  44. else
  45. {
  46. $search_action = "/recherche_nat.php";
  47. }
  48. // pour agence sans annonce(s)
  49. if ($_global["self"] == "resultats_agence_annonces.php") {
  50. // agence sans annonce (=> msg)
  51. if (!$is_agence_avec_annonces) {
  52. $site = strtoupper($_global["site"]);
  53. $trad = "_".$_global["lang"];
  54. $lang = strtoupper($_global["lang"]);
  55. $agency["lct_id"] = $agency["hierarchy"][2]["lct_id"];
  56. $loc_id = $agency["lct_id"];
  57. $sql = "
  58. SELECT
  59. CASE FILS.lct_parent_id
  60. WHEN 100 THEN
  61. 'PARIS'
  62. ELSE
  63. FILS.lct_name".$trad." END AS lct_name,
  64. 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
  65. FROM T_LOCALITY_LCT_".$site." AS FILS
  66. INNER JOIN T_LOCALITY_LCT_".$site." AS PARENT ON FILS.lct_parent_id = PARENT.lct_id
  67. WHERE FILS.lct_id = ".$loc_id."
  68. ";
  69. //echo "<hr>$sql<hr>";
  70. $chemin = pdoquery($sql);
  71. $value = $chemin[0];
  72. // code postal du département
  73. if ($value['lct_parent_post_code'] != '') $departement_post_code = clean_loc($value['lct_parent_post_code']);
  74. if (strlen($departement_post_code) == 3) {
  75. $departement_post_code = substr($departement_post_code, 0, 3);
  76. } else {
  77. $departement_post_code = substr($departement_post_code, 0, 2);
  78. }
  79. // ville
  80. $lct_id_ville_sql = $agency["lct_id"];
  81. //
  82. $sql = "
  83. SELECT lct_id,
  84. lct_level,
  85. lct_post_code,
  86. lct_name,
  87. lct_parent_id,
  88. lct_sal_pondering,
  89. lct_rnt_pondering
  90. FROM T_LOCALITY_LCT_FR
  91. WHERE lct_id = '".$lct_id_ville_sql."'
  92. ORDER BY lct_post_code ASC
  93. ";
  94. //echo "<hr>$sql<hr>";
  95. $liste_ville = pdoquery($sql);
  96. //
  97. $post_code_ville = $liste_ville[0]["lct_post_code"];
  98. $sal_count_ville = $liste_ville[0]["lct_sal_pondering"];
  99. $rnt_count_ville = $liste_ville[0]["lct_rnt_pondering"];
  100. // département
  101. $depart_sql = $liste_ville[0]['lct_parent_id'];
  102. //
  103. $sql = "
  104. SELECT lct_id,
  105. lct_level,
  106. lct_post_code,
  107. lct_name
  108. FROM T_LOCALITY_LCT_FR
  109. WHERE lct_id = '".$depart_sql."'
  110. AND lct_level = 1
  111. ORDER BY lct_post_code ASC
  112. ";
  113. //echo "<hr>$sql<hr>";
  114. $liste_depart = pdoquery($sql);
  115. //
  116. $post_code_depart = $liste_depart[0]["lct_post_code"];
  117. // villes et département (vente)
  118. $sal_locality = array();
  119. //
  120. // département
  121. if (!(string_begins_with($post_code_depart, '98') && (strlen($post_code_depart) == 2))) { // tout sauf Monaco
  122. foreach ($liste_depart as $key => $val) {
  123. $lct_id = $val['lct_id'];
  124. $lct_level = $val['lct_level'];
  125. if (string_begins_with($post_code_depart, '97') || string_begins_with($post_code_depart, '98')) { // DOM-TOM
  126. $code_postal = substr($val['lct_post_code'], 0, 3);
  127. } else if (string_begins_with($post_code_depart, '98') && (strlen($post_code_depart) == 2)) { // Monaco
  128. $code_postal = substr($val['lct_post_code'], 0, 2);
  129. } else { // autres départements
  130. $code_postal = substr($val['lct_post_code'], 0, 2);
  131. }
  132. $name_locality_long = ucwords2(strtolower($val['lct_name']));
  133. $name_locality_middle = $name_locality_long;
  134. $name_locality_short = $name_locality_long;
  135. /*$sal_locality[] = array(
  136. "lct_id" => $lct_id,
  137. "lct_level" => $lct_level,
  138. "code_postal" => $code_postal,
  139. "name_long" => $name_locality_long,
  140. "name_middle" => $name_locality_middle,
  141. "name_short" => $name_locality_short
  142. );*/
  143. }
  144. if (($post_code_ville != "75000") && ($post_code_ville != "13000") && ($post_code_ville != "69000")) {
  145. $is_ville_avec_arrondissements = false;
  146. $sql = "
  147. SELECT *
  148. FROM (
  149. SELECT lct_id,
  150. lct_level,
  151. lct_post_code,
  152. lct_name,
  153. lct_sal_pondering AS lct_pondering
  154. FROM T_LOCALITY_LCT_FR
  155. WHERE lct_post_code LIKE '".$code_postal."%'
  156. AND lct_level = 2
  157. ORDER BY lct_sal_pondering DESC
  158. LIMIT 0, 30
  159. ) AS t_loc ORDER BY lct_name
  160. ";
  161. //echo "<hr>$sql<hr>";
  162. $liste = pdoquery($sql);
  163. } else {
  164. $is_ville_avec_arrondissements = true;
  165. if ($post_code_ville == "75000") { // Paris
  166. $lct_ids = array(23599, 23601, 23602, 23603, 23604, 23605, 23606, 23607, 23609, 23589, 23590, 23591, 23592, 23593, 23594, 23595, 23596, 23597, 23598, 23600);
  167. } else if ($post_code_ville == "69000") { // Lyon
  168. $lct_ids = array(36119, 36120, 36121, 36122, 36123, 36124, 36125, 36126, 36127);
  169. } else if ($post_code_ville == "13000") { // Marseille
  170. $lct_ids = array(36102, 36104, 36105, 36106, 36107, 36108, 36109, 36110, 36111, 36112, 36113, 36114, 36115, 36116, 36117, 36118);
  171. }
  172. $sql = "
  173. SELECT *
  174. FROM (
  175. SELECT lct_id,
  176. lct_level,
  177. lct_post_code,
  178. lct_name,
  179. lct_sal_pondering AS lct_pondering
  180. FROM T_LOCALITY_LCT_FR
  181. WHERE lct_id IN (".implode(", ", $lct_ids).")
  182. AND lct_level = 2
  183. ORDER BY lct_sal_pondering DESC
  184. LIMIT 0, 30
  185. ) AS t_loc ORDER BY lct_name
  186. ";
  187. //echo "<hr>$sql<hr>";
  188. $liste = pdoquery($sql);
  189. }
  190. }
  191. // villes
  192. $name_locality_long_prev = "";
  193. foreach ($liste as $key => $val) {
  194. //if (($post_code_ville != "75000") && ($post_code_ville != "13000") && ($post_code_ville != "69000")) {
  195. $lct_id = $val['lct_id'];
  196. $lct_level = $val['lct_level'];
  197. $code_postal = $val['lct_post_code'];
  198. $name_locality_long = ucwords2(strtolower($val['lct_name']));
  199. $name_locality_middle = truncate2($name_locality_long, 30, "...");
  200. $name_locality_short = truncate2($name_locality_long, 20, "...");
  201. $name_locality_href = clean_loc_url(strtolower($val['lct_name']));
  202. $nbre_annces = $val['lct_pondering'];
  203. //if ($name_locality_long != $name_locality_long_prev) { // évite les éventuels doublons
  204. $sal_locality[] = array(
  205. "lct_id" => $lct_id,
  206. "lct_level" => $lct_level,
  207. "code_postal" => $code_postal,
  208. "name_long" => $name_locality_long,
  209. "name_middle" => $name_locality_middle,
  210. "name_short" => $name_locality_short,
  211. "name_href" => $name_locality_href,
  212. "nbre_annces" => $nbre_annces
  213. );
  214. //}
  215. $name_locality_long_prev = $name_locality_long;
  216. //}
  217. }
  218. // villes et département (vente)
  219. $rnt_locality = array();
  220. //
  221. // département
  222. if (!(string_begins_with($post_code_depart, '98') && (strlen($post_code_depart) == 2))) { // tout sauf Monaco
  223. foreach ($liste_depart as $key => $val) {
  224. $lct_id = $val['lct_id'];
  225. $lct_level = $val['lct_level'];
  226. if (string_begins_with($post_code_depart, '97') || string_begins_with($post_code_depart, '98')) { // DOM-TOM
  227. $code_postal = substr($val['lct_post_code'], 0, 3);
  228. } else if (string_begins_with($post_code_depart, '98') && (strlen($post_code_depart) == 2)) { // Monaco
  229. $code_postal = substr($val['lct_post_code'], 0, 2);
  230. } else { // autres départements
  231. $code_postal = substr($val['lct_post_code'], 0, 2);
  232. }
  233. $name_locality_long = ucwords2(strtolower($val['lct_name']));
  234. $name_locality_middle = $name_locality_long;
  235. $name_locality_short = $name_locality_long;
  236. /*$rnt_locality[] = array(
  237. "lct_id" => $lct_id,
  238. "lct_level" => $lct_level,
  239. "code_postal" => $code_postal,
  240. "name_long" => $name_locality_long,
  241. "name_middle" => $name_locality_middle,
  242. "name_short" => $name_locality_short
  243. );*/
  244. }
  245. if (($post_code_ville != "75000") && ($post_code_ville != "13000") && ($post_code_ville != "69000")) {
  246. $is_ville_avec_arrondissements = false;
  247. $sql = "
  248. SELECT *
  249. FROM (
  250. SELECT lct_id,
  251. lct_level,
  252. lct_post_code,
  253. lct_name,
  254. lct_rnt_pondering AS lct_pondering
  255. FROM T_LOCALITY_LCT_FR
  256. WHERE lct_post_code LIKE '".$code_postal."%'
  257. AND lct_level = 2
  258. ORDER BY lct_rnt_pondering DESC
  259. LIMIT 0, 30
  260. ) AS t_loc ORDER BY lct_name
  261. ";
  262. //echo "<hr>$sql<hr>";
  263. $liste = pdoquery($sql);
  264. } else {
  265. $is_ville_avec_arrondissements = true;
  266. if ($post_code_ville == "75000") { // Paris
  267. $lct_ids = array(23599, 23601, 23602, 23603, 23604, 23605, 23606, 23607, 23609, 23589, 23590, 23591, 23592, 23593, 23594, 23595, 23596, 23597, 23598, 23600);
  268. } else if ($post_code_ville == "69000") { // Lyon
  269. $lct_ids = array(36119, 36120, 36121, 36122, 36123, 36124, 36125, 36126, 36127);
  270. } else if ($post_code_ville == "13000") { // Marseille
  271. $lct_ids = array(36102, 36104, 36105, 36106, 36107, 36108, 36109, 36110, 36111, 36112, 36113, 36114, 36115, 36116, 36117, 36118);
  272. }
  273. $sql = "
  274. SELECT *
  275. FROM (
  276. SELECT lct_id,
  277. lct_level,
  278. lct_post_code,
  279. lct_name,
  280. lct_rnt_pondering AS lct_pondering
  281. FROM T_LOCALITY_LCT_FR
  282. WHERE lct_id IN (".implode(", ", $lct_ids).")
  283. AND lct_level = 2
  284. ORDER BY lct_rnt_pondering DESC
  285. LIMIT 0, 30
  286. ) AS t_loc ORDER BY lct_name
  287. ";
  288. //echo "<hr>$sql<hr>";
  289. $liste = pdoquery($sql);
  290. }
  291. }
  292. // villes
  293. $name_locality_long_prev = "";
  294. foreach ($liste as $key => $val) {
  295. //if (($post_code_ville != "75000") && ($post_code_ville != "13000") && ($post_code_ville != "69000")) {
  296. $lct_id = $val['lct_id'];
  297. $lct_level = $val['lct_level'];
  298. $code_postal = $val['lct_post_code'];
  299. $name_locality_long = ucwords2(strtolower($val['lct_name']));
  300. $name_locality_middle = truncate2($name_locality_long, 30, "...");
  301. $name_locality_short = truncate2($name_locality_long, 20, "...");
  302. $name_locality_href = clean_loc_url(strtolower($val['lct_name']));
  303. $nbre_annces = $val['lct_pondering'];
  304. //if ($name_locality_long != $name_locality_long_prev) { // évite les éventuels doublons
  305. $rnt_locality[] = array(
  306. "lct_id" => $lct_id,
  307. "lct_level" => $lct_level,
  308. "code_postal" => $code_postal,
  309. "name_long" => $name_locality_long,
  310. "name_middle" => $name_locality_middle,
  311. "name_short" => $name_locality_short,
  312. "name_href" => $name_locality_href,
  313. "nbre_annces" => $nbre_annces
  314. );
  315. //}
  316. $name_locality_long_prev = $name_locality_long;
  317. //}
  318. }
  319. $post_code = $liste_ville[0]["lct_post_code"];
  320. $departement = $liste_depart[0]["lct_name"];
  321. $count_sal_cols = intval(sizeof($sal_locality)/3); // on repartit tous les resultats sur 3 colonnes
  322. $count_rnt_cols = intval(sizeof($rnt_locality)/3); // on repartit tous les resultats sur 3 colonnes
  323. }
  324. }
  325. // pour modules/bloc_image_resu_edition.php + modules/bloc_seo_agence_immobilier.php
  326. if (($_global["self"] == "resultats.php") && ($_global['univers'] != 8) ) {
  327. // bloc_image_resu_edition.php
  328. parse_str($_SERVER["QUERY_STRING"], $url_parameters);
  329. // removes useless parameters
  330. unset($url_parameters["offset"]);
  331. unset($url_parameters["map"]);
  332. // adds page parameter
  333. $url_parameters["page"] = $_global["self"];
  334. // build iframe url
  335. $sMapLink = add_parameters("ve_map_300.php?".http_build_query($url_parameters));
  336. // search if the post code of the locality is referenced in an edition
  337. $post_codes = explode(",", $search_parameters['lzip'][0]);
  338. //$post_code = $search_parameters['lzip'][0];
  339. //echo "<hr>post_codes = ".print_r($post_codes, true); echo "<hr>"; //exit;
  340. /*foreach ($post_codes as $post_code) {
  341. $post_code = trim($post_code);
  342. $tab_edition = get_edition_from_post_code($post_code);
  343. //echo "<hr>post_code = ".$post_code." / tab_edition = "; print_r($tab_edition); echo "<hr>"; //exit;
  344. // dès qu'un n° d'édition est trouvé, on sort
  345. if (!is_null($tab_edition)) break;
  346. }*/
  347. $lockey1 = $search_request["loc_key1"];
  348. $loctab = explode("_", $lockey1);
  349. /*
  350. if ($loctab[1] == '98') {
  351. $loc_found['lct_name'] = 'toutes communes';
  352. } else {
  353. $loc_found = get_loc_key($search_parameters["loc_key1"]);
  354. }*/
  355. }
  356. ?>
  357. <?php if($_global['dev'] == 1 && isset($_GET['cmt']) && $_GET['cmt'] == 'on') { ?>
  358. <!-- //end : <?php echo __FILE__; ?> -->
  359. <?php } ?>