property_model.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. <?php
  2. class property_model extends Model {
  3. public function get_property($id) {
  4. $id = $this->escapeString($id);
  5. //die("SELECT *, alap.regszam AS uniqazonosito FROM hiper_ingatlan as alap LEFT JOIN hiper_ingatlan_other ON hiper_ingatlan_other.id_ingatlan=alap.id WHERE alap.id='".$id."' AND rockhomera_mehet='1';");
  6. $result = $this->query("SELECT *, alap.regszam AS uniqazonosito FROM hiper_ingatlan as alap LEFT JOIN hiper_ingatlan_other ON hiper_ingatlan_other.id_ingatlan=alap.id WHERE alap.id='".$id."';");
  7. if (sizeof($result)>0) {
  8. return $result[0];
  9. }
  10. else {
  11. return false;
  12. }
  13. }
  14. public function get_propertybyreg($regnum) {
  15. $regnum = $this->escapeString($regnum);
  16. $result = $this->query("SELECT * FROM hiper_ingatlan as alap LEFT JOIN hiper_ingatlan_other ON hiper_ingatlan_other.id_ingatlan=alap.id WHERE alap.regszam='".$regnum."' AND rockhomera_mehet='1';");
  17. if (sizeof($result)>0) {
  18. return $result[0];
  19. }
  20. else {
  21. return false;
  22. }
  23. }
  24. public function getPropertyID($code) {
  25. $result = $this->query("SELECT * FROM hiper_ingatlan WHERE regszam='".$code."' AND rockhomera_mehet='1';");
  26. if (sizeof($result)>0) {
  27. return $result[0]->id;
  28. }
  29. else {
  30. return false;
  31. }
  32. }
  33. public function get_property_description($id) {
  34. $id = $this->escapeString($id);
  35. $result = $this->query("SELECT * FROM hiper_ingatlan_text WHERE regszam='".$id."';");
  36. if (sizeof($result)>0) {
  37. return $result[0]->leiras;
  38. }
  39. else {
  40. return false;
  41. }
  42. }
  43. public function get_property_szlogen($id) {
  44. $id = $this->escapeString($id);
  45. $result = $this->query("SELECT * FROM hiper_ingatlan_text WHERE regszam='".$id."';");
  46. if (sizeof($result)>0) {
  47. return $result[0]->szlogen;
  48. }
  49. else {
  50. return false;
  51. }
  52. }
  53. public function get_property_sales($user) {
  54. $user = $this->escapeString($user);
  55. $result = $this->query("SELECT * FROM hiper_munkatars WHERE felhasznalonev='".$user."';");
  56. if (sizeof($result)>0) {
  57. return $result[0];
  58. }
  59. else {
  60. return false;
  61. }
  62. }
  63. public function get_property_images($id) {
  64. $id = $this->escapeString($id);
  65. $result = $this->query("SELECT *,getimgurl(fajlnev,'ingatlan') AS fajlnev FROM hiper_ingatlan_kep WHERE regszam='".$id."' AND webremehet='1' ORDER BY sorrend ASC;");
  66. if (sizeof($result)>0) {
  67. return $result;
  68. }
  69. else {
  70. return false;
  71. }
  72. }
  73. public function get_property_alaprajz($id) {
  74. $id = $this->escapeString($id);
  75. $result = $this->query("SELECT *,getimgurl(fajlnev,'ingatlan') AS fajlnev FROM hiper_ingatlan_kep WHERE tipus='0' AND regszam='".$id."' AND webremehet='1' ORDER BY sorrend ASC;");
  76. if (sizeof($result)>0) {
  77. return $result;
  78. }
  79. else {
  80. return false;
  81. }
  82. }
  83. public function getAgentName($id) {
  84. $id = $this->escapeString($id);
  85. if ($id!='') {
  86. $agent = $this->query("SELECT * FROM hiper_munkatars WHERE felhasznalonev='".$id."';");
  87. if (sizeof($agent)>0) {
  88. return $agent[0]->nev;
  89. }
  90. else {
  91. return false;
  92. }
  93. }
  94. else {
  95. return false;
  96. }
  97. }
  98. public function get_office($id) {
  99. $id = $this->escapeString($id);
  100. if ($id!='') {
  101. $office = $this->query("SELECT * FROM hiper_iroda WHERE azonosito='".$id."';");
  102. if (sizeof($office)>0) {
  103. return $office[0];
  104. }
  105. else {
  106. return false;
  107. }
  108. }
  109. else {
  110. return false;
  111. }
  112. }
  113. public function getInactiveOffices() {
  114. $check = $this->query("SELECT * FROM irodak where active='0';");
  115. foreach ($check as $row) {
  116. $temp[] = $row->office_id;
  117. }
  118. if (count($temp)>0) {
  119. return ' AND iroda NOT IN (\''.implode('\',\'',$temp).'\')';
  120. }
  121. else {
  122. return '';
  123. }
  124. }
  125. public function checkOffice($id) {
  126. $check = $this->query("SELECT * FROM irodak where office_id='".$id."';");
  127. if ($check[0]->active=='1') {
  128. return true;
  129. }
  130. else if ($check[0]->active=='0') {
  131. return false;
  132. }
  133. else {
  134. return true;
  135. }
  136. }
  137. public function get_property_list($search) {
  138. if ($search['jelleg']=='' && $search['jellegorig']!='') $search['jelleg'] = $search['jellegorig'];
  139. if ($search['jelleg'] == 'Beruházást igénylő') $search['jelleg'] = 'beruhazasi';
  140. $search = $this->escapeArray($search);
  141. $tempSQL = "SELECT *,getimgurl(indexkep,'ingatlan') AS indexkep FROM hiper_ingatlan WHERE statusz='aktualis' AND rockhomera_mehet='1'".$this->getInactiveOffices();
  142. if ($_SESSION['storedOrderField']=='') $_SESSION['storedOrderField'] = 'letrehozva';
  143. if ($_SESSION['storedOrderDirection']=='') $_SESSION['storedOrderDirection'] = 'DESC';
  144. if ($search['agent']!='') {
  145. $tempSQL.= " AND tanacsado='".$search['agent']."'";
  146. $title = $this->getAgentName($search['agent']).' tanácsadó ingatlanjai';
  147. }
  148. elseif ($search['office']!='') {
  149. $tempSQL.= " AND iroda='".$search['office']."'";
  150. }
  151. elseif ($search['from']!='') {
  152. if ($search['ertekesites']!='') $tempSQL.= " AND ertekesites='".$search['ertekesites']."'";
  153. if ($search['jelleg']!='nyaralo') {
  154. if ($search['jelleg']!='') $tempSQL.= " AND jelleg='".$search['jelleg']."'";
  155. if ($search['tipus']!='') $tempSQL.= " AND tipus='".$search['tipus']."'";
  156. }
  157. else {
  158. $tempSQL.= " AND nyaralo='1'";
  159. }
  160. if ($search['city']!='') {
  161. $list = explode(",",$search['city']);
  162. $cities = "";
  163. $megyek = "";
  164. foreach ($list as $city) {
  165. if ($city!='Budapest' && stristr($city," (")==false && $city!='Bács-Kiskun' && $city!='Nográd' && $city!='Borsod-Abaúj-Zemplén' && $city!='Pest' && $city!='Győr-Moson-Sopron' && $city!='Baranya' && $city!='Békés' && $city!='Somogy' && $city!='Jász-Nagykun-Szolnok' && $city!='Csongrád' && $city!='Tolna' && $city!='Komárom-Esztergom' && $city!='Fejér' && $city!='Vas' && $city!='Szabolcs-Szatmár-Bereg' && $city!='Hajdú-Bihar' && $city!='Veszprém' && $city!='Heves' && $city!='Zala') {
  166. $cities.= "'".$city."',";
  167. }
  168. elseif ($city=='Bács-Kiskun' || $city=='Nográd' || $city=='Borsod-Abaúj-Zemplén' || $city=='Pest' || $city=='Győr-Moson-Sopron' || $city=='Baranya' || $city=='Békés' || $city=='Somogy' || $city=='Jász-Nagykun-Szolnok' || $city=='Csongrád' || $city=='Tolna' || $city=='Komárom-Esztergom' || $city=='Fejér' || $city=='Vas' || $city=='Szabolcs-Szatmár-Bereg' || $city=='Hajdú-Bihar' || $city=='Veszprém' || $city=='Heves' || $city=='Zala') {
  169. $city = strtolower($city);
  170. $megyek.= "'".$city."',";
  171. }
  172. }
  173. $megyek = rtrim($megyek,',');
  174. if ($megyek!='') {
  175. $tempSQL.= " AND (megye IN (".$megyek.")";
  176. }
  177. $cities = rtrim($cities,',');
  178. if ($cities!='') {
  179. $tempSQL.= " AND (telepules IN (".$cities.")";
  180. }
  181. }
  182. if ($search['city']!='') {
  183. $list = explode(",",$search['city']);
  184. $cities = "";
  185. $hasStreet = false;
  186. $utcaSQL = "";
  187. foreach ($list as $city) {
  188. if ($city=='Budapest') {
  189. $tempSQL.= " OR megye='budapest'";
  190. }
  191. elseif (stristr($city," (")) {
  192. if ($hasStreet==false) {
  193. $utcaSQL.= " AND (";
  194. }
  195. $hasStreet = true;
  196. $dtemp = explode(" (",$city);
  197. $varosTemp = str_replace(")","",$dtemp[1]);
  198. $utcaTemp = $dtemp[0];
  199. $utcaSQL.= "(utcanev='".$utcaTemp."' AND telepules='".$varosTemp."') OR ";
  200. }
  201. }
  202. if ($hasStreet==false) {
  203. $tempSQL.= ")";
  204. }
  205. $utcaSQL = rtrim($utcaSQL," OR ");
  206. if ($utcaSQL!='') {
  207. $utcaSQL.= ")";
  208. }
  209. $tempSQL.= $utcaSQL;
  210. //die($tempSQL);
  211. }
  212. if ($_SESSION['statusz_switch']=='uj') $tempSQL.= " AND jogi_statusz='uj'";
  213. if ($_SESSION['statusz_switch']=='legujabb') $tempSQL.= " AND letrehozva >= DATE(NOW()) - INTERVAL 14 DAY";
  214. if ($search['ertekesites']=='elado') {
  215. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000000'";
  216. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000000'";
  217. }
  218. else {
  219. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000'";
  220. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000'";
  221. }
  222. if ($search['meret_netto_min']!='') $tempSQL.= " AND meret_brutto>='".$search['meret_netto_min']."'";
  223. if ($search['meret_netto_max']!='') $tempSQL.= " AND meret_brutto<='".$search['meret_netto_max']."'";
  224. if ($search['altipus']!='') {
  225. $list = explode(",",$search['altipus']);
  226. $altipusok = "";
  227. foreach ($list as $altipus) {
  228. $altipusok.= "'".$altipus."',";
  229. }
  230. $altipusok = rtrim($altipusok,',');
  231. $tempSQL.= " AND altipus IN (".$altipusok.")";
  232. }
  233. if ($search['jogi_statusz']!='') $tempSQL.= " AND jogi_statusz='".$search['jogi_statusz']."'";
  234. //if ($search['szoba_min']!='') $tempSQL.= " AND szoba>='".$search['szoba_min']."'";
  235. //if ($search['szoba_max']!='') $tempSQL.= " AND szoba<='".$search['szoba_max']."'";
  236. if ($search['kilatas']!='') {
  237. $list = explode(",",$search['kilatas']);
  238. $kilatasok = "";
  239. foreach ($list as $kilatas) {
  240. $kilatasok.= "'".$kilatas."',";
  241. }
  242. $kilatasok = rtrim($kilatasok,',');
  243. $tempSQL.= " AND kilatas IN (".$kilatasok.")";
  244. }
  245. if ($search['futes']!='') {
  246. $list = explode(",",$search['futes']);
  247. $futesek = "";
  248. foreach ($list as $futes) {
  249. $futesek.= "'".$futes."',";
  250. }
  251. $futesek = rtrim($futesek,',');
  252. $tempSQL.= " AND futes IN (".$futesek.")";
  253. }
  254. if ($search['tajolas']!='') {
  255. $list = explode(",",$search['tajolas']);
  256. $tajolasok = "";
  257. foreach ($list as $tajolas) {
  258. $tajolasok.= "'".$tajolas."',";
  259. }
  260. $tajolasok = rtrim($tajolasok,',');
  261. $tempSQL.= " AND tajolas IN (".$tajolasok.")";
  262. }
  263. if ($search['allapot']!='') {
  264. $list = explode(",",$search['allapot']);
  265. $allapotok = "";
  266. foreach ($list as $allapot) {
  267. $allapotok.= "'".$allapot."',";
  268. }
  269. $allapotok = rtrim($allapotok,',');
  270. $tempSQL.= " AND ingatlan_allapota IN (".$allapotok.")";
  271. }
  272. if ($search['kornyek']!='') {
  273. $list = explode(",",$search['kornyek']);
  274. $kornyekek = "";
  275. foreach ($list as $kornyek) {
  276. $kornyekek.= "'".$kornyek."',";
  277. }
  278. $kornyekek = rtrim($kornyekek,',');
  279. $tempSQL.= " AND kornyek IN (".$kornyekek.")";
  280. }
  281. if ($search['epites_eve_min']!='') $tempSQL.= " AND epites_eve>='".$search['epites_eve_min']."'";
  282. if ($search['epites_eve_max']!='') $tempSQL.= " AND epites_eve<='".$search['epites_eve_max']."'";
  283. if ($search['telek_min']!='') $tempSQL.= " AND meret_telek>='".$search['telek_min']."'";
  284. if ($search['telek_max']!='') $tempSQL.= " AND meret_telek<='".$search['telek_max']."'";
  285. if ($search['ferohely_garazs_min']!='') $tempSQL.= " AND ferohely_garazs>='".$search['ferohely_garazs_min']."'";
  286. if ($search['ferohely_garazs_max']!='') $tempSQL.= " AND ferohely_garazs<='".$search['ferohely_garazs_max']."'";
  287. if ($search['kulon_nyilo_szobak']=='1') $tempSQL.= " AND kulon_nyilo_szobak='1'";
  288. if ($search['terasz']=='1') $tempSQL.= " AND terasz='1'";
  289. if ($search['erkely']=='1') $tempSQL.= " AND erkely='1'";
  290. if ($search['pince']=='1') $tempSQL.= " AND pince='1'";
  291. if ($search['tarolo']=='1') $tempSQL.= " AND tarolo='1'";
  292. if ($search['garazs']=='1') $tempSQL.= " AND garazs='1'";
  293. if ($search['ferohely_fedettbeallo']=='1') $tempSQL.= " AND ferohely_fedettbeallo='1'";
  294. if ($search['kertkapcsolatos']=='1') $tempSQL.= " AND kertkapcsolatos='1'";
  295. if ($search['viz']=='1') $tempSQL.= " AND viz='1'";
  296. if ($search['gaz']=='1') $tempSQL.= " AND gaz='1'";
  297. if ($search['villany']=='1') $tempSQL.= " AND villany='1'";
  298. if ($search['csatorna']=='1') $tempSQL.= " AND csatorna='1'";
  299. if ($search['lift']=='1') $tempSQL.= " AND lift='1'";
  300. $title = "Találatok";
  301. }
  302. else {
  303. $title = "Ingatlanok";
  304. }
  305. $tempSQL = str_replace("' OR megye='budapest')","' AND megye='budapest'",$tempSQL);
  306. //print_r($search);
  307. //die($tempSQL);
  308. $allSQL = $tempSQL." ORDER BY ".$_SESSION['storedOrderField']." ".$_SESSION['storedOrderDirection'].";";
  309. $tempSQL.= " ORDER BY ".$_SESSION['storedOrderField']." ".$_SESSION['storedOrderDirection'].$this->lazy_loader().";";
  310. $querySQL = $tempSQL;
  311. $_SESSION['storedQuery'] = $querySQL;
  312. //$_SESSION['storedQuery'] = "";
  313. //print_r($search);
  314. //die($_SESSION['storedQuery']);
  315. $result = $this->query($querySQL);
  316. $count = $this->query($allSQL);
  317. if (($search['szoba_min']!='' || $search['szoba_max']!='') && ($search['szoba_min']!='1' && $search['szoba_max']!='100')) {
  318. foreach ($count as $row) {
  319. if ($row->tipus=='') $row->tipus = $row->jelleg;
  320. $szoba = $row->szoba_fel+$row->szoba_egesz;
  321. if ($szoba>=$search['szoba_min'] && $szoba<=$search['szoba_max'] && $search['jelleg']!='telek') {
  322. $return[] = $row;
  323. }
  324. elseif ($search['jelleg']=='telek') {
  325. $return[] = $row;
  326. }
  327. }
  328. $result = $return;
  329. }
  330. elseif (($search['szoba_min']!='' || $search['szoba_max']!='') && ($search['szoba_min']!='1' && $search['szoba_max']=='100')) {
  331. foreach ($count as $row) {
  332. if ($row->tipus=='') $row->tipus = $row->jelleg;
  333. $szoba = $row->szoba_fel+$row->szoba_egesz;
  334. if ($szoba>=$search['szoba_min'] && $szoba<=$search['szoba_max'] && $search['jelleg']!='telek') {
  335. $return[] = $row;
  336. }
  337. elseif ($search['jelleg']=='telek') {
  338. $return[] = $row;
  339. }
  340. }
  341. $result = $return;
  342. }
  343. elseif (($search['szoba_min']!='' || $search['szoba_max']!='') && ($search['szoba_min']=='1' && $search['szoba_max']!='100' && $search['szoba_max']!='')) {
  344. foreach ($count as $row) {
  345. if ($row->tipus=='') $row->tipus = $row->jelleg;
  346. $szoba = $row->szoba_fel+$row->szoba_egesz;
  347. if ($szoba>=$search['szoba_min'] && $szoba<=$search['szoba_max'] && $search['jelleg']!='telek') {
  348. $return[] = $row;
  349. }
  350. elseif ($search['jelleg']=='telek') {
  351. $return[] = $row;
  352. }
  353. }
  354. $result = $return;
  355. }
  356. elseif ($search['szoba_min']=='1' && $search['szoba_max']=='100') {
  357. foreach ($count as $row) {
  358. $return[] = $row;
  359. }
  360. $result = $return;
  361. }
  362. if ($_SESSION['statusz_switch']=='arcsokkent') {
  363. $return = null;
  364. foreach ($count as $row) {
  365. if ($this->isArcsokkent($row->regszam)) {
  366. $return[] = $row;
  367. }
  368. }
  369. $result = $return;
  370. $count = $return;
  371. }
  372. if (sizeof($result)>0) {
  373. $response['error'] = false;
  374. $response['errorMessage'] = 'ok';
  375. $response['title'] = $title;
  376. $response['list'] = $result;
  377. $response['count'] = sizeof($count);
  378. }
  379. else {
  380. $response['error'] = true;
  381. $response['errorMessage'] = 'empty';
  382. }
  383. return $response;
  384. }
  385. public function isArcsokkent($code) {
  386. if ($code!='') {
  387. $check = $this->query("SELECT * FROM hiper_ingatlan_ertekesites WHERE regszam='".$code."' AND arcsokkenes='1';");
  388. if ($check[0]->arcsokkenes=='1') {
  389. return true;
  390. }
  391. else {
  392. return false;
  393. }
  394. }
  395. else {
  396. return false;
  397. }
  398. }
  399. public function lazy_loader() {
  400. if ($_SESSION['storedPager']=='') $_SESSION['storedPager'] = '0';
  401. return " LIMIT ".$_SESSION['storedPager'].",8;";
  402. }
  403. public function lazy_has_more($search) {
  404. if ($_SESSION['storedPager']=='') $_SESSION['storedPager'] = '0';
  405. $search = $this->escapeArray($search);
  406. $tempSQL = "SELECT *,getimgurl(indexkep,'ingatlan') AS indexkep FROM hiper_ingatlan WHERE statusz='aktualis' AND rockhomera_mehet='1'";
  407. if ($_SESSION['storedOrderField']=='') $_SESSION['storedOrderField'] = 'letrehozva';
  408. if ($_SESSION['storedOrderDirection']=='') $_SESSION['storedOrderDirection'] = 'DESC';
  409. if ($search['agent']!='') {
  410. $tempSQL.= " AND tanacsado='".$search['agent']."'";
  411. $title = $this->getAgentName($search['agent']).' tanácsadó ingatlanjai';
  412. }
  413. elseif ($search['from']!='') {
  414. if ($search['ertekesites']!='') $tempSQL.= " AND ertekesites='".$search['ertekesites']."'";
  415. if ($search['jelleg']!='nyaralo') {
  416. if ($search['jelleg']!='') $tempSQL.= " AND jelleg='".$search['jelleg']."'";
  417. if ($search['tipus']!='') $tempSQL.= " AND tipus='".$search['tipus']."'";
  418. }
  419. else {
  420. $tempSQL.= " AND nyaralo='1'";
  421. }
  422. if ($search['city']!='') {
  423. $list = explode(",",$search['city']);
  424. $cities = "";
  425. $megyek = "";
  426. foreach ($list as $city) {
  427. if ($city!='Budapest' && stristr($city," (")==false && $city!='Bács-Kiskun' && $city!='Nográd' && $city!='Borsod-Abaúj-Zemplén' && $city!='Pest' && $city!='Győr-Moson-Sopron' && $city!='Baranya' && $city!='Békés' && $city!='Somogy' && $city!='Jász-Nagykun-Szolnok' && $city!='Csongrád' && $city!='Tolna' && $city!='Komárom-Esztergom' && $city!='Fejér' && $city!='Vas' && $city!='Szabolcs-Szatmár-Bereg' && $city!='Hajdú-Bihar' && $city!='Veszprém' && $city!='Heves' && $city!='Zala') {
  428. $cities.= "'".$city."',";
  429. }
  430. elseif ($city=='Bács-Kiskun' || $city=='Nográd' || $city=='Borsod-Abaúj-Zemplén' || $city=='Pest' || $city=='Győr-Moson-Sopron' || $city=='Baranya' || $city=='Békés' || $city=='Somogy' || $city=='Jász-Nagykun-Szolnok' || $city=='Csongrád' || $city=='Tolna' || $city=='Komárom-Esztergom' || $city=='Fejér' || $city=='Vas' || $city=='Szabolcs-Szatmár-Bereg' || $city=='Hajdú-Bihar' || $city=='Veszprém' || $city=='Heves' || $city=='Zala') {
  431. $city = strtolower($city);
  432. $megyek.= "'".$city."',";
  433. }
  434. }
  435. $megyek = rtrim($megyek,',');
  436. if ($megyek!='') {
  437. $tempSQL.= " AND (megye IN (".$megyek.")";
  438. }
  439. $cities = rtrim($cities,',');
  440. if ($cities!='') {
  441. $tempSQL.= " AND (telepules IN (".$cities.")";
  442. }
  443. }
  444. if ($search['city']!='') {
  445. $list = explode(",",$search['city']);
  446. $cities = "";
  447. $hasStreet = false;
  448. $utcaSQL = "";
  449. foreach ($list as $city) {
  450. if ($city=='Budapest') {
  451. $tempSQL.= " OR megye='budapest'";
  452. }
  453. elseif (stristr($city," (")) {
  454. if ($hasStreet==false) {
  455. $utcaSQL.= " AND (";
  456. }
  457. $hasStreet = true;
  458. $dtemp = explode(" (",$city);
  459. $varosTemp = str_replace(")","",$dtemp[1]);
  460. $utcaTemp = $dtemp[0];
  461. $utcaSQL.= "(utcanev='".$utcaTemp."' AND telepules='".$varosTemp."') OR ";
  462. }
  463. }
  464. if ($hasStreet==false) {
  465. $tempSQL.= ")";
  466. }
  467. $utcaSQL = rtrim($utcaSQL," OR ");
  468. if ($utcaSQL!='') {
  469. $utcaSQL.= ")";
  470. }
  471. $tempSQL.= $utcaSQL;
  472. //die($tempSQL);
  473. }
  474. if ($_SESSION['statusz_switch']=='uj') $tempSQL.= " AND jogi_statusz='uj'";
  475. if ($_SESSION['statusz_switch']=='legujabb') $tempSQL.= " AND letrehozva >= DATE(NOW()) - INTERVAL 14 DAY";
  476. if ($search['ertekesites']=='elado') {
  477. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000000'";
  478. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000000'";
  479. }
  480. else {
  481. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."000'";
  482. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."000'";
  483. }
  484. if ($search['meret_netto_min']!='') $tempSQL.= " AND meret_brutto>='".$search['meret_netto_min']."'";
  485. if ($search['meret_netto_max']!='') $tempSQL.= " AND meret_brutto<='".$search['meret_netto_max']."'";
  486. if ($search['altipus']!='') {
  487. $list = explode(",",$search['altipus']);
  488. $altipusok = "";
  489. foreach ($list as $altipus) {
  490. $altipusok.= "'".$altipus."',";
  491. }
  492. $altipusok = rtrim($altipusok,',');
  493. $tempSQL.= " AND altipus IN (".$altipusok.")";
  494. }
  495. if ($search['jogi_statusz']!='') $tempSQL.= " AND jogi_statusz='".$search['jogi_statusz']."'";
  496. //if ($search['szoba_min']!='') $tempSQL.= " AND szoba>='".$search['szoba_min']."'";
  497. //if ($search['szoba_max']!='') $tempSQL.= " AND szoba<='".$search['szoba_max']."'";
  498. if ($search['kilatas']!='') {
  499. $list = explode(",",$search['kilatas']);
  500. $kilatasok = "";
  501. foreach ($list as $kilatas) {
  502. $kilatasok.= "'".$kilatas."',";
  503. }
  504. $kilatasok = rtrim($kilatasok,',');
  505. $tempSQL.= " AND kilatas IN (".$kilatasok.")";
  506. }
  507. if ($search['futes']!='') {
  508. $list = explode(",",$search['futes']);
  509. $futesek = "";
  510. foreach ($list as $futes) {
  511. $futesek.= "'".$futes."',";
  512. }
  513. $futesek = rtrim($futesek,',');
  514. $tempSQL.= " AND futes IN (".$futesek.")";
  515. }
  516. if ($search['ovezet']!='') {
  517. $list = explode(",",$search['ovezet']);
  518. $ovezetek = "";
  519. foreach ($list as $ovezet) {
  520. $ovezetek.= "'".$ovezet."',";
  521. }
  522. $ovezetek = rtrim($ovezetek,',');
  523. $tempSQL.= " AND ovezeti_besorolas IN (".$ovezetek.")";
  524. }
  525. if ($search['tajolas']!='') {
  526. $list = explode(",",$search['tajolas']);
  527. $tajolasok = "";
  528. foreach ($list as $tajolas) {
  529. $tajolasok.= "'".$tajolas."',";
  530. }
  531. $tajolasok = rtrim($tajolasok,',');
  532. $tempSQL.= " AND tajolas IN (".$tajolasok.")";
  533. }
  534. if ($search['allapot']!='') {
  535. $list = explode(",",$search['allapot']);
  536. $allapotok = "";
  537. foreach ($list as $allapot) {
  538. $allapotok.= "'".$allapot."',";
  539. }
  540. $allapotok = rtrim($allapotok,',');
  541. $tempSQL.= " AND ingatlan_allapota IN (".$allapotok.")";
  542. }
  543. if ($search['kornyek']!='') {
  544. $list = explode(",",$search['kornyek']);
  545. $kornyekek = "";
  546. foreach ($list as $kornyek) {
  547. $kornyekek.= "'".$kornyek."',";
  548. }
  549. $kornyekek = rtrim($kornyekek,',');
  550. $tempSQL.= " AND kornyek IN (".$kornyekek.")";
  551. }
  552. if ($search['epites_eve_min']!='') $tempSQL.= " AND epites_eve>='".$search['epites_eve_min']."'";
  553. if ($search['epites_eve_max']!='') $tempSQL.= " AND epites_eve<='".$search['epites_eve_max']."'";
  554. if ($search['telek_min']!='') $tempSQL.= " AND meret_telek>='".$search['telek_min']."'";
  555. if ($search['telek_max']!='') $tempSQL.= " AND meret_telek<='".$search['telek_max']."'";
  556. if ($search['ferohely_garazs_min']!='') $tempSQL.= " AND ferohely_garazs>='".$search['ferohely_garazs_min']."'";
  557. if ($search['ferohely_garazs_max']!='') $tempSQL.= " AND ferohely_garazs<='".$search['ferohely_garazs_max']."'";
  558. if ($search['kulon_nyilo_szobak']=='1') $tempSQL.= " AND kulon_nyilo_szobak='1'";
  559. if ($search['terasz']=='1') $tempSQL.= " AND terasz='1'";
  560. if ($search['erkely']=='1') $tempSQL.= " AND erkely='1'";
  561. if ($search['pince']=='1') $tempSQL.= " AND pince='1'";
  562. if ($search['tarolo']=='1') $tempSQL.= " AND tarolo='1'";
  563. if ($search['garazs']=='1') $tempSQL.= " AND garazs='1'";
  564. if ($search['ferohely_fedettbeallo']=='1') $tempSQL.= " AND ferohely_fedettbeallo='1'";
  565. if ($search['kertkapcsolatos']=='1') $tempSQL.= " AND kertkapcsolatos='1'";
  566. if ($search['viz']=='1') $tempSQL.= " AND viz='1'";
  567. if ($search['gaz']=='1') $tempSQL.= " AND gaz='1'";
  568. if ($search['villany']=='1') $tempSQL.= " AND villany='1'";
  569. if ($search['csatorna']=='1') $tempSQL.= " AND csatorna='1'";
  570. if ($search['lift']=='1') $tempSQL.= " AND lift='1'";
  571. $title = "Találatok";
  572. }
  573. else {
  574. $title = "Ingatlanok";
  575. }
  576. $tempSQL.= " ORDER BY ".$_SESSION['storedOrderField']." ".$_SESSION['storedOrderDirection']."";
  577. $tempSQL = str_replace("' OR megye='budapest')","' AND megye='budapest'",$tempSQL);
  578. $querySQL = $tempSQL;
  579. $_SESSION['storedQuery'] = $querySQL;
  580. $testPager = $_SESSION['storedPager']+8;
  581. $queryPostfix = $tempSQL;
  582. //die($queryPostfix." LIMIT ".$testPager.",8;");
  583. $result = $this->query($queryPostfix." LIMIT ".$testPager.",8;");
  584. if ($search['szoba_min']!='' || $search['szoba_max']!='') {
  585. foreach ($result as $row) {
  586. $szoba = $row->szoba_fel+$row->szoba_egesz;
  587. if ($szoba>=$search['szoba_min'] && $szoba<=$search['szoba_max']) {
  588. $return[] = $row;
  589. }
  590. }
  591. $result = $return;
  592. }
  593. if ($_SESSION['statusz_switch']=='arcsokkent') {
  594. $return = null;
  595. foreach ($result as $row) {
  596. if ($this->isArcsokkent($row->regszam)) {
  597. $return[] = $row;
  598. }
  599. }
  600. $result = $return;
  601. }
  602. if (sizeof($result)>0) {
  603. return true;
  604. }
  605. else {
  606. return false;
  607. }
  608. }
  609. public function lazy_jumper() {
  610. $_SESSION['storedPager'] = $_SESSION['storedPager']+8;
  611. return true;
  612. }
  613. public function get_ertekesites_tipusok() {
  614. $result = $this->query("SELECT ertekesites FROM hiper_ingatlan WHERE ertekesites<>'' AND (rockhomera_mehet='1' OR rockhomera_mehet='0') AND statusz='aktualis' GROUP BY ertekesites ORDER BY ertekesites ASC;");
  615. return $result;
  616. }
  617. public function get_jelleg_tipusok() {
  618. $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;");
  619. $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;");
  620. foreach ($resultx as $row) {
  621. if ($row->tipus=='tarsashazi') {
  622. $row->jelleg = 'Lakóingatlan - '.$row->tipus;
  623. $result[] = $row;
  624. }
  625. }
  626. foreach ($resultx as $row) {
  627. if ($row->tipus!='tarsashazi') {
  628. $row->jelleg = 'Lakóingatlan - '.$row->tipus;
  629. $result[] = $row;
  630. }
  631. }
  632. foreach ($resulty as $row) {
  633. $result[] = $row;
  634. }
  635. return $result;
  636. }
  637. public function get_telepulesek() {
  638. $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;");
  639. return $result;
  640. }
  641. public function get_altipusok($tipus='') {
  642. if ($tipus!='') {
  643. $result = $this->query("SELECT altipus FROM hiper_ingatlan WHERE altipus<>'' AND tipus='".$tipus."' AND statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0') GROUP BY altipus ORDER BY altipus ASC;");
  644. }
  645. else {
  646. $result = $this->query("SELECT altipus FROM hiper_ingatlan WHERE altipus<>'' AND statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0') GROUP BY altipus ORDER BY altipus ASC;");
  647. }
  648. return $result;
  649. }
  650. public function get_jog() {
  651. $result = $this->query("SELECT jogi_statusz FROM hiper_ingatlan WHERE jogi_statusz<>'' AND statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0') GROUP BY jogi_statusz ORDER BY jogi_statusz ASC;");
  652. return $result;
  653. }
  654. public function get_kilatas() {
  655. $result = $this->query("SELECT kilatas FROM hiper_ingatlan WHERE kilatas<>'' AND statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0') GROUP BY kilatas ORDER BY kilatas ASC;");
  656. return $result;
  657. }
  658. public function get_futes() {
  659. $result = $this->query("SELECT futes FROM hiper_ingatlan WHERE futes<>'' AND statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0') GROUP BY futes ORDER BY futes ASC;");
  660. return $result;
  661. }
  662. public function get_ovezet() {
  663. $result = $this->query("SELECT ovezeti_besorolas AS ovezet FROM hiper_ingatlan WHERE ovezeti_besorolas<>'' AND statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0') GROUP BY ovezeti_besorolas ORDER BY ovezeti_besorolas ASC;");
  664. return $result;
  665. }
  666. public function getSearchObject($id) {
  667. $id = $this->escapeString($id);
  668. $result = $this->query("SELECT * FROM saved_search WHERE sch_id='".$id."';");
  669. return unserialize($result[0]->sch_query);
  670. }
  671. public function getSearchString() {
  672. if ($_SESSION['search']['ertekesites']=='elado') {
  673. $string = 'Eladó';
  674. }
  675. elseif ($_SESSION['search']['ertekesites']=='kiado') {
  676. $string = 'Kiadó';
  677. }
  678. else {
  679. $string = '';
  680. }
  681. if ($_SESSION['search']['tipus']=='tarsashazi') {
  682. $string.= ' lakás';
  683. }
  684. elseif ($_SESSION['search']['tipus']=='csaladihaz') {
  685. $string.= ' családi ház';
  686. }
  687. elseif ($_SESSION['search']['tipus']=='epuletresz') {
  688. $string.= ' épületrész';
  689. }
  690. elseif ($_SESSION['search']['tipus']=='hazresz') {
  691. $string.= ' házrész';
  692. }
  693. elseif ($_SESSION['search']['tipus']=='ikerhaz') {
  694. $string.= ' ikerház';
  695. }
  696. elseif ($_SESSION['search']['tipus']=='onalloepulet') {
  697. $string.= ' önálló épület';
  698. }
  699. elseif ($_SESSION['search']['tipus']=='teljesepulet') {
  700. $string.= ' teljes épület';
  701. }
  702. elseif ($_SESSION['search']['tipus']=='beruhazasi') {
  703. $string.= ' beruházás';
  704. }
  705. elseif ($_SESSION['search']['tipus']=='garazs') {
  706. $string.= ' garázs';
  707. }
  708. elseif ($_SESSION['search']['jelleg']=='nyaralo') {
  709. $string.= ' nyaraló';
  710. }
  711. elseif ($_SESSION['search']['tipus']=='kereskedelmi') {
  712. $string.= ' kereskedelmi';
  713. }
  714. elseif ($_SESSION['search']['tipus']=='mezogazdasagi') {
  715. $string.= ' mezőgazdasági';
  716. }
  717. elseif ($_SESSION['search']['tipus']=='tarolo') {
  718. $string.= ' tároló';
  719. }
  720. elseif ($_SESSION['search']['tipus']=='telek') {
  721. $string.= ' telek';
  722. }
  723. $string.= ', ';
  724. $actives = explode(",",$_SESSION['search']['city']);
  725. foreach ($actives as $item) {
  726. if (stristr($item,"Budapest") && $item!='Budapest') {
  727. $string.= $item.'. kerület, ';
  728. }
  729. else {
  730. $string.= $item.', ';
  731. }
  732. }
  733. $string = trim($string,", ");
  734. return $string;
  735. }
  736. }