| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451 |
- <?php
- class agents_model extends Model {
- public function getAgentsByOffice($id) {
- if ($_SESSION['storedAgentOrderField']=='') $_SESSION['storedAgentOrderField'] = 'nev';
- if ($_SESSION['storedAgentOrderDirection']=='') $_SESSION['storedAgentOrderDirection'] = 'ASC';
- $id = $this->escapeString($id);
- if ($id!=='') {
- $result = $this->query("SELECT * FROM hiper_munkatars WHERE iroda='".$id."' AND aktiv='1' ORDER BY ".$_SESSION['storedAgentOrderField']." ".$_SESSION['storedAgentOrderDirection'].";");
- if (sizeof($result)>0) {
- return $result;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- public function getAgentsList() {
- if ($_SESSION['storedAgentOrderField']=='') $_SESSION['storedAgentOrderField'] = 'nev';
- if ($_SESSION['storedAgentOrderDirection']=='') $_SESSION['storedAgentOrderDirection'] = 'ASC';
- $result = $this->query("SELECT * FROM hiper_munkatars WHERE aktiv='1' ORDER BY ".$_SESSION['storedAgentOrderField']." ".$_SESSION['storedAgentOrderDirection'].";");
- if (sizeof($result)>0) {
- return $result;
- }
- else {
- return false;
- }
- }
- public function getAgentsListSearch($search) {
- if ($_SESSION['storedAgentOrderField']=='') $_SESSION['storedAgentOrderField'] = 'nev';
- if ($_SESSION['storedAgentOrderDirection']=='') $_SESSION['storedAgentOrderDirection'] = 'ASC';
- if ($_SESSION['activeOffice']!='') {
- $tempSQL = " AND iroda='".$_SESSION['activeOffice']."'";
- }
- if ($search['city']!='') {
- $list = explode(",",$search['city']);
- $cities = "";
- foreach ($list as $city) {
- $cities.= "'".$city."',";
- }
- $cities = rtrim($cities,',');
- $tempSQL.= " AND cim_telepules IN (".$cities.")";
- }
- if ($search['name']!='') {
- $list = explode(",",$search['name']);
- $names = "";
- foreach ($list as $name) {
- $names.= "'".$name."',";
- }
- $names = rtrim($names,',');
- $tempSQL.= " AND nev IN (".$names.")";
- }
- $result = $this->query("SELECT * FROM hiper_munkatars WHERE aktiv='1'".$tempSQL." ORDER BY ".$_SESSION['storedAgentOrderField']." ".$_SESSION['storedAgentOrderDirection'].";");
- //die("SELECT * FROM hiper_munkatars WHERE aktiv='1'".$tempSQL." ORDER BY ".$_SESSION['storedAgentOrderField']." ".$_SESSION['storedAgentOrderDirection'].";");
- if (sizeof($result)>0) {
- return $result;
- }
- else {
- return false;
- }
- }
- public function getAgentsCountSearch($resultset) {
- if (is_array($resultset)) {
- return count($resultset);
- }
- else {
- return 0;
- }
- }
- public function getOffice($id) {
- $id = $this->escapeString($id);
- if ($id!=='') {
- $result = $this->query("SELECT * FROM hiper_iroda WHERE azonosito='".$id."';");
- if (sizeof($result)>0) {
- return $result[0];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- public function getAgentsCountByOffice($id) {
- if ($_SESSION['storedAgentOrderField']=='') $_SESSION['storedAgentOrderField'] = 'nev';
- if ($_SESSION['storedAgentOrderDirection']=='') $_SESSION['storedAgentOrderDirection'] = 'ASC';
- $id = $this->escapeString($id);
- if ($id!=='') {
- $result = $this->query("SELECT * FROM hiper_munkatars WHERE iroda='".$id."' AND aktiv='1' ORDER BY ".$_SESSION['storedAgentOrderField']." ".$_SESSION['storedAgentOrderDirection'].";");
- return sizeof($result);
- }
- else {
- return false;
- }
- }
- public function getAgentsCount() {
- if ($_SESSION['storedAgentOrderField']=='') $_SESSION['storedAgentOrderField'] = 'nev';
- if ($_SESSION['storedAgentOrderDirection']=='') $_SESSION['storedAgentOrderDirection'] = 'ASC';
- $result = $this->query("SELECT * FROM hiper_munkatars WHERE aktiv='1' ORDER BY ".$_SESSION['storedAgentOrderField']." ".$_SESSION['storedAgentOrderDirection'].";");
- return sizeof($result);
- }
- public function getAgent($id) {
- $id = $this->escapeString($id);
- if ($id!=='') {
- $result = $this->query("SELECT * FROM hiper_munkatars WHERE id='".$id."';");
- if (sizeof($result)>0) {
- return $result[0];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- 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 getPropertiesList($id) {
- $id = $this->escapeString($id);
- if ($id!=='') {
- $result = $this->query("SELECT *,getimgurl(indexkep,'ingatlan') AS indexkep FROM hiper_ingatlan WHERE tanacsado='".$id."' 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 getPropertiesListShort($id) {
- $id = $this->escapeString($id);
- if ($id!=='') {
- $result = $this->query("SELECT *,getimgurl(indexkep,'ingatlan') AS indexkep FROM hiper_ingatlan WHERE tanacsado='".$id."' 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 getAgentPropertiesCount($agent_code) {
- $agent_code = $this->escapeString($agent_code);
- if ($agent_code!=='') {
- $result = $this->query("SELECT * FROM hiper_ingatlan WHERE tanacsado='".$agent_code."' AND statusz='aktualis' AND rockhomera_mehet='1' ORDER BY letrehozva DESC;");
- return sizeof($result);
- }
- else {
- return false;
- }
- }
- public function get_telepulesek() {
- $result = $this->query("SELECT cim_telepules FROM hiper_munkatars WHERE cim_telepules<>'' AND aktiv='1' GROUP BY cim_telepules ORDER BY cim_telepules ASC;");
- return $result;
- }
- public function get_names() {
- $result = $this->query("SELECT nev FROM hiper_munkatars WHERE nev<>'' AND aktiv='1' ORDER BY nev 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 get_property_list_by_filter($search) {
- $search = $this->escapeArray($search);
- $tempSQL = "SELECT *,getimgurl(indexkep,'ingatlan') AS indexkep 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 tanacsado='".$search['agent']."'";
- 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.")";
- }
- if ($search['iranyar_min']!='') $tempSQL.= " AND iranyar>='".$search['iranyar_min']."'";
- if ($search['iranyar_max']!='') $tempSQL.= " AND iranyar<='".$search['iranyar_max']."'";
- 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']!='') $tempSQL.= " AND szoba>='".$search['szoba_min']."'";
- if ($search['szoba_max']!='') $tempSQL.= " 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;
-
- $_SESSION['storedQuery'] = $querySQL;
-
- $result = $this->query($querySQL);
- return $result;
- }
- public function getAgentUserName($id) {
- $id = $this->escapeString($id);
- if ($id!=='') {
- $agent = $this->query("SELECT * FROM hiper_munkatars WHERE id='".$id."';");
- if (sizeof($agent)>0) {
- return $agent[0]->felhasznalonev;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- public function get_agent_languages($nick) {
- $nick = $this->escapeString($nick);
- $langs = $this->query("SELECT * FROM hiper_munkatars_nyelv WHERE nick='".$nick."' AND nyelv>'0';");
- if (sizeof($langs)>0) {
- foreach ($langs as $lang) {
- switch ($lang->nyelv) {
- case '1': $result[] = 'Angol'; break;
- case '2': $result[] = 'Német'; break;
- case '3': $result[] = 'Spanyol'; break;
- case '4': $result[] = 'Francia'; break;
- case '5': $result[] = 'Olasz'; break;
- case '6': $result[] = 'Orosz'; break;
- }
- }
- return $result;
- }
- else {
- return false;
- }
- }
- public function get_comments($id) {
- $id = $this->escapeString($id);
- if ($id!='') {
- $result = $this->query("SELECT * FROM velemenyek WHERE agent_id='".$id."';");
- if (sizeof($result)>0) {
- return $result;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- public function get_referens($id) {
- $id = $this->escapeString($id);
- if ($id!='') {
- $result = $this->query("SELECT * FROM referensek WHERE agent_id='".$id."';");
- if (sizeof($result)>0) {
- return $result[0];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- }
|