| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 |
- <?php
- class offices_model extends Model {
- public function getOfficesCount() {
- if ($_SESSION['storedOfficeOrderField']=='') $_SESSION['storedOfficeOrderField'] = 'nev';
- if ($_SESSION['storedOfficeOrderDirection']=='') $_SESSION['storedOfficeOrderDirection'] = 'ASC';
- $res = $this->query("SELECT * FROM hiper_iroda WHERE aktiv='1'".$this->getInactiveOffices()." ORDER BY ".$_SESSION['storedOfficeOrderField']." ".$_SESSION['storedOfficeOrderDirection'].";");
- return sizeof($res);
- }
- public function getOfficesList() {
- if ($_SESSION['storedOfficeOrderField']=='') $_SESSION['storedOfficeOrderField'] = 'nev';
- if ($_SESSION['storedOfficeOrderDirection']=='') $_SESSION['storedOfficeOrderDirection'] = 'ASC';
- $res = $this->query("SELECT * FROM hiper_iroda WHERE aktiv='1'".$this->getInactiveOffices()." ORDER BY ".$_SESSION['storedOfficeOrderField']." ".$_SESSION['storedOfficeOrderDirection'].";");
- if (sizeof($res)>0) {
- return $res;
- }
- else {
- return false;
- }
- }
- public function getInactiveOffices() {
- $check = $this->query("SELECT * FROM irodak where active='0';");
- foreach ($check as $row) {
- $temp[] = $row->office_id;
- }
- if (count($temp)>0) {
- return ' AND azonosito NOT IN (\''.implode('\',\'',$temp).'\')';
- }
- else {
- return '';
- }
- }
- public function checkOffice($id) {
- $check = $this->query("SELECT * FROM irodak where office_id='".$id."';");
- if ($check[0]->active=='1') {
- return true;
- }
- else if ($check[0]->active=='0') {
- return false;
- }
- else {
- return true;
- }
- }
- public function getOfficeNames() {
- $result = $this->query("SELECT nev FROM hiper_iroda WHERE nev<>'' AND aktiv='1'".$this->getInactiveOffices()." ORDER BY nev ASC;");
- return $result;
- }
- public function get_bemutatkozas($id) {
- $result = $this->query("SELECT * FROM irodak WHERE office_id='".$id."';");
- return $result[0]->description;
- }
- public function get_pixelid($id) {
- $result = $this->query("SELECT * FROM irodak WHERE office_id='".$id."';");
- return $result[0]->pixelid;
- }
- public function getOffice($id) {
- $id = $this->escapeString($id);
- if ($id!=='') {
- $result = $this->query("SELECT * FROM hiper_iroda WHERE id='".$id."';");
- if (sizeof($result)>0) {
- return $result[0];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- public function getOfficeAgents($id) {
- $id = $this->escapeString($id);
- if ($id!=='') {
- $result = $this->query("SELECT * FROM hiper_munkatars WHERE iroda='".$id."';");
- if (sizeof($result)>0) {
- return $result;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- public function getOfficePropertiesCount($office_code) {
- $office_code = $this->escapeString($office_code);
- if ($office_code!=='') {
- $result = $this->query("SELECT * FROM hiper_ingatlan WHERE iroda='".$office_code."' AND statusz='aktualis' AND rockhomera_mehet='1' ORDER BY letrehozva DESC;");
- return sizeof($result);
- }
- else {
- return false;
- }
- }
- public function getOfficePropertiesList($office_code) {
- $office_code = $this->escapeString($office_code);
- if ($office_code!=='') {
- $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;");
- if (sizeof($result)>0) {
- return $result;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- public function getOfficePropertiesListShort($office_code) {
- $office_code = $this->escapeString($office_code);
- if ($office_code!=='') {
- $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;");
- if (sizeof($result)>0) {
- return $result;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- public function addRate($data) {
- $data = $this->escapeArray($data);
- if ($data['id']!=='' && $data['rate']!=='' && $_SESSION['userid']!=='') {
- $check = $this->query("SELECT * FROM iroda_ratings WHERE iroda='".$data['id']."' AND statusz='1' AND userid='".$_SESSION['userid']."';");
- if (sizeof($check)>0) {
- return 'error';
- }
- else {
- $this->execute("INSERT INTO iroda_ratings SET iroda='".$data['id']."', rate='".$data['rate']."', userid='".$_SESSION['userid']."';");
- return 'ok';
- }
- }
- else {
- return 'error';
- }
- }
- public function getOfficesListSearch($search) {
- if ($_SESSION['storedOfficeOrderField']=='') $_SESSION['storedOfficeOrderField'] = 'nev';
- if ($_SESSION['storedOfficeOrderDirection']=='') $_SESSION['storedOfficeOrderDirection'] = 'ASC';
- $tempSQL = '';
- if ($search['city']!='') {
- $list = explode(",",$search['city']);
- $cities = "";
- foreach ($list as $city) {
- $cities.= "'".$city."',";
- }
- $cities = rtrim($cities,',');
- $tempSQL.= " AND varos IN (".$cities.")";
- }
- if ($search['officename']!='') {
- $list = explode(",",$search['officename']);
- $names = "";
- foreach ($list as $name) {
- $names.= "'".$name."',";
- }
- $names = rtrim($names,',');
- $tempSQL.= " AND nev IN (".$names.")";
- }
- $result = $this->query("SELECT * FROM hiper_iroda WHERE aktiv='1'".$this->getInactiveOffices()."".$tempSQL." ORDER BY ".$_SESSION['storedOfficeOrderField']." ".$_SESSION['storedOfficeOrderDirection'].";");
- if (sizeof($result)>0) {
- return $result;
- }
- else {
- return false;
- }
- }
- public function getOfficesCountSearch($resultset) {
- return sizeof($resultset);
- }
- public function get_telepulesek() {
- $result = $this->query("SELECT varos FROM hiper_iroda WHERE varos<>'' AND aktiv='1' GROUP BY varos ORDER BY varos ASC;");
- return $result;
- }
-
- public function get_ertekesites_tipusok() {
- $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;");
- return $result;
- }
- public function get_jelleg_tipusok() {
- $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;");
- $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;");
-
- foreach ($resultx as $row) {
- $row->jelleg = 'Lakóingatlan - '.$row->tipus;
- $result[] = $row;
- }
- foreach ($resulty as $row) {
- $result[] = $row;
- }
- return $result;
- }
- public function get_properties_telepulesek() {
- $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;");
- return $result;
- }
- public function getOfficeUserName($id) {
- $id = $this->escapeString($id);
- if ($id!=='') {
- $office = $this->query("SELECT * FROM hiper_iroda WHERE id='".$id."';");
- if (sizeof($office)>0) {
- return $office[0]->azonosito;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- public function get_property_list_by_filter($search) {
- $search = $this->escapeArray($search);
- $tempSQL = "SELECT *,getimgurl(indexkep,'ingatlan') AS indexkep, szoba_egesz+szoba_fel AS szoba FROM hiper_ingatlan WHERE statusz='aktualis' AND rockhomera_mehet='1'";
- if ($_SESSION['storedOrderField']=='') $_SESSION['storedOrderField'] = 'letrehozva';
- if ($_SESSION['storedOrderDirection']=='') $_SESSION['storedOrderDirection'] = 'DESC';
- if ($search['from']!='') {
- $tempSQL.= " AND iroda='".$search['office']."'";
- if ($search['ertekesites']!='') $tempSQL.= " AND ertekesites='".$search['ertekesites']."'";
- if ($search['jelleg']!='') $tempSQL.= " AND jelleg='".$search['jelleg']."'";
- if ($search['tipus']!='') $tempSQL.= " AND tipus='".$search['tipus']."'";
- if ($search['city']!='') {
- $list = explode(",",$search['city']);
- $cities = "";
- foreach ($list as $city) {
- $cities.= "'".$city."',";
- }
- $cities = rtrim($cities,',');
- $tempSQL.= " AND telepules IN (".$cities.")";
- }
- $pmin = $search['iranyar_min']*1000000;
- $pmax = $search['iranyar_max']*1000000;
- if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$pmin."'";
- if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$pmax."'";
- if ($search['meret_netto_min']!='') $tempSQL.= " AND meret_netto>='".$search['meret_netto_min']."'";
- if ($search['meret_netto_max']!='') $tempSQL.= " AND meret_netto<='".$search['meret_netto_max']."'";
- if ($search['altipus']!='') {
- $list = explode(",",$search['altipus']);
- $altipusok = "";
- foreach ($list as $altipus) {
- $altipusok.= "'".$altipus."',";
- }
- $altipusok = rtrim($altipusok,',');
- $tempSQL.= " AND altipus IN (".$altipusok.")";
- }
- if ($search['jogi_statusz']!='') $tempSQL.= " AND jogi_statusz='".$search['jogi_statusz']."'";
-
- if ($search['szoba_min']!='' && $search['szoba_max']=='') $tempSQL.= " HAVING szoba>='".$search['szoba_min']."'";
- if ($search['szoba_max']!='' && $search['szoba_min']=='') $tempSQL.= " HAVING szoba<='".$search['szoba_max']."'";
- if ($search['szoba_max']!='' && $search['szoba_min']!='') $tempSQL.= " HAVING szoba>='".$search['szoba_min']."' AND szoba<='".$search['szoba_max']."'";
- if ($search['kilatas']!='') {
- $list = explode(",",$search['kilatas']);
- $kilatasok = "";
- foreach ($list as $kilatas) {
- $kilatasok.= "'".$kilatas."',";
- }
- $kilatasok = rtrim($kilatasok,',');
- $tempSQL.= " AND kilatas IN (".$kilatasok.")";
- }
- if ($search['futes']!='') {
- $list = explode(",",$search['futes']);
- $futesek = "";
- foreach ($list as $futes) {
- $futesek.= "'".$futes."',";
- }
- $futesek = rtrim($futesek,',');
- $tempSQL.= " AND futes IN (".$futesek.")";
- }
- if ($search['tajolas']!='') {
- $list = explode(",",$search['tajolas']);
- $tajolasok = "";
- foreach ($list as $tajolas) {
- $tajolasok.= "'".$tajolas."',";
- }
- $tajolasok = rtrim($tajolasok,',');
- $tempSQL.= " AND tajolas IN (".$tajolasok.")";
- }
- if ($search['allapot']!='') {
- $list = explode(",",$search['allapot']);
- $allapotok = "";
- foreach ($list as $allapot) {
- $allapotok.= "'".$allapot."',";
- }
- $allapotok = rtrim($allapotok,',');
- $tempSQL.= " AND ingatlan_allapota IN (".$allapotok.")";
- }
- if ($search['kornyek']!='') {
- $list = explode(",",$search['kornyek']);
- $kornyekek = "";
- foreach ($list as $kornyek) {
- $kornyekek.= "'".$kornyek."',";
- }
- $kornyekek = rtrim($kornyekek,',');
- $tempSQL.= " AND kornyek IN (".$kornyekek.")";
- }
- if ($search['epites_eve_min']!='') $tempSQL.= " AND epites_eve>='".$search['epites_eve_min']."'";
- if ($search['epites_eve_max']!='') $tempSQL.= " AND epites_eve<='".$search['epites_eve_max']."'";
- if ($search['telek_min']!='') $tempSQL.= " AND meret_telek>='".$search['telek_min']."'";
- if ($search['telek_max']!='') $tempSQL.= " AND meret_telek<='".$search['telek_max']."'";
- if ($search['ferohely_garazs_min']!='') $tempSQL.= " AND ferohely_garazs>='".$search['ferohely_garazs_min']."'";
- if ($search['ferohely_garazs_max']!='') $tempSQL.= " AND ferohely_garazs<='".$search['ferohely_garazs_max']."'";
- if ($search['kulon_nyilo_szobak']=='1') $tempSQL.= " AND kulon_nyilo_szobak='1'";
- if ($search['terasz']=='1') $tempSQL.= " AND terasz='1'";
- if ($search['erkely']=='1') $tempSQL.= " AND erkely='1'";
- if ($search['pince']=='1') $tempSQL.= " AND pince='1'";
- if ($search['tarolo']=='1') $tempSQL.= " AND tarolo='1'";
- if ($search['garazs']=='1') $tempSQL.= " AND garazs='1'";
- if ($search['ferohely_fedettbeallo']=='1') $tempSQL.= " AND ferohely_fedettbeallo='1'";
- if ($search['kertkapcsolatos']=='1') $tempSQL.= " AND kertkapcsolatos='1'";
- if ($search['viz']=='1') $tempSQL.= " AND viz='1'";
- if ($search['gaz']=='1') $tempSQL.= " AND gaz='1'";
- if ($search['villany']=='1') $tempSQL.= " AND villany='1'";
- if ($search['csatorna']=='1') $tempSQL.= " AND csatorna='1'";
- if ($search['lift']=='1') $tempSQL.= " AND lift='1'";
- }
- $tempSQL.= " ORDER BY ".$_SESSION['storedOrderField']." ".$_SESSION['storedOrderDirection'].";";
- $querySQL = $tempSQL;
- //die($querySQL);
-
- $_SESSION['storedQuery'] = $querySQL;
- //echo($querySQL);
-
- $result = $this->query($querySQL);
- return $result;
- }
- public function get_teruletek($partnerid) {
- $partnerid = $this->escapeString($partnerid);
- $res = $this->query("SELECT * FROM hiper_terulet WHERE id_partner='".$partnerid."' AND aktiv='1' ORDER BY nev ASC;");
- return $res;
- }
- }
|