offices_model.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <?php
  2. class offices_model extends Model {
  3. public function getOfficesCount() {
  4. if ($_SESSION['storedOfficeOrderField']=='') $_SESSION['storedOfficeOrderField'] = 'nev';
  5. if ($_SESSION['storedOfficeOrderDirection']=='') $_SESSION['storedOfficeOrderDirection'] = 'ASC';
  6. $res = $this->query("SELECT * FROM hiper_iroda WHERE aktiv='1'".$this->getInactiveOffices()." ORDER BY ".$_SESSION['storedOfficeOrderField']." ".$_SESSION['storedOfficeOrderDirection'].";");
  7. return sizeof($res);
  8. }
  9. public function getOfficesList() {
  10. if ($_SESSION['storedOfficeOrderField']=='') $_SESSION['storedOfficeOrderField'] = 'nev';
  11. if ($_SESSION['storedOfficeOrderDirection']=='') $_SESSION['storedOfficeOrderDirection'] = 'ASC';
  12. $res = $this->query("SELECT * FROM hiper_iroda WHERE aktiv='1'".$this->getInactiveOffices()." ORDER BY ".$_SESSION['storedOfficeOrderField']." ".$_SESSION['storedOfficeOrderDirection'].";");
  13. if (sizeof($res)>0) {
  14. return $res;
  15. }
  16. else {
  17. return false;
  18. }
  19. }
  20. public function getInactiveOffices() {
  21. $check = $this->query("SELECT * FROM irodak where active='0';");
  22. foreach ($check as $row) {
  23. $temp[] = $row->office_id;
  24. }
  25. if (count($temp)>0) {
  26. return ' AND azonosito NOT IN (\''.implode('\',\'',$temp).'\')';
  27. }
  28. else {
  29. return '';
  30. }
  31. }
  32. public function checkOffice($id) {
  33. $check = $this->query("SELECT * FROM irodak where office_id='".$id."';");
  34. if ($check[0]->active=='1') {
  35. return true;
  36. }
  37. else if ($check[0]->active=='0') {
  38. return false;
  39. }
  40. else {
  41. return true;
  42. }
  43. }
  44. public function getOfficeNames() {
  45. $result = $this->query("SELECT nev FROM hiper_iroda WHERE nev<>'' AND aktiv='1'".$this->getInactiveOffices()." ORDER BY nev ASC;");
  46. return $result;
  47. }
  48. public function get_bemutatkozas($id) {
  49. $result = $this->query("SELECT * FROM irodak WHERE office_id='".$id."';");
  50. return $result[0]->description;
  51. }
  52. public function get_pixelid($id) {
  53. $result = $this->query("SELECT * FROM irodak WHERE office_id='".$id."';");
  54. return $result[0]->pixelid;
  55. }
  56. public function getOffice($id) {
  57. $id = $this->escapeString($id);
  58. if ($id!=='') {
  59. $result = $this->query("SELECT * FROM hiper_iroda WHERE id='".$id."';");
  60. if (sizeof($result)>0) {
  61. return $result[0];
  62. }
  63. else {
  64. return false;
  65. }
  66. }
  67. else {
  68. return false;
  69. }
  70. }
  71. public function getOfficeAgents($id) {
  72. $id = $this->escapeString($id);
  73. if ($id!=='') {
  74. $result = $this->query("SELECT * FROM hiper_munkatars WHERE iroda='".$id."';");
  75. if (sizeof($result)>0) {
  76. return $result;
  77. }
  78. else {
  79. return false;
  80. }
  81. }
  82. else {
  83. return false;
  84. }
  85. }
  86. public function getOfficePropertiesCount($office_code) {
  87. $office_code = $this->escapeString($office_code);
  88. if ($office_code!=='') {
  89. $result = $this->query("SELECT * FROM hiper_ingatlan WHERE iroda='".$office_code."' AND statusz='aktualis' AND rockhomera_mehet='1' ORDER BY letrehozva DESC;");
  90. return sizeof($result);
  91. }
  92. else {
  93. return false;
  94. }
  95. }
  96. public function getOfficePropertiesList($office_code) {
  97. $office_code = $this->escapeString($office_code);
  98. if ($office_code!=='') {
  99. $result = $this->query("SELECT *,getimgurl(indexkep,'ingatlan') AS indexkep FROM hiper_ingatlan WHERE iroda='".$office_code."' AND statusz='aktualis' AND rockhomera_mehet='1' ORDER BY letrehozva DESC;");
  100. if (sizeof($result)>0) {
  101. return $result;
  102. }
  103. else {
  104. return false;
  105. }
  106. }
  107. else {
  108. return false;
  109. }
  110. }
  111. public function getOfficePropertiesListShort($office_code) {
  112. $office_code = $this->escapeString($office_code);
  113. if ($office_code!=='') {
  114. $result = $this->query("SELECT *,getimgurl(indexkep,'ingatlan') AS indexkep FROM hiper_ingatlan WHERE iroda='".$office_code."' AND statusz='aktualis' AND rockhomera_mehet='1' ORDER BY letrehozva DESC LIMIT 0,3;");
  115. if (sizeof($result)>0) {
  116. return $result;
  117. }
  118. else {
  119. return false;
  120. }
  121. }
  122. else {
  123. return false;
  124. }
  125. }
  126. public function addRate($data) {
  127. $data = $this->escapeArray($data);
  128. if ($data['id']!=='' && $data['rate']!=='' && $_SESSION['userid']!=='') {
  129. $check = $this->query("SELECT * FROM iroda_ratings WHERE iroda='".$data['id']."' AND statusz='1' AND userid='".$_SESSION['userid']."';");
  130. if (sizeof($check)>0) {
  131. return 'error';
  132. }
  133. else {
  134. $this->execute("INSERT INTO iroda_ratings SET iroda='".$data['id']."', rate='".$data['rate']."', userid='".$_SESSION['userid']."';");
  135. return 'ok';
  136. }
  137. }
  138. else {
  139. return 'error';
  140. }
  141. }
  142. public function getOfficesListSearch($search) {
  143. if ($_SESSION['storedOfficeOrderField']=='') $_SESSION['storedOfficeOrderField'] = 'nev';
  144. if ($_SESSION['storedOfficeOrderDirection']=='') $_SESSION['storedOfficeOrderDirection'] = 'ASC';
  145. $tempSQL = '';
  146. if ($search['city']!='') {
  147. $list = explode(",",$search['city']);
  148. $cities = "";
  149. foreach ($list as $city) {
  150. $cities.= "'".$city."',";
  151. }
  152. $cities = rtrim($cities,',');
  153. $tempSQL.= " AND varos IN (".$cities.")";
  154. }
  155. if ($search['officename']!='') {
  156. $list = explode(",",$search['officename']);
  157. $names = "";
  158. foreach ($list as $name) {
  159. $names.= "'".$name."',";
  160. }
  161. $names = rtrim($names,',');
  162. $tempSQL.= " AND nev IN (".$names.")";
  163. }
  164. $result = $this->query("SELECT * FROM hiper_iroda WHERE aktiv='1'".$this->getInactiveOffices()."".$tempSQL." ORDER BY ".$_SESSION['storedOfficeOrderField']." ".$_SESSION['storedOfficeOrderDirection'].";");
  165. if (sizeof($result)>0) {
  166. return $result;
  167. }
  168. else {
  169. return false;
  170. }
  171. }
  172. public function getOfficesCountSearch($resultset) {
  173. return sizeof($resultset);
  174. }
  175. public function get_telepulesek() {
  176. $result = $this->query("SELECT varos FROM hiper_iroda WHERE varos<>'' AND aktiv='1' GROUP BY varos ORDER BY varos ASC;");
  177. return $result;
  178. }
  179. public function get_ertekesites_tipusok() {
  180. $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;");
  181. return $result;
  182. }
  183. public function get_jelleg_tipusok() {
  184. $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;");
  185. $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;");
  186. foreach ($resultx as $row) {
  187. $row->jelleg = 'Lakóingatlan - '.$row->tipus;
  188. $result[] = $row;
  189. }
  190. foreach ($resulty as $row) {
  191. $result[] = $row;
  192. }
  193. return $result;
  194. }
  195. public function get_properties_telepulesek() {
  196. $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;");
  197. return $result;
  198. }
  199. public function getOfficeUserName($id) {
  200. $id = $this->escapeString($id);
  201. if ($id!=='') {
  202. $office = $this->query("SELECT * FROM hiper_iroda WHERE id='".$id."';");
  203. if (sizeof($office)>0) {
  204. return $office[0]->azonosito;
  205. }
  206. else {
  207. return false;
  208. }
  209. }
  210. else {
  211. return false;
  212. }
  213. }
  214. public function get_property_list_by_filter($search) {
  215. $search = $this->escapeArray($search);
  216. $tempSQL = "SELECT *,getimgurl(indexkep,'ingatlan') AS indexkep, szoba_egesz+szoba_fel AS szoba FROM hiper_ingatlan WHERE statusz='aktualis' AND rockhomera_mehet='1'";
  217. if ($_SESSION['storedOrderField']=='') $_SESSION['storedOrderField'] = 'letrehozva';
  218. if ($_SESSION['storedOrderDirection']=='') $_SESSION['storedOrderDirection'] = 'DESC';
  219. if ($search['from']!='') {
  220. $tempSQL.= " AND iroda='".$search['office']."'";
  221. if ($search['ertekesites']!='') $tempSQL.= " AND ertekesites='".$search['ertekesites']."'";
  222. if ($search['jelleg']!='') $tempSQL.= " AND jelleg='".$search['jelleg']."'";
  223. if ($search['tipus']!='') $tempSQL.= " AND tipus='".$search['tipus']."'";
  224. if ($search['city']!='') {
  225. $list = explode(",",$search['city']);
  226. $cities = "";
  227. foreach ($list as $city) {
  228. $cities.= "'".$city."',";
  229. }
  230. $cities = rtrim($cities,',');
  231. $tempSQL.= " AND telepules IN (".$cities.")";
  232. }
  233. $pmin = $search['iranyar_min']*1000000;
  234. $pmax = $search['iranyar_max']*1000000;
  235. if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$pmin."'";
  236. if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$pmax."'";
  237. if ($search['meret_netto_min']!='') $tempSQL.= " AND meret_netto>='".$search['meret_netto_min']."'";
  238. if ($search['meret_netto_max']!='') $tempSQL.= " AND meret_netto<='".$search['meret_netto_max']."'";
  239. if ($search['altipus']!='') {
  240. $list = explode(",",$search['altipus']);
  241. $altipusok = "";
  242. foreach ($list as $altipus) {
  243. $altipusok.= "'".$altipus."',";
  244. }
  245. $altipusok = rtrim($altipusok,',');
  246. $tempSQL.= " AND altipus IN (".$altipusok.")";
  247. }
  248. if ($search['jogi_statusz']!='') $tempSQL.= " AND jogi_statusz='".$search['jogi_statusz']."'";
  249. if ($search['szoba_min']!='' && $search['szoba_max']=='') $tempSQL.= " HAVING szoba>='".$search['szoba_min']."'";
  250. if ($search['szoba_max']!='' && $search['szoba_min']=='') $tempSQL.= " HAVING szoba<='".$search['szoba_max']."'";
  251. if ($search['szoba_max']!='' && $search['szoba_min']!='') $tempSQL.= " HAVING szoba>='".$search['szoba_min']."' AND szoba<='".$search['szoba_max']."'";
  252. if ($search['kilatas']!='') {
  253. $list = explode(",",$search['kilatas']);
  254. $kilatasok = "";
  255. foreach ($list as $kilatas) {
  256. $kilatasok.= "'".$kilatas."',";
  257. }
  258. $kilatasok = rtrim($kilatasok,',');
  259. $tempSQL.= " AND kilatas IN (".$kilatasok.")";
  260. }
  261. if ($search['futes']!='') {
  262. $list = explode(",",$search['futes']);
  263. $futesek = "";
  264. foreach ($list as $futes) {
  265. $futesek.= "'".$futes."',";
  266. }
  267. $futesek = rtrim($futesek,',');
  268. $tempSQL.= " AND futes IN (".$futesek.")";
  269. }
  270. if ($search['tajolas']!='') {
  271. $list = explode(",",$search['tajolas']);
  272. $tajolasok = "";
  273. foreach ($list as $tajolas) {
  274. $tajolasok.= "'".$tajolas."',";
  275. }
  276. $tajolasok = rtrim($tajolasok,',');
  277. $tempSQL.= " AND tajolas IN (".$tajolasok.")";
  278. }
  279. if ($search['allapot']!='') {
  280. $list = explode(",",$search['allapot']);
  281. $allapotok = "";
  282. foreach ($list as $allapot) {
  283. $allapotok.= "'".$allapot."',";
  284. }
  285. $allapotok = rtrim($allapotok,',');
  286. $tempSQL.= " AND ingatlan_allapota IN (".$allapotok.")";
  287. }
  288. if ($search['kornyek']!='') {
  289. $list = explode(",",$search['kornyek']);
  290. $kornyekek = "";
  291. foreach ($list as $kornyek) {
  292. $kornyekek.= "'".$kornyek."',";
  293. }
  294. $kornyekek = rtrim($kornyekek,',');
  295. $tempSQL.= " AND kornyek IN (".$kornyekek.")";
  296. }
  297. if ($search['epites_eve_min']!='') $tempSQL.= " AND epites_eve>='".$search['epites_eve_min']."'";
  298. if ($search['epites_eve_max']!='') $tempSQL.= " AND epites_eve<='".$search['epites_eve_max']."'";
  299. if ($search['telek_min']!='') $tempSQL.= " AND meret_telek>='".$search['telek_min']."'";
  300. if ($search['telek_max']!='') $tempSQL.= " AND meret_telek<='".$search['telek_max']."'";
  301. if ($search['ferohely_garazs_min']!='') $tempSQL.= " AND ferohely_garazs>='".$search['ferohely_garazs_min']."'";
  302. if ($search['ferohely_garazs_max']!='') $tempSQL.= " AND ferohely_garazs<='".$search['ferohely_garazs_max']."'";
  303. if ($search['kulon_nyilo_szobak']=='1') $tempSQL.= " AND kulon_nyilo_szobak='1'";
  304. if ($search['terasz']=='1') $tempSQL.= " AND terasz='1'";
  305. if ($search['erkely']=='1') $tempSQL.= " AND erkely='1'";
  306. if ($search['pince']=='1') $tempSQL.= " AND pince='1'";
  307. if ($search['tarolo']=='1') $tempSQL.= " AND tarolo='1'";
  308. if ($search['garazs']=='1') $tempSQL.= " AND garazs='1'";
  309. if ($search['ferohely_fedettbeallo']=='1') $tempSQL.= " AND ferohely_fedettbeallo='1'";
  310. if ($search['kertkapcsolatos']=='1') $tempSQL.= " AND kertkapcsolatos='1'";
  311. if ($search['viz']=='1') $tempSQL.= " AND viz='1'";
  312. if ($search['gaz']=='1') $tempSQL.= " AND gaz='1'";
  313. if ($search['villany']=='1') $tempSQL.= " AND villany='1'";
  314. if ($search['csatorna']=='1') $tempSQL.= " AND csatorna='1'";
  315. if ($search['lift']=='1') $tempSQL.= " AND lift='1'";
  316. }
  317. $tempSQL.= " ORDER BY ".$_SESSION['storedOrderField']." ".$_SESSION['storedOrderDirection'].";";
  318. $querySQL = $tempSQL;
  319. //die($querySQL);
  320. $_SESSION['storedQuery'] = $querySQL;
  321. //echo($querySQL);
  322. $result = $this->query($querySQL);
  323. return $result;
  324. }
  325. public function get_teruletek($partnerid) {
  326. $partnerid = $this->escapeString($partnerid);
  327. $res = $this->query("SELECT * FROM hiper_terulet WHERE id_partner='".$partnerid."' AND aktiv='1' ORDER BY nev ASC;");
  328. return $res;
  329. }
  330. }