main_model.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <?php
  2. class main_model extends Model {
  3. public function getSlideShow() {
  4. $result = $this->query("SELECT * FROM azonics_boxes WHERE box_status<>'0' ORDER BY box_id ASC;");
  5. if (sizeof($result)>0) {
  6. return $result;
  7. }
  8. else {
  9. return false;
  10. }
  11. }
  12. public function getMenu($section = 'tours') {
  13. $result = $this->query("SELECT * FROM azonics_menus WHERE box_status<>'0' AND box_subtitle='".$section."' ORDER BY box_id ASC;");
  14. if (sizeof($result)>0) {
  15. return $result;
  16. }
  17. else {
  18. return false;
  19. }
  20. }
  21. public function getBoxes($lang = 'en') {
  22. $result = $this->query("SELECT * FROM azonics_blocks WHERE box_status<>'0' ORDER BY box_id ASC;");
  23. if (sizeof($result)>0) {
  24. return $result;
  25. }
  26. else {
  27. return false;
  28. }
  29. }
  30. public function getServices() {
  31. $result = $this->query("SELECT * FROM azonics_services WHERE box_status<>'0' ORDER BY box_id ASC;");
  32. if (sizeof($result)>0) {
  33. return $result;
  34. }
  35. else {
  36. return false;
  37. }
  38. }
  39. public function getReviews($from,$limit) {
  40. $result = $this->query("SELECT * FROM azonics_reviews WHERE box_status<>'0' ORDER BY box_id ASC LIMIT ".$from.", ".$limit.";");
  41. if (sizeof($result)>0) {
  42. return $result;
  43. }
  44. else {
  45. return false;
  46. }
  47. }
  48. public function getFAQs($limit) {
  49. if ($limit != 0) {
  50. $result = $this->query("SELECT * FROM azonics_faq WHERE box_status<>'0' ORDER BY box_id ASC LIMIT 0, ".$limit.";");
  51. }
  52. else {
  53. $result = $this->query("SELECT * FROM azonics_faq WHERE box_status<>'0' ORDER BY box_id;");
  54. }
  55. if (sizeof($result)>0) {
  56. return $result;
  57. }
  58. else {
  59. return false;
  60. }
  61. }
  62. public function getGallery() {
  63. $result = $this->query("SELECT * FROM azonics_slideshow WHERE slide_status<>'0' ORDER BY slide_id ASC;");
  64. if (sizeof($result)>0) {
  65. return $result;
  66. }
  67. else {
  68. return false;
  69. }
  70. }
  71. public function getBoarding() {
  72. $result = $this->query("SELECT * FROM azonics_boarding WHERE box_id='1';");
  73. if (sizeof($result)>0) {
  74. return $result[0];
  75. }
  76. else {
  77. return false;
  78. }
  79. }
  80. public function getOurServices() {
  81. $result = $this->query("SELECT * FROM azonics_pages WHERE page_id='1';");
  82. if (sizeof($result)>0) {
  83. return $result[0];
  84. }
  85. else {
  86. return false;
  87. }
  88. }
  89. public function getPortfolio($lang = 'en') {
  90. $result = $this->query("SELECT * FROM azonics_blog WHERE page_status<>'0' AND page_category='befektetesek' ORDER BY page_id ASC;");
  91. if (sizeof($result)>0) {
  92. return $result;
  93. }
  94. else {
  95. return false;
  96. }
  97. }
  98. public function getAnnos($lang = 'en') {
  99. $result = $this->query("SELECT * FROM azonics_blog WHERE page_status<>'0' AND page_category='kozzetetelek' ORDER BY page_id ASC;");
  100. if (sizeof($result)>0) {
  101. return $result;
  102. }
  103. else {
  104. return false;
  105. }
  106. }
  107. public function getBox($id) {
  108. $result = $this->query("SELECT * FROM azonics_boxes WHERE box_status<>'0' AND box_id='".$id."';");
  109. if (sizeof($result)>0) {
  110. return $result[0];
  111. }
  112. else {
  113. return false;
  114. }
  115. }
  116. public function getAllPropertiesCount() {
  117. $result = $this->query("SELECT * FROM hiper_ingatlan WHERE statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0');");
  118. return sizeof($result);
  119. }
  120. public function getAllAgentsCount() {
  121. $result = $this->query("SELECT * FROM hiper_munkatars WHERE aktiv='1';");
  122. return sizeof($result);
  123. }
  124. public function getAllOfficesCount() {
  125. $result = $this->query("SELECT * FROM hiper_iroda WHERE aktiv='1';");
  126. return sizeof($result);
  127. }
  128. public function get_telepulesek() {
  129. $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;");
  130. return $result;
  131. }
  132. public function getCitySuggession($key) {
  133. $key = $this->escapeString($key);
  134. $result = $this->query("SELECT telepules FROM hiper_ingatlan WHERE telepules<>'' AND telepules LIKE '%".$key."%' AND statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0') GROUP BY telepules ORDER BY telepules ASC;");
  135. return $result;
  136. }
  137. public function getMoreOffers($limit,$source) {
  138. $search = $this->escapeArray($search);
  139. $tempSQL = "SELECT * FROM hiper_ingatlan WHERE statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  140. if ($_SESSION['storedOrderField']=='') $_SESSION['storedOrderField'] = 'letrehozva';
  141. if ($_SESSION['storedOrderDirection']=='') $_SESSION['storedOrderDirection'] = 'DESC';
  142. $tempSQL.= $this->getInactiveOffices()." ORDER BY ".$_SESSION['storedOrderField']." ".$_SESSION['storedOrderDirection'].";";
  143. $querySQL = $tempSQL;
  144. $result = $this->query($querySQL);
  145. if (sizeof($result)>0) {
  146. $i = 0;
  147. foreach ($result as $row) {
  148. $skip = false;
  149. foreach ($source as $item) {
  150. if ($item->id==$row->id) {
  151. $skip = true;
  152. }
  153. }
  154. if ($skip==false && $i<$limit) {
  155. $i++;
  156. $source[] = $row;
  157. }
  158. }
  159. return $source;
  160. }
  161. else {
  162. return false;
  163. }
  164. }
  165. public function getInactiveOffices() {
  166. $check = $this->query("SELECT * FROM irodak where active='0';");
  167. foreach ($check as $row) {
  168. $temp[] = $row->office_id;
  169. }
  170. if (count($temp)>0) {
  171. return ' AND iroda NOT IN (\''.implode('\',\'',$temp).'\')';
  172. }
  173. else {
  174. return '';
  175. }
  176. }
  177. public function getAgentName($id) {
  178. $id = $this->escapeString($id);
  179. if ($id!='') {
  180. $agent = $this->query("SELECT * FROM hiper_munkatars WHERE felhasznalonev='".$id."';");
  181. if (sizeof($agent)>0) {
  182. return $agent[0]->nev;
  183. }
  184. else {
  185. return false;
  186. }
  187. }
  188. else {
  189. return false;
  190. }
  191. }
  192. public function get_offers($search) {
  193. $search = $this->escapeArray($search);
  194. $tempSQL = "SELECT *,getimgurl(indexkep,'ingatlan') AS indexkep FROM hiper_ingatlan WHERE statusz='aktualis' AND (rockhomera_mehet='1' OR rockhomera_mehet='0')";
  195. /*if ($_SESSION['search']['city']!='' && stristr($_SESSION['search']['city']," (")==false) {
  196. $list = explode(",",$_SESSION['search']['city']);
  197. $cities = "";
  198. foreach ($list as $city) {
  199. if ($city!='Budapest') {
  200. $cities.= "'".$city."',";
  201. }
  202. }
  203. $cities = rtrim($cities,',');
  204. if ($cities!='') {
  205. $tempSQL.= " AND telepules IN (".$cities.")";
  206. }
  207. foreach ($list as $city) {
  208. if ($city=='Budapest') {
  209. $tempSQL.= " AND telepules LIKE '%".$city."%'";
  210. }
  211. }
  212. }
  213. elseif (stristr($_SESSION['search']['city']," (")) {
  214. $tempSQL.= " AND telepules LIKE '%Budapest%'";
  215. }*/
  216. if ($_SESSION['storedOrderField']=='') $_SESSION['storedOrderField'] = 'letrehozva';
  217. if ($_SESSION['storedOrderDirection']=='') $_SESSION['storedOrderDirection'] = 'DESC';
  218. $tempSQL.= $this->getInactiveOffices()." ORDER BY ".$_SESSION['storedOrderField']." ".$_SESSION['storedOrderDirection']." LIMIT 0,8;";
  219. //die($tempSQL);
  220. $querySQL = $tempSQL;
  221. $result = $this->query($querySQL);
  222. if (sizeof($result)>0) {
  223. if (sizeof($result)<8) {
  224. $diff = 8-count($result);
  225. $result = $this->getMoreOffers($diff,$result);
  226. }
  227. foreach ($result as $item) {
  228. $item->tanacsado = $this->getAgentName($item->tanacsado);
  229. $lista[] = $item;
  230. }
  231. return $result;
  232. }
  233. else {
  234. return false;
  235. }
  236. }
  237. public function exportdata() {
  238. $sqlStatement = "SELECT
  239. hiper_ingatlan.id AS ocId,
  240. hiper_ingatlan.regszam AS regszam,
  241. hiper_ingatlan.iroda AS irodaKod,
  242. hiper_ingatlan.ertekesites AS ertekesites,
  243. hiper_ingatlan.letrehozva AS rogzites_datuma,
  244. hiper_ingatlan.modositva AS modositas_datuma,
  245. hiper_ingatlan.jogi_statusz AS jogiStatus,
  246. hiper_ingatlan.tipus,
  247. hiper_ingatlan.altipus AS epitesModja,
  248. hiper_ingatlan.megye,
  249. hiper_ingatlan.iranyitoszam,
  250. hiper_ingatlan.telepules,
  251. hiper_ingatlan.korzet AS varosresz,
  252. hiper_ingatlan.iranyar,
  253. hiper_ingatlan.meret_netto AS nettoMeret,
  254. hiper_ingatlan.meret_brutto As bruttoMeret,
  255. hiper_ingatlan.meret_telek AS telekMeret,
  256. hiper_ingatlan.szoba_egesz AS egeszSzoba,
  257. hiper_ingatlan.szoba_furdo AS furdoSzoba,
  258. hiper_ingatlan.belmagassag,
  259. hiper_ingatlan.futes,
  260. hiper_ingatlan.ingatlan_allapota AS allapot,
  261. hiper_ingatlan.tajolas,
  262. hiper_ingatlan.epites_eve AS epitesEve,
  263. hiper_ingatlan.csatorna,
  264. hiper_ingatlan.gaz,
  265. hiper_ingatlan.villany,
  266. hiper_ingatlan.viz,
  267. hiper_ingatlan.ferohely_garazs,
  268. hiper_ingatlan.ferohely_nyitottbeallo,
  269. hiper_ingatlan_text.szlogen AS szlogen,
  270. hiper_ingatlan_text.leiras AS leiras,
  271. hiper_ingatlan.meret_terasz as teraszMeret,
  272. hiper_ingatlan.utcanev AS utca,
  273. hiper_ingatlan.emelet AS emelet,
  274. hiper_ingatlan.zaroszint AS zaroszint,
  275. hiper_ingatlan.kilatas AS kilatas,
  276. hiper_ingatlan.kozoskoltseg AS kozoskoltseg,
  277. hiper_ingatlan.energetikai_tanusitvany AS energetikai_tanusitvany,
  278. hiper_ingatlan.szoba_fel AS szoba_fel,
  279. hiper_ingatlan.ferohely_fedettbeallo AS ferohely_fedettbeallo,
  280. hiper_ingatlan.lift AS lift,
  281. hiper_ingatlan.jutalek as jutalek,
  282. hiper_ingatlan.statusz AS statusz,
  283. hiper_iroda.id AS irodaId,
  284. hiper_iroda.nev AS partneriroda_neve,
  285. hiper_tranzakcio.ingatlan_sorsa AS ingatlan_sorsa,
  286. hiper_tranzakcio.teljes_ar AS teljes_ar,
  287. hiper_tranzakcio.szerzodeskotes_datuma AS szerzodeskotes_datuma FROM hiper_ingatlan
  288. LEFT JOIN hiper_ingatlan_text ON hiper_ingatlan_text.regszam=hiper_ingatlan.regszam
  289. LEFT JOIN hiper_tranzakcio ON hiper_tranzakcio.regszam=hiper_ingatlan.regszam
  290. LEFT JOIN hiper_iroda ON hiper_iroda.azonosito=hiper_ingatlan.iroda
  291. WHERE hiper_ingatlan.statusz='eladva' AND hiper_tranzakcio.ingatlan_sorsa='eladva' ORDER BY hiper_ingatlan.letrehozva ASC;";
  292. $result = $this->query($sqlStatement,true);
  293. foreach ($result as $row) {
  294. $row->ertekesites = $this->getDict('ertekesites',$row->ertekesites);
  295. $row->jogiStatus = $this->getDict('jogi_statusz',$row->jogiStatus);
  296. $row->tipus = $this->getDict('tipus',$row->tipus);
  297. $row->epitesModja = $this->getDict('altipus',$row->epitesModja);
  298. $row->belmagassag = $this->getDict('belmagassag',$row->belmagassag);
  299. $row->futes = $this->getDict('futes',$row->futes);
  300. $row->allapot = $this->getDict('ingatlan_allapota',$row->allapot);
  301. $row->tajolas = $this->getDict('tajolas',$row->tajolas);
  302. $row->zaroszint = $this->getDict('zaroszint',$row->zaroszint);
  303. $row->kilatas = $this->getDict('kilatas',$row->kilatas);
  304. }
  305. return $result;
  306. }
  307. public function exportActiveData() {
  308. $sqlStatement = "SELECT
  309. hiper_ingatlan.id AS ocId,
  310. hiper_ingatlan.regszam AS regszam,
  311. hiper_ingatlan.iroda AS irodaKod,
  312. hiper_ingatlan.ertekesites AS ertekesites,
  313. hiper_ingatlan.letrehozva AS rogzites_datuma,
  314. hiper_ingatlan.modositva AS modositas_datuma,
  315. hiper_ingatlan.jogi_statusz AS jogiStatus,
  316. hiper_ingatlan.tipus,
  317. hiper_ingatlan.altipus AS epitesModja,
  318. hiper_ingatlan.megye,
  319. hiper_ingatlan.iranyitoszam,
  320. hiper_ingatlan.telepules,
  321. hiper_ingatlan.korzet AS varosresz,
  322. hiper_ingatlan.iranyar,
  323. hiper_ingatlan.meret_netto AS nettoMeret,
  324. hiper_ingatlan.meret_brutto As bruttoMeret,
  325. hiper_ingatlan.meret_telek AS telekMeret,
  326. hiper_ingatlan.szoba_egesz AS egeszSzoba,
  327. hiper_ingatlan.szoba_furdo AS furdoSzoba,
  328. hiper_ingatlan.belmagassag,
  329. hiper_ingatlan.futes,
  330. hiper_ingatlan.ingatlan_allapota AS allapot,
  331. hiper_ingatlan.tajolas,
  332. hiper_ingatlan.epites_eve AS epitesEve,
  333. hiper_ingatlan.csatorna,
  334. hiper_ingatlan.gaz,
  335. hiper_ingatlan.villany,
  336. hiper_ingatlan.viz,
  337. hiper_ingatlan.ferohely_garazs,
  338. hiper_ingatlan.ferohely_nyitottbeallo,
  339. hiper_ingatlan_text.szlogen AS szlogen,
  340. hiper_ingatlan_text.leiras AS leiras,
  341. hiper_ingatlan.meret_terasz as teraszMeret,
  342. hiper_ingatlan.utcanev AS utca,
  343. hiper_ingatlan.emelet AS emelet,
  344. hiper_ingatlan.zaroszint AS zaroszint,
  345. hiper_ingatlan.kilatas AS kilatas,
  346. hiper_ingatlan.kozoskoltseg AS kozoskoltseg,
  347. hiper_ingatlan.energetikai_tanusitvany AS energetikai_tanusitvany,
  348. hiper_ingatlan.szoba_fel AS szoba_fel,
  349. hiper_ingatlan.ferohely_fedettbeallo AS ferohely_fedettbeallo,
  350. hiper_ingatlan.lift AS lift,
  351. hiper_ingatlan.jutalek as jutalek,
  352. hiper_ingatlan.statusz AS statusz,
  353. hiper_iroda.id AS irodaId,
  354. hiper_iroda.nev AS partneriroda_neve,
  355. hiper_tranzakcio.ingatlan_sorsa AS ingatlan_sorsa,
  356. hiper_tranzakcio.teljes_ar AS teljes_ar,
  357. hiper_tranzakcio.szerzodeskotes_datuma AS szerzodeskotes_datuma FROM hiper_ingatlan
  358. LEFT JOIN hiper_ingatlan_text ON hiper_ingatlan_text.regszam=hiper_ingatlan.regszam
  359. LEFT JOIN hiper_tranzakcio ON hiper_tranzakcio.regszam=hiper_ingatlan.regszam
  360. LEFT JOIN hiper_iroda ON hiper_iroda.azonosito=hiper_ingatlan.iroda
  361. WHERE hiper_ingatlan.statusz='aktualis' ORDER BY hiper_ingatlan.letrehozva ASC;";
  362. $result = $this->query($sqlStatement,true);
  363. foreach ($result as $row) {
  364. $row->ertekesites = $this->getDict('ertekesites',$row->ertekesites);
  365. $row->jogiStatus = $this->getDict('jogi_statusz',$row->jogiStatus);
  366. $row->tipus = $this->getDict('tipus',$row->tipus);
  367. $row->epitesModja = $this->getDict('altipus',$row->epitesModja);
  368. $row->belmagassag = $this->getDict('belmagassag',$row->belmagassag);
  369. $row->futes = $this->getDict('futes',$row->futes);
  370. $row->allapot = $this->getDict('ingatlan_allapota',$row->allapot);
  371. $row->tajolas = $this->getDict('tajolas',$row->tajolas);
  372. $row->zaroszint = $this->getDict('zaroszint',$row->zaroszint);
  373. $row->kilatas = $this->getDict('kilatas',$row->kilatas);
  374. }
  375. return $result;
  376. }
  377. public function getDict($group,$value) {
  378. $trans = $this->query("SELECT * FROM `dictionary` WHERE `group`='".$group."' AND `config_key`='".$value."' AND `language`='hu';",true);
  379. return $trans[0]->config_value;
  380. }
  381. }