map_model.php 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354
  1. <?php
  2. class map_model extends Model {
  3. public function get_map_results($lat_min,$lat_max,$lon_min,$lon_max,$search) {
  4. //die(print_r($search));
  5. $lat_min = $this->escapeString($lat_min);
  6. $lon_min = $this->escapeString($lon_min);
  7. $lat_max = $this->escapeString($lat_max);
  8. $lon_max = $this->escapeString($lon_max);
  9. $_SESSION['lat_min'] = $lat_min;
  10. $_SESSION['lat_max'] = $lat_max;
  11. $_SESSION['lon_min'] = $lon_min;
  12. $_SESSION['lon_max'] = $lon_max;
  13. if ($_SESSION['storedOrderField']=='') $_SESSION['storedOrderField'] = 'letrehozva';
  14. if ($_SESSION['storedOrderDirection']=='') $_SESSION['storedOrderDirection'] = 'DESC';
  15. $queryPostfix = $this->getInactiveOffices()." ORDER BY ".$_SESSION['storedOrderField']." ".$_SESSION['storedOrderDirection'];
  16. if ($_SESSION['lat_min']!='' && $_SESSION['lat_max']!='' && $_SESSION['lon_min']!='' && $_SESSION['lon_max']!='') {
  17. $tempSQL = "SELECT *,
  18. CONCAT(iranyitoszam,'.',telepules,',<br> (',korzet,') ',utcanev) AS name,
  19. googlelat AS lat,
  20. googlelon AS lng FROM
  21. hiper_ingatlan WHERE
  22. googlelat>='".$_SESSION['lat_min']."' AND
  23. googlelat<='".$_SESSION['lat_max']."' AND
  24. googlelon>='".$_SESSION['lon_min']."' AND
  25. googlelon<='".$_SESSION['lon_max']."' AND
  26. statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  27. }
  28. else {
  29. $tempSQL = "SELECT *,
  30. CONCAT(iranyitoszam,'.',telepules,',<br> (',korzet,') ',utcanev) AS name,
  31. googlelat AS lat,
  32. googlelon AS lng FROM
  33. hiper_ingatlan WHERE
  34. statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  35. }
  36. if ($_SESSION['statusz_switch']=='uj') $tempSQL.= " AND jogi_statusz='uj'";
  37. if ($_SESSION['statusz_switch']=='legujabb') $tempSQL.= " AND letrehozva >= DATE(NOW()) - INTERVAL 14 DAY";
  38. if ($search['ertekesites']!='') $tempSQL.= " AND ertekesites='".$search['ertekesites']."'";
  39. //if ($search['jelleg']!='') $tempSQL.= " AND jelleg='".$search['jelleg']."'";
  40. if ($_SESSION['wtf']!='') $tempSQL.= " AND jelleg='".$_SESSION['wtf']."'";
  41. if ($search['tipus']!='') $tempSQL.= " AND tipus='".$search['tipus']."'";
  42. if ($search['ertekesites']=='elado') {
  43. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000000'";
  44. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000000'";
  45. }
  46. else {
  47. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000'";
  48. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000'";
  49. }
  50. if ($search['meret_netto_min']!='') $tempSQL.= " AND meret_brutto>='".$search['meret_netto_min']."'";
  51. if ($search['meret_netto_max']!='') $tempSQL.= " AND meret_brutto<='".$search['meret_netto_max']."'";
  52. if ($search['altipus']!='') {
  53. $list = explode(",",$search['altipus']);
  54. $altipusok = "";
  55. foreach ($list as $altipus) {
  56. $altipusok.= "'".$altipus."',";
  57. }
  58. $altipusok = rtrim($altipusok,',');
  59. $tempSQL.= " AND altipus IN (".$altipusok.")";
  60. }
  61. if ($search['jogi_statusz']!='') $tempSQL.= " AND jogi_statusz='".$search['jogi_statusz']."'";
  62. //if ($search['szoba_min']!='') $tempSQL.= " AND szoba>='".$search['szoba_min']."'";
  63. //if ($search['szoba_max']!='') $tempSQL.= " AND szoba<='".$search['szoba_max']."'";
  64. if ($search['kilatas']!='') {
  65. $list = explode(",",$search['kilatas']);
  66. $kilatasok = "";
  67. foreach ($list as $kilatas) {
  68. $kilatasok.= "'".$kilatas."',";
  69. }
  70. $kilatasok = rtrim($kilatasok,',');
  71. $tempSQL.= " AND kilatas IN (".$kilatasok.")";
  72. }
  73. if ($search['futes']!='') {
  74. $list = explode(",",$search['futes']);
  75. $futesek = "";
  76. foreach ($list as $futes) {
  77. $futesek.= "'".$futes."',";
  78. }
  79. $futesek = rtrim($futesek,',');
  80. $tempSQL.= " AND futes IN (".$futesek.")";
  81. }
  82. if ($search['tajolas']!='') {
  83. $list = explode(",",$search['tajolas']);
  84. $tajolasok = "";
  85. foreach ($list as $tajolas) {
  86. $tajolasok.= "'".$tajolas."',";
  87. }
  88. $tajolasok = rtrim($tajolasok,',');
  89. $tempSQL.= " AND tajolas IN (".$tajolasok.")";
  90. }
  91. if ($search['allapot']!='') {
  92. $list = explode(",",$search['allapot']);
  93. $allapotok = "";
  94. foreach ($list as $allapot) {
  95. $allapotok.= "'".$allapot."',";
  96. }
  97. $allapotok = rtrim($allapotok,',');
  98. $tempSQL.= " AND ingatlan_allapota IN (".$allapotok.")";
  99. }
  100. if ($search['kornyek']!='') {
  101. $list = explode(",",$search['kornyek']);
  102. $kornyekek = "";
  103. foreach ($list as $kornyek) {
  104. $kornyekek.= "'".$kornyek."',";
  105. }
  106. $kornyekek = rtrim($kornyekek,',');
  107. $tempSQL.= " AND kornyek IN (".$kornyekek.")";
  108. }
  109. if ($search['epites_eve_min']!='') $tempSQL.= " AND epites_eve>='".$search['epites_eve_min']."'";
  110. if ($search['epites_eve_max']!='') $tempSQL.= " AND epites_eve<='".$search['epites_eve_max']."'";
  111. if ($search['telek_min']!='') $tempSQL.= " AND meret_telek>='".$search['telek_min']."'";
  112. if ($search['telek_max']!='') $tempSQL.= " AND meret_telek<='".$search['telek_max']."'";
  113. if ($search['ferohely_garazs_min']!='') $tempSQL.= " AND ferohely_garazs>='".$search['ferohely_garazs_min']."'";
  114. if ($search['ferohely_garazs_max']!='') $tempSQL.= " AND ferohely_garazs<='".$search['ferohely_garazs_max']."'";
  115. if ($search['kulon_nyilo_szobak']=='1') $tempSQL.= " AND kulon_nyilo_szobak='1'";
  116. if ($search['terasz']=='1') $tempSQL.= " AND terasz='1'";
  117. if ($search['erkely']=='1') $tempSQL.= " AND erkely='1'";
  118. if ($search['pince']=='1') $tempSQL.= " AND pince='1'";
  119. if ($search['tarolo']=='1') $tempSQL.= " AND tarolo='1'";
  120. if ($search['garazs']=='1') $tempSQL.= " AND garazs='1'";
  121. if ($search['ferohely_fedettbeallo']=='1') $tempSQL.= " AND ferohely_fedettbeallo='1'";
  122. if ($search['kertkapcsolatos']=='1') $tempSQL.= " AND kertkapcsolatos='1'";
  123. if ($search['viz']=='1') $tempSQL.= " AND viz='1'";
  124. if ($search['gaz']=='1') $tempSQL.= " AND gaz='1'";
  125. if ($search['villany']=='1') $tempSQL.= " AND villany='1'";
  126. if ($search['csatorna']=='1') $tempSQL.= " AND csatorna='1'";
  127. if ($search['lift']=='1') $tempSQL.= " AND lift='1'";
  128. //die($tempSQL." ".$queryPostfix.$this->lazy_loader());
  129. $result = $this->query($tempSQL." ".$queryPostfix.$this->lazy_loader());
  130. $all = $this->query($tempSQL." ".$queryPostfix);
  131. if ($search['szoba_min']!='' || $search['szoba_max']!='') {
  132. foreach ($result as $row) {
  133. $szoba = $row->szoba_fel+$row->szoba_egesz;
  134. if ($szoba>=$search['szoba_min'] && $szoba<=$search['szoba_max']) {
  135. $return[] = $row;
  136. }
  137. }
  138. $result = $return;
  139. }
  140. if ($_SESSION['statusz_switch']=='arcsokkent') {
  141. $return = null;
  142. foreach ($all as $row) {
  143. if ($this->isArcsokkent($row->regszam)) {
  144. $return[] = $row;
  145. }
  146. }
  147. $result = $return;
  148. }
  149. return $result;
  150. }
  151. public function getInactiveOffices() {
  152. $check = $this->query("SELECT * FROM irodak where active='0';");
  153. foreach ($check as $row) {
  154. $temp[] = $row->office_id;
  155. }
  156. if (count($temp)>0) {
  157. return ' AND iroda NOT IN (\''.implode('\',\'',$temp).'\')';
  158. }
  159. else {
  160. return '';
  161. }
  162. }
  163. public function get_map_results_circle($search) {
  164. if ($_SESSION['storedOrderField']=='') $_SESSION['storedOrderField'] = 'letrehozva';
  165. if ($_SESSION['storedOrderDirection']=='') $_SESSION['storedOrderDirection'] = 'DESC';
  166. $queryPostfix = $this->getInactiveOffices()." ORDER BY ".$_SESSION['storedOrderField']." ".$_SESSION['storedOrderDirection'];
  167. $tempSQL = "SELECT *,
  168. CONCAT(iranyitoszam,'.',telepules,',<br> (',korzet,') ',utcanev) AS name,
  169. googlelat AS lat,
  170. googlelon AS lng FROM
  171. hiper_ingatlan WHERE
  172. statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  173. if ($search['ertekesites']!='') $tempSQL.= " AND ertekesites='".$search['ertekesites']."'";
  174. //if ($search['jelleg']!='') $tempSQL.= " AND jelleg='".$search['jelleg']."'";
  175. if ($_SESSION['wtf']!='') $tempSQL.= " AND jelleg='".$_SESSION['wtf']."'";
  176. if ($search['tipus']!='') $tempSQL.= " AND tipus='".$search['tipus']."'";
  177. if ($search['ertekesites']=='elado') {
  178. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000000'";
  179. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000000'";
  180. }
  181. else {
  182. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000'";
  183. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000'";
  184. }
  185. if ($_SESSION['statusz_switch']=='uj') $tempSQL.= " AND jogi_statusz='uj'";
  186. if ($_SESSION['statusz_switch']=='legujabb') $tempSQL.= " AND letrehozva >= DATE(NOW()) - INTERVAL 14 DAY";
  187. if ($search['meret_netto_min']!='') $tempSQL.= " AND meret_brutto>='".$search['meret_netto_min']."'";
  188. if ($search['meret_netto_max']!='') $tempSQL.= " AND meret_brutto<='".$search['meret_netto_max']."'";
  189. if ($search['altipus']!='') {
  190. $list = explode(",",$search['altipus']);
  191. $altipusok = "";
  192. foreach ($list as $altipus) {
  193. $altipusok.= "'".$altipus."',";
  194. }
  195. $altipusok = rtrim($altipusok,',');
  196. $tempSQL.= " AND altipus IN (".$altipusok.")";
  197. }
  198. if ($search['jogi_statusz']!='') $tempSQL.= " AND jogi_statusz='".$search['jogi_statusz']."'";
  199. //if ($search['szoba_min']!='') $tempSQL.= " AND szoba>='".$search['szoba_min']."'";
  200. //if ($search['szoba_max']!='') $tempSQL.= " AND szoba<='".$search['szoba_max']."'";
  201. if ($search['kilatas']!='') {
  202. $list = explode(",",$search['kilatas']);
  203. $kilatasok = "";
  204. foreach ($list as $kilatas) {
  205. $kilatasok.= "'".$kilatas."',";
  206. }
  207. $kilatasok = rtrim($kilatasok,',');
  208. $tempSQL.= " AND kilatas IN (".$kilatasok.")";
  209. }
  210. if ($search['futes']!='') {
  211. $list = explode(",",$search['futes']);
  212. $futesek = "";
  213. foreach ($list as $futes) {
  214. $futesek.= "'".$futes."',";
  215. }
  216. $futesek = rtrim($futesek,',');
  217. $tempSQL.= " AND futes IN (".$futesek.")";
  218. }
  219. if ($search['tajolas']!='') {
  220. $list = explode(",",$search['tajolas']);
  221. $tajolasok = "";
  222. foreach ($list as $tajolas) {
  223. $tajolasok.= "'".$tajolas."',";
  224. }
  225. $tajolasok = rtrim($tajolasok,',');
  226. $tempSQL.= " AND tajolas IN (".$tajolasok.")";
  227. }
  228. if ($search['allapot']!='') {
  229. $list = explode(",",$search['allapot']);
  230. $allapotok = "";
  231. foreach ($list as $allapot) {
  232. $allapotok.= "'".$allapot."',";
  233. }
  234. $allapotok = rtrim($allapotok,',');
  235. $tempSQL.= " AND ingatlan_allapota IN (".$allapotok.")";
  236. }
  237. if ($search['kornyek']!='') {
  238. $list = explode(",",$search['kornyek']);
  239. $kornyekek = "";
  240. foreach ($list as $kornyek) {
  241. $kornyekek.= "'".$kornyek."',";
  242. }
  243. $kornyekek = rtrim($kornyekek,',');
  244. $tempSQL.= " AND kornyek IN (".$kornyekek.")";
  245. }
  246. if ($search['epites_eve_min']!='') $tempSQL.= " AND epites_eve>='".$search['epites_eve_min']."'";
  247. if ($search['epites_eve_max']!='') $tempSQL.= " AND epites_eve<='".$search['epites_eve_max']."'";
  248. if ($search['telek_min']!='') $tempSQL.= " AND meret_telek>='".$search['telek_min']."'";
  249. if ($search['telek_max']!='') $tempSQL.= " AND meret_telek<='".$search['telek_max']."'";
  250. if ($search['ferohely_garazs_min']!='') $tempSQL.= " AND ferohely_garazs>='".$search['ferohely_garazs_min']."'";
  251. if ($search['ferohely_garazs_max']!='') $tempSQL.= " AND ferohely_garazs<='".$search['ferohely_garazs_max']."'";
  252. if ($search['kulon_nyilo_szobak']=='1') $tempSQL.= " AND kulon_nyilo_szobak='1'";
  253. if ($search['terasz']=='1') $tempSQL.= " AND terasz='1'";
  254. if ($search['erkely']=='1') $tempSQL.= " AND erkely='1'";
  255. if ($search['pince']=='1') $tempSQL.= " AND pince='1'";
  256. if ($search['tarolo']=='1') $tempSQL.= " AND tarolo='1'";
  257. if ($search['garazs']=='1') $tempSQL.= " AND garazs='1'";
  258. if ($search['ferohely_fedettbeallo']=='1') $tempSQL.= " AND ferohely_fedettbeallo='1'";
  259. if ($search['kertkapcsolatos']=='1') $tempSQL.= " AND kertkapcsolatos='1'";
  260. if ($search['viz']=='1') $tempSQL.= " AND viz='1'";
  261. if ($search['gaz']=='1') $tempSQL.= " AND gaz='1'";
  262. if ($search['villany']=='1') $tempSQL.= " AND villany='1'";
  263. if ($search['csatorna']=='1') $tempSQL.= " AND csatorna='1'";
  264. if ($search['lift']=='1') $tempSQL.= " AND lift='1'";
  265. $result = $this->query($tempSQL." ".$queryPostfix);
  266. if ($search['szoba_min']!='' || $search['szoba_max']!='') {
  267. foreach ($result as $row) {
  268. $szoba = $row->szoba_fel+$row->szoba_egesz;
  269. if ($szoba>=$search['szoba_min'] && $szoba<=$search['szoba_max']) {
  270. $return[] = $row;
  271. }
  272. }
  273. $result = $return;
  274. }
  275. if ($_SESSION['statusz_switch']=='arcsokkent') {
  276. $return = null;
  277. foreach ($result as $row) {
  278. if ($this->isArcsokkent($row->regszam)) {
  279. $return[] = $row;
  280. }
  281. }
  282. $result = $return;
  283. }
  284. return $result;
  285. }
  286. public function get_map_results_all($lat_min,$lat_max,$lon_min,$lon_max,$search) {
  287. $lat_min = $this->escapeString($lat_min);
  288. $lon_min = $this->escapeString($lon_min);
  289. $lat_max = $this->escapeString($lat_max);
  290. $lon_max = $this->escapeString($lon_max);
  291. $_SESSION['lat_min'] = $lat_min;
  292. $_SESSION['lat_max'] = $lat_max;
  293. $_SESSION['lon_min'] = $lon_min;
  294. $_SESSION['lon_max'] = $lon_max;
  295. if ($_SESSION['storedOrderField']=='') $_SESSION['storedOrderField'] = 'letrehozva';
  296. if ($_SESSION['storedOrderDirection']=='') $_SESSION['storedOrderDirection'] = 'DESC';
  297. $queryPostfix = $this->getInactiveOffices()." ORDER BY ".$_SESSION['storedOrderField']." ".$_SESSION['storedOrderDirection'];
  298. if ($_SESSION['lat_min']!='' && $_SESSION['lat_max']!='' && $_SESSION['lon_min']!='' && $_SESSION['lon_max']!='') {
  299. $tempSQL = "SELECT *,
  300. CONCAT(iranyitoszam,'.',telepules,',<br> (',korzet,') ',utcanev) AS name,
  301. googlelat AS lat,
  302. googlelon AS lng FROM
  303. hiper_ingatlan WHERE
  304. googlelat>='".$_SESSION['lat_min']."' AND
  305. googlelat<='".$_SESSION['lat_max']."' AND
  306. googlelon>='".$_SESSION['lon_min']."' AND
  307. googlelon<='".$_SESSION['lon_max']."' AND
  308. statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  309. }
  310. else {
  311. $tempSQL = "SELECT *,
  312. CONCAT(iranyitoszam,'.',telepules,',<br> (',korzet,') ',utcanev) AS name,
  313. googlelat AS lat,
  314. googlelon AS lng FROM
  315. hiper_ingatlan WHERE
  316. statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  317. }
  318. if ($search['ertekesites']!='') $tempSQL.= " AND ertekesites='".$search['ertekesites']."'";
  319. //if ($search['jelleg']!='') $tempSQL.= " AND jelleg='".$search['jelleg']."'";
  320. if ($_SESSION['wtf']!='') $tempSQL.= " AND jelleg='".$_SESSION['wtf']."'";
  321. if ($search['tipus']!='') $tempSQL.= " AND tipus='".$search['tipus']."'";
  322. if ($_SESSION['statusz_switch']=='uj') $tempSQL.= " AND jogi_statusz='uj'";
  323. if ($_SESSION['statusz_switch']=='legujabb') $tempSQL.= " AND letrehozva >= DATE(NOW()) - INTERVAL 14 DAY";
  324. if ($search['ertekesites']=='elado') {
  325. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000000'";
  326. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000000'";
  327. }
  328. else {
  329. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000'";
  330. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000'";
  331. }
  332. if ($search['meret_netto_min']!='') $tempSQL.= " AND meret_brutto>='".$search['meret_netto_min']."'";
  333. if ($search['meret_netto_max']!='') $tempSQL.= " AND meret_brutto<='".$search['meret_netto_max']."'";
  334. if ($search['altipus']!='') {
  335. $list = explode(",",$search['altipus']);
  336. $altipusok = "";
  337. foreach ($list as $altipus) {
  338. $altipusok.= "'".$altipus."',";
  339. }
  340. $altipusok = rtrim($altipusok,',');
  341. $tempSQL.= " AND altipus IN (".$altipusok.")";
  342. }
  343. if ($search['jogi_statusz']!='') $tempSQL.= " AND jogi_statusz='".$search['jogi_statusz']."'";
  344. //if ($search['szoba_min']!='') $tempSQL.= " AND szoba>='".$search['szoba_min']."'";
  345. //if ($search['szoba_max']!='') $tempSQL.= " AND szoba<='".$search['szoba_max']."'";
  346. if ($search['kilatas']!='') {
  347. $list = explode(",",$search['kilatas']);
  348. $kilatasok = "";
  349. foreach ($list as $kilatas) {
  350. $kilatasok.= "'".$kilatas."',";
  351. }
  352. $kilatasok = rtrim($kilatasok,',');
  353. $tempSQL.= " AND kilatas IN (".$kilatasok.")";
  354. }
  355. if ($search['futes']!='') {
  356. $list = explode(",",$search['futes']);
  357. $futesek = "";
  358. foreach ($list as $futes) {
  359. $futesek.= "'".$futes."',";
  360. }
  361. $futesek = rtrim($futesek,',');
  362. $tempSQL.= " AND futes IN (".$futesek.")";
  363. }
  364. if ($search['tajolas']!='') {
  365. $list = explode(",",$search['tajolas']);
  366. $tajolasok = "";
  367. foreach ($list as $tajolas) {
  368. $tajolasok.= "'".$tajolas."',";
  369. }
  370. $tajolasok = rtrim($tajolasok,',');
  371. $tempSQL.= " AND tajolas IN (".$tajolasok.")";
  372. }
  373. if ($search['allapot']!='') {
  374. $list = explode(",",$search['allapot']);
  375. $allapotok = "";
  376. foreach ($list as $allapot) {
  377. $allapotok.= "'".$allapot."',";
  378. }
  379. $allapotok = rtrim($allapotok,',');
  380. $tempSQL.= " AND ingatlan_allapota IN (".$allapotok.")";
  381. }
  382. if ($search['kornyek']!='') {
  383. $list = explode(",",$search['kornyek']);
  384. $kornyekek = "";
  385. foreach ($list as $kornyek) {
  386. $kornyekek.= "'".$kornyek."',";
  387. }
  388. $kornyekek = rtrim($kornyekek,',');
  389. $tempSQL.= " AND kornyek IN (".$kornyekek.")";
  390. }
  391. if ($search['epites_eve_min']!='') $tempSQL.= " AND epites_eve>='".$search['epites_eve_min']."'";
  392. if ($search['epites_eve_max']!='') $tempSQL.= " AND epites_eve<='".$search['epites_eve_max']."'";
  393. if ($search['telek_min']!='') $tempSQL.= " AND meret_telek>='".$search['telek_min']."'";
  394. if ($search['telek_max']!='') $tempSQL.= " AND meret_telek<='".$search['telek_max']."'";
  395. if ($search['ferohely_garazs_min']!='') $tempSQL.= " AND ferohely_garazs>='".$search['ferohely_garazs_min']."'";
  396. if ($search['ferohely_garazs_max']!='') $tempSQL.= " AND ferohely_garazs<='".$search['ferohely_garazs_max']."'";
  397. if ($search['kulon_nyilo_szobak']=='1') $tempSQL.= " AND kulon_nyilo_szobak='1'";
  398. if ($search['terasz']=='1') $tempSQL.= " AND terasz='1'";
  399. if ($search['erkely']=='1') $tempSQL.= " AND erkely='1'";
  400. if ($search['pince']=='1') $tempSQL.= " AND pince='1'";
  401. if ($search['tarolo']=='1') $tempSQL.= " AND tarolo='1'";
  402. if ($search['garazs']=='1') $tempSQL.= " AND garazs='1'";
  403. if ($search['ferohely_fedettbeallo']=='1') $tempSQL.= " AND ferohely_fedettbeallo='1'";
  404. if ($search['kertkapcsolatos']=='1') $tempSQL.= " AND kertkapcsolatos='1'";
  405. if ($search['viz']=='1') $tempSQL.= " AND viz='1'";
  406. if ($search['gaz']=='1') $tempSQL.= " AND gaz='1'";
  407. if ($search['villany']=='1') $tempSQL.= " AND villany='1'";
  408. if ($search['csatorna']=='1') $tempSQL.= " AND csatorna='1'";
  409. if ($search['lift']=='1') $tempSQL.= " AND lift='1'";
  410. $result = $this->query($tempSQL." ".$queryPostfix);
  411. if ($search['szoba_min']!='' || $search['szoba_max']!='') {
  412. foreach ($result as $row) {
  413. $szoba = $row->szoba_fel+$row->szoba_egesz;
  414. if ($szoba>=$search['szoba_min'] && $szoba<=$search['szoba_max']) {
  415. $return[] = $row;
  416. }
  417. }
  418. $result = $return;
  419. }
  420. if ($_SESSION['statusz_switch']=='arcsokkent') {
  421. $return = null;
  422. foreach ($result as $row) {
  423. if ($this->isArcsokkent($row->regszam)) {
  424. $return[] = $row;
  425. }
  426. }
  427. $result = $return;
  428. }
  429. return $result;
  430. }
  431. public function lazy_loader() {
  432. if ($_SESSION['storedPager']=='') $_SESSION['storedPager'] = '0';
  433. return " LIMIT ".$_SESSION['storedPager'].",5;";
  434. }
  435. public function lazy_has_more($search) {
  436. if ($_SESSION['lat_min']!='' && $_SESSION['lat_max']!='' && $_SESSION['lon_min']!='' && $_SESSION['lon_max']!='') {
  437. $tempSQL = "SELECT *,
  438. CONCAT(iranyitoszam,'.',telepules,',<br> (',korzet,') ',utcanev) AS name,
  439. googlelat AS lat,
  440. googlelon AS lng FROM
  441. hiper_ingatlan WHERE
  442. googlelat>='".$_SESSION['lat_min']."' AND
  443. googlelat<='".$_SESSION['lat_max']."' AND
  444. googlelon>='".$_SESSION['lon_min']."' AND
  445. googlelon<='".$_SESSION['lon_max']."' AND
  446. statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  447. }
  448. else {
  449. $tempSQL = "SELECT *,
  450. CONCAT(iranyitoszam,'.',telepules,',<br> (',korzet,') ',utcanev) AS name,
  451. googlelat AS lat,
  452. googlelon AS lng FROM
  453. hiper_ingatlan WHERE
  454. statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  455. }
  456. if ($search['ertekesites']!='') $tempSQL.= " AND ertekesites='".$search['ertekesites']."'";
  457. //if ($search['jelleg']!='') $tempSQL.= " AND jelleg='".$search['jelleg']."'";
  458. if ($_SESSION['wtf']!='') $tempSQL.= " AND jelleg='".$_SESSION['wtf']."'";
  459. if ($search['tipus']!='') $tempSQL.= " AND tipus='".$search['tipus']."'";
  460. if ($_SESSION['statusz_switch']=='uj') $tempSQL.= " AND jogi_statusz='uj'";
  461. if ($_SESSION['statusz_switch']=='legujabb') $tempSQL.= " AND letrehozva >= DATE(NOW()) - INTERVAL 14 DAY";
  462. if ($search['ertekesites']=='elado') {
  463. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000000'";
  464. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000000'";
  465. }
  466. else {
  467. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000'";
  468. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000'";
  469. }
  470. if ($search['meret_netto_min']!='') $tempSQL.= " AND meret_brutto>='".$search['meret_netto_min']."'";
  471. if ($search['meret_netto_max']!='') $tempSQL.= " AND meret_brutto<='".$search['meret_netto_max']."'";
  472. if ($search['altipus']!='') {
  473. $list = explode(",",$search['altipus']);
  474. $altipusok = "";
  475. foreach ($list as $altipus) {
  476. $altipusok.= "'".$altipus."',";
  477. }
  478. $altipusok = rtrim($altipusok,',');
  479. $tempSQL.= " AND altipus IN (".$altipusok.")";
  480. }
  481. if ($search['jogi_statusz']!='') $tempSQL.= " AND jogi_statusz='".$search['jogi_statusz']."'";
  482. //if ($search['szoba_min']!='') $tempSQL.= " AND szoba>='".$search['szoba_min']."'";
  483. //if ($search['szoba_max']!='') $tempSQL.= " AND szoba<='".$search['szoba_max']."'";
  484. if ($search['kilatas']!='') {
  485. $list = explode(",",$search['kilatas']);
  486. $kilatasok = "";
  487. foreach ($list as $kilatas) {
  488. $kilatasok.= "'".$kilatas."',";
  489. }
  490. $kilatasok = rtrim($kilatasok,',');
  491. $tempSQL.= " AND kilatas IN (".$kilatasok.")";
  492. }
  493. if ($search['futes']!='') {
  494. $list = explode(",",$search['futes']);
  495. $futesek = "";
  496. foreach ($list as $futes) {
  497. $futesek.= "'".$futes."',";
  498. }
  499. $futesek = rtrim($futesek,',');
  500. $tempSQL.= " AND futes IN (".$futesek.")";
  501. }
  502. if ($search['tajolas']!='') {
  503. $list = explode(",",$search['tajolas']);
  504. $tajolasok = "";
  505. foreach ($list as $tajolas) {
  506. $tajolasok.= "'".$tajolas."',";
  507. }
  508. $tajolasok = rtrim($tajolasok,',');
  509. $tempSQL.= " AND tajolas IN (".$tajolasok.")";
  510. }
  511. if ($search['allapot']!='') {
  512. $list = explode(",",$search['allapot']);
  513. $allapotok = "";
  514. foreach ($list as $allapot) {
  515. $allapotok.= "'".$allapot."',";
  516. }
  517. $allapotok = rtrim($allapotok,',');
  518. $tempSQL.= " AND ingatlan_allapota IN (".$allapotok.")";
  519. }
  520. if ($search['kornyek']!='') {
  521. $list = explode(",",$search['kornyek']);
  522. $kornyekek = "";
  523. foreach ($list as $kornyek) {
  524. $kornyekek.= "'".$kornyek."',";
  525. }
  526. $kornyekek = rtrim($kornyekek,',');
  527. $tempSQL.= " AND kornyek IN (".$kornyekek.")";
  528. }
  529. if ($search['epites_eve_min']!='') $tempSQL.= " AND epites_eve>='".$search['epites_eve_min']."'";
  530. if ($search['epites_eve_max']!='') $tempSQL.= " AND epites_eve<='".$search['epites_eve_max']."'";
  531. if ($search['telek_min']!='') $tempSQL.= " AND meret_telek>='".$search['telek_min']."'";
  532. if ($search['telek_max']!='') $tempSQL.= " AND meret_telek<='".$search['telek_max']."'";
  533. if ($search['ferohely_garazs_min']!='') $tempSQL.= " AND ferohely_garazs>='".$search['ferohely_garazs_min']."'";
  534. if ($search['ferohely_garazs_max']!='') $tempSQL.= " AND ferohely_garazs<='".$search['ferohely_garazs_max']."'";
  535. if ($search['kulon_nyilo_szobak']=='1') $tempSQL.= " AND kulon_nyilo_szobak='1'";
  536. if ($search['terasz']=='1') $tempSQL.= " AND terasz='1'";
  537. if ($search['erkely']=='1') $tempSQL.= " AND erkely='1'";
  538. if ($search['pince']=='1') $tempSQL.= " AND pince='1'";
  539. if ($search['tarolo']=='1') $tempSQL.= " AND tarolo='1'";
  540. if ($search['garazs']=='1') $tempSQL.= " AND garazs='1'";
  541. if ($search['ferohely_fedettbeallo']=='1') $tempSQL.= " AND ferohely_fedettbeallo='1'";
  542. if ($search['kertkapcsolatos']=='1') $tempSQL.= " AND kertkapcsolatos='1'";
  543. if ($search['viz']=='1') $tempSQL.= " AND viz='1'";
  544. if ($search['gaz']=='1') $tempSQL.= " AND gaz='1'";
  545. if ($search['villany']=='1') $tempSQL.= " AND villany='1'";
  546. if ($search['csatorna']=='1') $tempSQL.= " AND csatorna='1'";
  547. if ($search['lift']=='1') $tempSQL.= " AND lift='1'";
  548. if ($_SESSION['storedPager']=='') $_SESSION['storedPager'] = '0';
  549. $testPager = $_SESSION['storedPager']+5;
  550. $queryPostfix = $tempSQL.$this->getInactiveOffices()." ORDER BY ".$_SESSION['storedOrderField']." ".$_SESSION['storedOrderDirection'];
  551. $result = $this->query($queryPostfix." LIMIT ".$testPager.",5;");
  552. $all = $this->query($queryPostfix.";");
  553. //die($queryPostfix." LIMIT ".$testPager.",5;");
  554. if ($search['szoba_min']!='' || $search['szoba_max']!='') {
  555. foreach ($result as $row) {
  556. $szoba = $row->szoba_fel+$row->szoba_egesz;
  557. if ($szoba>=$search['szoba_min'] && $szoba<=$search['szoba_max']) {
  558. $return[] = $row;
  559. }
  560. }
  561. $result = $return;
  562. }
  563. if ($_SESSION['statusz_switch']=='arcsokkent') {
  564. $return = null;
  565. foreach ($all as $row) {
  566. if ($this->isArcsokkent($row->regszam)) {
  567. $return[] = $row;
  568. }
  569. }
  570. $result = $return;
  571. }
  572. if (sizeof($result)>0) {
  573. return true;
  574. }
  575. else {
  576. return false;
  577. }
  578. }
  579. public function lazy_jumper() {
  580. $_SESSION['storedPager'] = $_SESSION['storedPager']+5;
  581. return true;
  582. }
  583. public function reload_stored_query($search,$nolimit=false) {
  584. $tempSQL = '';
  585. if ($_SESSION['lat_min']!='' && $_SESSION['lat_max']!='' && $_SESSION['lon_min']!='' && $_SESSION['lon_max']!='') {
  586. $tempSQL = "SELECT *,
  587. CONCAT(iranyitoszam,'.',telepules,',<br> (',korzet,') ',utcanev) AS name,
  588. googlelat AS lat,
  589. googlelon AS lng FROM
  590. hiper_ingatlan WHERE
  591. googlelat>='".$_SESSION['lat_min']."' AND
  592. googlelat<='".$_SESSION['lat_max']."' AND
  593. googlelon>='".$_SESSION['lon_min']."' AND
  594. googlelon<='".$_SESSION['lon_max']."' AND
  595. statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  596. }
  597. else {
  598. $tempSQL = "SELECT *,
  599. CONCAT(iranyitoszam,'.',telepules,',<br> (',korzet,') ',utcanev) AS name,
  600. googlelat AS lat,
  601. googlelon AS lng FROM
  602. hiper_ingatlan WHERE
  603. statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  604. }
  605. if ($search['ertekesites']!='') $tempSQL.= " AND ertekesites='".$search['ertekesites']."'";
  606. //if ($search['jelleg']!='') $tempSQL.= " AND jelleg='".$search['jelleg']."'";
  607. if ($_SESSION['wtf']!='') $tempSQL.= " AND jelleg='".$_SESSION['wtf']."'";
  608. if ($search['tipus']!='') $tempSQL.= " AND tipus='".$search['tipus']."'";
  609. if ($_SESSION['statusz_switch']=='uj') $tempSQL.= " AND jogi_statusz='uj'";
  610. if ($_SESSION['statusz_switch']=='legujabb') $tempSQL.= " AND letrehozva >= DATE(NOW()) - INTERVAL 14 DAY";
  611. if ($search['ertekesites']=='elado') {
  612. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000000'";
  613. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000000'";
  614. }
  615. else {
  616. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000'";
  617. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000'";
  618. }
  619. if ($search['meret_netto_min']!='') $tempSQL.= " AND meret_brutto>='".$search['meret_netto_min']."'";
  620. if ($search['meret_netto_max']!='') $tempSQL.= " AND meret_brutto<='".$search['meret_netto_max']."'";
  621. if ($search['altipus']!='') {
  622. $list = explode(",",$search['altipus']);
  623. $altipusok = "";
  624. foreach ($list as $altipus) {
  625. $altipusok.= "'".$altipus."',";
  626. }
  627. $altipusok = rtrim($altipusok,',');
  628. $tempSQL.= " AND altipus IN (".$altipusok.")";
  629. }
  630. if ($search['city']!='') {
  631. $list = explode(",",$search['city']);
  632. $cities = "";
  633. foreach ($list as $city) {
  634. if ($city!='Budapest' && stristr($city," (")==false) {
  635. $cities.= "'".$city."',";
  636. }
  637. }
  638. $cities = rtrim($cities,',');
  639. if ($cities!='') {
  640. $tempSQL.= " AND (telepules IN (".$cities.")";
  641. }
  642. }
  643. if ($search['city']!='') {
  644. $list = explode(",",$search['city']);
  645. $cities = "";
  646. $hasStreet = false;
  647. $utcaSQL = "";
  648. foreach ($list as $city) {
  649. if ($city=='Budapest') {
  650. $tempSQL.= " OR megye='budapest'";
  651. }
  652. elseif (stristr($city," (")) {
  653. if ($hasStreet==false) {
  654. $utcaSQL.= " AND (";
  655. }
  656. $hasStreet = true;
  657. $dtemp = explode(" (",$city);
  658. $varosTemp = str_replace(")","",$dtemp[1]);
  659. $utcaTemp = $dtemp[0];
  660. $utcaSQL.= "(utcanev='".$utcaTemp."' AND telepules='".$varosTemp."') OR ";
  661. }
  662. }
  663. $tempSQL.= ")";
  664. $utcaSQL = rtrim($utcaSQL," OR ");
  665. if ($utcaSQL!='') {
  666. $utcaSQL.= ")";
  667. }
  668. $tempSQL.= $utcaSQL;
  669. }
  670. if ($search['jogi_statusz']!='') $tempSQL.= " AND jogi_statusz='".$search['jogi_statusz']."'";
  671. //if ($search['szoba_min']!='') $tempSQL.= " AND szoba_egesz>='".$search['szoba_min']."'";
  672. //if ($search['szoba_max']!='') $tempSQL.= " AND szoba_egesz<='".$search['szoba_max']."'";
  673. if ($search['kilatas']!='') {
  674. $list = explode(",",$search['kilatas']);
  675. $kilatasok = "";
  676. foreach ($list as $kilatas) {
  677. $kilatasok.= "'".$kilatas."',";
  678. }
  679. $kilatasok = rtrim($kilatasok,',');
  680. $tempSQL.= " AND kilatas IN (".$kilatasok.")";
  681. }
  682. if ($search['futes']!='') {
  683. $list = explode(",",$search['futes']);
  684. $futesek = "";
  685. foreach ($list as $futes) {
  686. $futesek.= "'".$futes."',";
  687. }
  688. $futesek = rtrim($futesek,',');
  689. $tempSQL.= " AND futes IN (".$futesek.")";
  690. }
  691. if ($search['tajolas']!='') {
  692. $list = explode(",",$search['tajolas']);
  693. $tajolasok = "";
  694. foreach ($list as $tajolas) {
  695. $tajolasok.= "'".$tajolas."',";
  696. }
  697. $tajolasok = rtrim($tajolasok,',');
  698. $tempSQL.= " AND tajolas IN (".$tajolasok.")";
  699. }
  700. if ($search['allapot']!='') {
  701. $list = explode(",",$search['allapot']);
  702. $allapotok = "";
  703. foreach ($list as $allapot) {
  704. $allapotok.= "'".$allapot."',";
  705. }
  706. $allapotok = rtrim($allapotok,',');
  707. $tempSQL.= " AND ingatlan_allapota IN (".$allapotok.")";
  708. }
  709. if ($search['kornyek']!='') {
  710. $list = explode(",",$search['kornyek']);
  711. $kornyekek = "";
  712. foreach ($list as $kornyek) {
  713. $kornyekek.= "'".$kornyek."',";
  714. }
  715. $kornyekek = rtrim($kornyekek,',');
  716. $tempSQL.= " AND kornyek IN (".$kornyekek.")";
  717. }
  718. if ($search['epites_eve_min']!='') $tempSQL.= " AND epites_eve>='".$search['epites_eve_min']."'";
  719. if ($search['epites_eve_max']!='') $tempSQL.= " AND epites_eve<='".$search['epites_eve_max']."'";
  720. if ($search['telek_min']!='') $tempSQL.= " AND meret_telek>='".$search['telek_min']."'";
  721. if ($search['telek_max']!='') $tempSQL.= " AND meret_telek<='".$search['telek_max']."'";
  722. if ($search['ferohely_garazs_min']!='') $tempSQL.= " AND ferohely_garazs>='".$search['ferohely_garazs_min']."'";
  723. if ($search['ferohely_garazs_max']!='') $tempSQL.= " AND ferohely_garazs<='".$search['ferohely_garazs_max']."'";
  724. if ($search['kulon_nyilo_szobak']=='1') $tempSQL.= " AND kulon_nyilo_szobak='1'";
  725. if ($search['terasz']=='1') $tempSQL.= " AND terasz='1'";
  726. if ($search['erkely']=='1') $tempSQL.= " AND erkely='1'";
  727. if ($search['pince']=='1') $tempSQL.= " AND pince='1'";
  728. if ($search['tarolo']=='1') $tempSQL.= " AND tarolo='1'";
  729. if ($search['garazs']=='1') $tempSQL.= " AND garazs='1'";
  730. if ($search['ferohely_fedettbeallo']=='1') $tempSQL.= " AND ferohely_fedettbeallo='1'";
  731. if ($search['kertkapcsolatos']=='1') $tempSQL.= " AND kertkapcsolatos='1'";
  732. if ($search['viz']=='1') $tempSQL.= " AND viz='1'";
  733. if ($search['gaz']=='1') $tempSQL.= " AND gaz='1'";
  734. if ($search['villany']=='1') $tempSQL.= " AND villany='1'";
  735. if ($search['csatorna']=='1') $tempSQL.= " AND csatorna='1'";
  736. if ($search['lift']=='1') $tempSQL.= " AND lift='1'";
  737. if ($_SESSION['storedOrderField']=='') $_SESSION['storedOrderField'] = 'letrehozva';
  738. if ($_SESSION['storedOrderDirection']=='') $_SESSION['storedOrderDirection'] = 'DESC';
  739. $queryPostfix = $this->getInactiveOffices()." ORDER BY ".$_SESSION['storedOrderField']." ".$_SESSION['storedOrderDirection'];
  740. //die($tempSQL." ".$queryPostfix);
  741. $tempSQL = str_replace("' OR megye='budapest')","' AND megye='budapest'",$tempSQL);
  742. if ($nolimit) {
  743. $result = $this->query($tempSQL." ".$queryPostfix);
  744. }
  745. else {
  746. $result = $this->query($tempSQL." ".$queryPostfix.$this->lazy_loader());
  747. }
  748. $all = $this->query($tempSQL." ".$queryPostfix);
  749. if ($search['szoba_min']!='' || $search['szoba_max']!='') {
  750. foreach ($result as $row) {
  751. $szoba = $row->szoba_fel+$row->szoba_egesz;
  752. if ($szoba>=$search['szoba_min'] && $szoba<=$search['szoba_max']) {
  753. $return[] = $row;
  754. }
  755. }
  756. $result = $return;
  757. }
  758. if ($_SESSION['statusz_switch']=='arcsokkent') {
  759. $return = null;
  760. foreach ($all as $row) {
  761. if ($this->isArcsokkent($row->regszam)) {
  762. $return[] = $row;
  763. }
  764. }
  765. $result = $return;
  766. }
  767. return $result;
  768. }
  769. public function get_map_all_results($search) {
  770. $tempSQL = '';
  771. if ($_SESSION['lat_min']!='' && $_SESSION['lat_max']!='' && $_SESSION['lon_min']!='' && $_SESSION['lon_max']!='') {
  772. $tempSQL = "SELECT *,
  773. CONCAT(iranyitoszam,'.',telepules,',<br> (',korzet,') ',utcanev) AS name,
  774. googlelat AS lat,
  775. googlelon AS lng FROM
  776. hiper_ingatlan WHERE
  777. googlelat>='".$_SESSION['lat_min']."' AND
  778. googlelat<='".$_SESSION['lat_max']."' AND
  779. googlelon>='".$_SESSION['lon_min']."' AND
  780. googlelon<='".$_SESSION['lon_max']."' AND
  781. statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  782. }
  783. else {
  784. $tempSQL = "SELECT *,
  785. CONCAT(iranyitoszam,'.',telepules,',<br> (',korzet,') ',utcanev) AS name,
  786. googlelat AS lat,
  787. googlelon AS lng FROM
  788. hiper_ingatlan WHERE
  789. statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  790. }
  791. if ($search['ertekesites']!='') $tempSQL.= " AND ertekesites='".$search['ertekesites']."'";
  792. //if ($search['jelleg']!='') $tempSQL.= " AND jelleg='".$search['jelleg']."'";
  793. if ($_SESSION['wtf']!='') $tempSQL.= " AND jelleg='".$_SESSION['wtf']."'";
  794. if ($search['tipus']!='') $tempSQL.= " AND tipus='".$search['tipus']."'";
  795. if ($_SESSION['statusz_switch']=='uj') $tempSQL.= " AND jogi_statusz='uj'";
  796. if ($_SESSION['statusz_switch']=='legujabb') $tempSQL.= " AND letrehozva >= DATE(NOW()) - INTERVAL 14 DAY";
  797. if ($search['ertekesites']=='elado') {
  798. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000000'";
  799. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000000'";
  800. }
  801. else {
  802. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000'";
  803. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000'";
  804. }
  805. if ($search['meret_netto_min']!='') $tempSQL.= " AND meret_brutto>='".$search['meret_netto_min']."'";
  806. if ($search['meret_netto_max']!='') $tempSQL.= " AND meret_brutto<='".$search['meret_netto_max']."'";
  807. if ($search['altipus']!='') {
  808. $list = explode(",",$search['altipus']);
  809. $altipusok = "";
  810. foreach ($list as $altipus) {
  811. $altipusok.= "'".$altipus."',";
  812. }
  813. $altipusok = rtrim($altipusok,',');
  814. $tempSQL.= " AND altipus IN (".$altipusok.")";
  815. }
  816. if ($search['jogi_statusz']!='') $tempSQL.= " AND jogi_statusz='".$search['jogi_statusz']."'";
  817. //if ($search['szoba_min']!='') $tempSQL.= " AND szoba>='".$search['szoba_min']."'";
  818. //if ($search['szoba_max']!='') $tempSQL.= " AND szoba<='".$search['szoba_max']."'";
  819. if ($search['kilatas']!='') {
  820. $list = explode(",",$search['kilatas']);
  821. $kilatasok = "";
  822. foreach ($list as $kilatas) {
  823. $kilatasok.= "'".$kilatas."',";
  824. }
  825. $kilatasok = rtrim($kilatasok,',');
  826. $tempSQL.= " AND kilatas IN (".$kilatasok.")";
  827. }
  828. if ($search['futes']!='') {
  829. $list = explode(",",$search['futes']);
  830. $futesek = "";
  831. foreach ($list as $futes) {
  832. $futesek.= "'".$futes."',";
  833. }
  834. $futesek = rtrim($futesek,',');
  835. $tempSQL.= " AND futes IN (".$futesek.")";
  836. }
  837. if ($search['tajolas']!='') {
  838. $list = explode(",",$search['tajolas']);
  839. $tajolasok = "";
  840. foreach ($list as $tajolas) {
  841. $tajolasok.= "'".$tajolas."',";
  842. }
  843. $tajolasok = rtrim($tajolasok,',');
  844. $tempSQL.= " AND tajolas IN (".$tajolasok.")";
  845. }
  846. if ($search['allapot']!='') {
  847. $list = explode(",",$search['allapot']);
  848. $allapotok = "";
  849. foreach ($list as $allapot) {
  850. $allapotok.= "'".$allapot."',";
  851. }
  852. $allapotok = rtrim($allapotok,',');
  853. $tempSQL.= " AND ingatlan_allapota IN (".$allapotok.")";
  854. }
  855. if ($search['kornyek']!='') {
  856. $list = explode(",",$search['kornyek']);
  857. $kornyekek = "";
  858. foreach ($list as $kornyek) {
  859. $kornyekek.= "'".$kornyek."',";
  860. }
  861. $kornyekek = rtrim($kornyekek,',');
  862. $tempSQL.= " AND kornyek IN (".$kornyekek.")";
  863. }
  864. if ($search['epites_eve_min']!='') $tempSQL.= " AND epites_eve>='".$search['epites_eve_min']."'";
  865. if ($search['epites_eve_max']!='') $tempSQL.= " AND epites_eve<='".$search['epites_eve_max']."'";
  866. if ($search['telek_min']!='') $tempSQL.= " AND meret_telek>='".$search['telek_min']."'";
  867. if ($search['telek_max']!='') $tempSQL.= " AND meret_telek<='".$search['telek_max']."'";
  868. if ($search['ferohely_garazs_min']!='') $tempSQL.= " AND ferohely_garazs>='".$search['ferohely_garazs_min']."'";
  869. if ($search['ferohely_garazs_max']!='') $tempSQL.= " AND ferohely_garazs<='".$search['ferohely_garazs_max']."'";
  870. if ($search['kulon_nyilo_szobak']=='1') $tempSQL.= " AND kulon_nyilo_szobak='1'";
  871. if ($search['terasz']=='1') $tempSQL.= " AND terasz='1'";
  872. if ($search['erkely']=='1') $tempSQL.= " AND erkely='1'";
  873. if ($search['pince']=='1') $tempSQL.= " AND pince='1'";
  874. if ($search['tarolo']=='1') $tempSQL.= " AND tarolo='1'";
  875. if ($search['garazs']=='1') $tempSQL.= " AND garazs='1'";
  876. if ($search['ferohely_fedettbeallo']=='1') $tempSQL.= " AND ferohely_fedettbeallo='1'";
  877. if ($search['kertkapcsolatos']=='1') $tempSQL.= " AND kertkapcsolatos='1'";
  878. if ($search['viz']=='1') $tempSQL.= " AND viz='1'";
  879. if ($search['gaz']=='1') $tempSQL.= " AND gaz='1'";
  880. if ($search['villany']=='1') $tempSQL.= " AND villany='1'";
  881. if ($search['csatorna']=='1') $tempSQL.= " AND csatorna='1'";
  882. if ($search['lift']=='1') $tempSQL.= " AND lift='1'";
  883. $_SESSION['storedPager'] = 0;
  884. if ($_SESSION['storedOrderField']=='') $_SESSION['storedOrderField'] = 'letrehozva';
  885. if ($_SESSION['storedOrderDirection']=='') $_SESSION['storedOrderDirection'] = 'DESC';
  886. //die($tempSQL);
  887. $queryPostfix = $tempSQL.$this->getInactiveOffices()." ORDER BY ".$_SESSION['storedOrderField']." ".$_SESSION['storedOrderDirection'];
  888. $result = $this->query($queryPostfix." ".$this->lazy_loader());
  889. $all = $this->query($queryPostfix.";");
  890. //die('debug: '.count($all));
  891. if ($search['szoba_min']!='' || $search['szoba_max']!='') {
  892. foreach ($result as $row) {
  893. $szoba = $row->szoba_fel+$row->szoba_egesz;
  894. if ($szoba>=$search['szoba_min'] && $szoba<=$search['szoba_max']) {
  895. $return[] = $row;
  896. }
  897. }
  898. $result = $return;
  899. }
  900. if ($_SESSION['statusz_switch']=='arcsokkent') {
  901. $return = null;
  902. foreach ($all as $row) {
  903. if ($this->isArcsokkent($row->regszam)) {
  904. $return[] = $row;
  905. }
  906. }
  907. $result = $return;
  908. }
  909. return $result;
  910. }
  911. public function get_map_all_results_count($search) {
  912. $tempSQL = '';
  913. if ($_SESSION['lat_min']!='' && $_SESSION['lat_max']!='' && $_SESSION['lon_min']!='' && $_SESSION['lon_max']!='') {
  914. $tempSQL = "SELECT *,
  915. CONCAT(iranyitoszam,'.',telepules,',<br> (',korzet,') ',utcanev) AS name,
  916. googlelat AS lat,
  917. googlelon AS lng FROM
  918. hiper_ingatlan WHERE
  919. googlelat>='".$_SESSION['lat_min']."' AND
  920. googlelat<='".$_SESSION['lat_max']."' AND
  921. googlelon>='".$_SESSION['lon_min']."' AND
  922. googlelon<='".$_SESSION['lon_max']."' AND
  923. statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  924. }
  925. else {
  926. $tempSQL = "SELECT *,
  927. CONCAT(iranyitoszam,'.',telepules,',<br> (',korzet,') ',utcanev) AS name,
  928. googlelat AS lat,
  929. googlelon AS lng FROM
  930. hiper_ingatlan WHERE
  931. statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  932. }
  933. if ($search['ertekesites']!='') $tempSQL.= " AND ertekesites='".$search['ertekesites']."'";
  934. //if ($search['jelleg']!='') $tempSQL.= " AND jelleg='".$search['jelleg']."'";
  935. if ($_SESSION['wtf']!='') $tempSQL.= " AND jelleg='".$_SESSION['wtf']."'";
  936. if ($search['tipus']!='') $tempSQL.= " AND tipus='".$search['tipus']."'";
  937. if ($_SESSION['statusz_switch']=='uj') $tempSQL.= " AND jogi_statusz='uj'";
  938. if ($_SESSION['statusz_switch']=='legujabb') $tempSQL.= " AND letrehozva >= DATE(NOW()) - INTERVAL 14 DAY";
  939. if ($search['ertekesites']=='elado') {
  940. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000000'";
  941. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000000'";
  942. }
  943. else {
  944. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000'";
  945. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000'";
  946. }
  947. if ($search['meret_netto_min']!='') $tempSQL.= " AND meret_brutto>='".$search['meret_netto_min']."'";
  948. if ($search['meret_netto_max']!='') $tempSQL.= " AND meret_brutto<='".$search['meret_netto_max']."'";
  949. if ($search['altipus']!='') {
  950. $list = explode(",",$search['altipus']);
  951. $altipusok = "";
  952. foreach ($list as $altipus) {
  953. $altipusok.= "'".$altipus."',";
  954. }
  955. $altipusok = rtrim($altipusok,',');
  956. $tempSQL.= " AND altipus IN (".$altipusok.")";
  957. }
  958. if ($search['jogi_statusz']!='') $tempSQL.= " AND jogi_statusz='".$search['jogi_statusz']."'";
  959. //if ($search['szoba_min']!='') $tempSQL.= " AND szoba>='".$search['szoba_min']."'";
  960. //if ($search['szoba_max']!='') $tempSQL.= " AND szoba<='".$search['szoba_max']."'";
  961. if ($search['kilatas']!='') {
  962. $list = explode(",",$search['kilatas']);
  963. $kilatasok = "";
  964. foreach ($list as $kilatas) {
  965. $kilatasok.= "'".$kilatas."',";
  966. }
  967. $kilatasok = rtrim($kilatasok,',');
  968. $tempSQL.= " AND kilatas IN (".$kilatasok.")";
  969. }
  970. if ($search['futes']!='') {
  971. $list = explode(",",$search['futes']);
  972. $futesek = "";
  973. foreach ($list as $futes) {
  974. $futesek.= "'".$futes."',";
  975. }
  976. $futesek = rtrim($futesek,',');
  977. $tempSQL.= " AND futes IN (".$futesek.")";
  978. }
  979. if ($search['tajolas']!='') {
  980. $list = explode(",",$search['tajolas']);
  981. $tajolasok = "";
  982. foreach ($list as $tajolas) {
  983. $tajolasok.= "'".$tajolas."',";
  984. }
  985. $tajolasok = rtrim($tajolasok,',');
  986. $tempSQL.= " AND tajolas IN (".$tajolasok.")";
  987. }
  988. if ($search['allapot']!='') {
  989. $list = explode(",",$search['allapot']);
  990. $allapotok = "";
  991. foreach ($list as $allapot) {
  992. $allapotok.= "'".$allapot."',";
  993. }
  994. $allapotok = rtrim($allapotok,',');
  995. $tempSQL.= " AND ingatlan_allapota IN (".$allapotok.")";
  996. }
  997. if ($search['kornyek']!='') {
  998. $list = explode(",",$search['kornyek']);
  999. $kornyekek = "";
  1000. foreach ($list as $kornyek) {
  1001. $kornyekek.= "'".$kornyek."',";
  1002. }
  1003. $kornyekek = rtrim($kornyekek,',');
  1004. $tempSQL.= " AND kornyek IN (".$kornyekek.")";
  1005. }
  1006. if ($search['epites_eve_min']!='') $tempSQL.= " AND epites_eve>='".$search['epites_eve_min']."'";
  1007. if ($search['epites_eve_max']!='') $tempSQL.= " AND epites_eve<='".$search['epites_eve_max']."'";
  1008. if ($search['telek_min']!='') $tempSQL.= " AND meret_telek>='".$search['telek_min']."'";
  1009. if ($search['telek_max']!='') $tempSQL.= " AND meret_telek<='".$search['telek_max']."'";
  1010. if ($search['ferohely_garazs_min']!='') $tempSQL.= " AND ferohely_garazs>='".$search['ferohely_garazs_min']."'";
  1011. if ($search['ferohely_garazs_max']!='') $tempSQL.= " AND ferohely_garazs<='".$search['ferohely_garazs_max']."'";
  1012. if ($search['kulon_nyilo_szobak']=='1') $tempSQL.= " AND kulon_nyilo_szobak='1'";
  1013. if ($search['terasz']=='1') $tempSQL.= " AND terasz='1'";
  1014. if ($search['erkely']=='1') $tempSQL.= " AND erkely='1'";
  1015. if ($search['pince']=='1') $tempSQL.= " AND pince='1'";
  1016. if ($search['tarolo']=='1') $tempSQL.= " AND tarolo='1'";
  1017. if ($search['garazs']=='1') $tempSQL.= " AND garazs='1'";
  1018. if ($search['ferohely_fedettbeallo']=='1') $tempSQL.= " AND ferohely_fedettbeallo='1'";
  1019. if ($search['kertkapcsolatos']=='1') $tempSQL.= " AND kertkapcsolatos='1'";
  1020. if ($search['viz']=='1') $tempSQL.= " AND viz='1'";
  1021. if ($search['gaz']=='1') $tempSQL.= " AND gaz='1'";
  1022. if ($search['villany']=='1') $tempSQL.= " AND villany='1'";
  1023. if ($search['csatorna']=='1') $tempSQL.= " AND csatorna='1'";
  1024. if ($search['lift']=='1') $tempSQL.= " AND lift='1'";
  1025. if ($_SESSION['storedOrderField']=='') $_SESSION['storedOrderField'] = 'letrehozva';
  1026. if ($_SESSION['storedOrderDirection']=='') $_SESSION['storedOrderDirection'] = 'DESC';
  1027. $queryPostfix = $this->getInactiveOffices()." ORDER BY ".$_SESSION['storedOrderField']." ".$_SESSION['storedOrderDirection'];
  1028. $result = $this->query($tempSQL." ".$queryPostfix);
  1029. if ($search['szoba_min']!='' || $search['szoba_max']!='') {
  1030. foreach ($result as $row) {
  1031. $szoba = $row->szoba_fel+$row->szoba_egesz;
  1032. if ($szoba>=$search['szoba_min'] && $szoba<=$search['szoba_max']) {
  1033. $return[] = $row;
  1034. }
  1035. }
  1036. $result = $return;
  1037. }
  1038. if ($_SESSION['statusz_switch']=='arcsokkent') {
  1039. $return = null;
  1040. foreach ($result as $row) {
  1041. if ($this->isArcsokkent($row->regszam)) {
  1042. $return[] = $row;
  1043. }
  1044. }
  1045. $result = $return;
  1046. }
  1047. return $result;
  1048. }
  1049. public function get_ertekesites_tipusok() {
  1050. $result = $this->query("SELECT ertekesites FROM hiper_ingatlan WHERE ertekesites<>'' AND statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0') GROUP BY ertekesites ORDER BY ertekesites ASC;");
  1051. return $result;
  1052. }
  1053. public function get_jelleg_tipusok() {
  1054. $resultx = $this->query("SELECT tipus FROM hiper_ingatlan WHERE tipus<>'' AND statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0') GROUP BY tipus ORDER BY tipus ASC;");
  1055. $resulty = $this->query("SELECT jelleg FROM hiper_ingatlan WHERE jelleg<>'lakoingatlan' AND statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0') GROUP BY jelleg ORDER BY jelleg ASC;");
  1056. foreach ($resultx as $row) {
  1057. if ($row->tipus=='tarsashazi') {
  1058. $row->jelleg = 'Lakóingatlan - '.$row->tipus;
  1059. $result[] = $row;
  1060. }
  1061. }
  1062. foreach ($resultx as $row) {
  1063. if ($row->tipus!='tarsashazi') {
  1064. $row->jelleg = 'Lakóingatlan - '.$row->tipus;
  1065. $result[] = $row;
  1066. }
  1067. }
  1068. foreach ($resulty as $row) {
  1069. $result[] = $row;
  1070. }
  1071. return $result;
  1072. }
  1073. public function get_telepulesek() {
  1074. $result = $this->query("SELECT telepules FROM hiper_ingatlan WHERE telepules<>'' AND statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0') GROUP BY telepules ORDER BY telepules ASC;");
  1075. return $result;
  1076. }
  1077. public function isArcsokkent($code) {
  1078. if ($code!='') {
  1079. $check = $this->query("SELECT * FROM hiper_ingatlan_ertekesites WHERE regszam='".$code."' AND arcsokkenes='1';");
  1080. if ($check[0]->arcsokkenes=='1') {
  1081. return true;
  1082. }
  1083. else {
  1084. return false;
  1085. }
  1086. }
  1087. else {
  1088. return false;
  1089. }
  1090. }
  1091. public function getSearchString() {
  1092. if ($_SESSION['search']['ertekesites']=='elado') {
  1093. $string = 'Eladó';
  1094. }
  1095. else {
  1096. $string = 'Kiadó';
  1097. }
  1098. if ($_SESSION['search']['tipus']=='tarsashazi') {
  1099. $string.= ' lakás';
  1100. }
  1101. elseif ($_SESSION['search']['tipus']=='csaladihaz') {
  1102. $string.= ' családi ház';
  1103. }
  1104. elseif ($_SESSION['search']['tipus']=='epuletresz') {
  1105. $string.= ' épületrész';
  1106. }
  1107. elseif ($_SESSION['search']['tipus']=='hazresz') {
  1108. $string.= ' házrész';
  1109. }
  1110. elseif ($_SESSION['search']['tipus']=='ikerhaz') {
  1111. $string.= ' ikerház';
  1112. }
  1113. elseif ($_SESSION['search']['tipus']=='onalloepulet') {
  1114. $string.= ' önálló épület';
  1115. }
  1116. elseif ($_SESSION['search']['tipus']=='teljesepulet') {
  1117. $string.= ' teljes épület';
  1118. }
  1119. elseif ($_SESSION['search']['tipus']=='beruhazasi') {
  1120. $string.= ' beruházás';
  1121. }
  1122. elseif ($_SESSION['search']['tipus']=='garazs') {
  1123. $string.= ' garázs';
  1124. }
  1125. elseif ($_SESSION['search']['tipus']=='kereskedelmi') {
  1126. $string.= ' kereskedelmi';
  1127. }
  1128. elseif ($_SESSION['search']['tipus']=='mezogazdasagi') {
  1129. $string.= ' mezőgazdasági';
  1130. }
  1131. elseif ($_SESSION['search']['tipus']=='tarolo') {
  1132. $string.= ' tároló';
  1133. }
  1134. elseif ($_SESSION['search']['tipus']=='telek') {
  1135. $string.= ' telek';
  1136. }
  1137. $string.= ', ';
  1138. $actives = explode(",",$_SESSION['search']['city']);
  1139. foreach ($actives as $item) {
  1140. if (stristr($item,"Budapest")) {
  1141. $string.= $item.'. kerület, ';
  1142. }
  1143. else {
  1144. $string.= $item.', ';
  1145. }
  1146. }
  1147. $string = trim($string,", ");
  1148. return $string;
  1149. }
  1150. }