function count_estate_by_type_and_city($city_id, $estatetype_id) { $CI =& get_instance(); $estates = new Estate(); $estates->where('estatecity_id', $city_id); $estates->where('estatetype_id', $estatetype_id); $estates->where(array('active' => 0, 'isFree' => 0)); $estates->get(); return $estates->result_count(); }
function GL() { // get all province $estateProvince = new Estatecity(); $estateProvince->order_by('position', 'asc'); $estateProvince->get_iterated(); $dis['estateProvince'] = $estateProvince; // get all Areas $estateAreas = new Estatearea(); $estateAreas->order_by('position', 'asc'); $estateAreas->get_iterated(); $dis['estateAreas'] = $estateAreas; // get all Prices $estatePrices = new Estateprice(); $estatePrices->order_by('position', 'asc'); $estatePrices->get_iterated(); $dis['estatePrices'] = $estatePrices; // get all Direction $estateDirection = new Estatedirection(); $estateDirection->order_by('position', 'asc'); $estateDirection->get_iterated(); $dis['estateDirection'] = $estateDirection; // get all District $estateDistrict = new Estatedistrict(); $estateDistrict->order_by('position', 'asc'); $estateDistrict->get_iterated(); $dis['estateDistrict'] = $estateDistrict; // get estates new $estatesNew = new Estate(); $estatesNew->order_by('created', 'desc'); $estatesNew->where('active', 0); $estatesNew->get(12); $dis['estatesNew'] = $estatesNew; // get estates vip $estatesVip = new Estate(); $estatesVip->order_by('created', 'desc'); $estatesVip->where('isVip', 1); $estatesVip->where('active', 0); $estatesVip->get_iterated(); $dis['estatesVip'] = $estatesVip; // get news view most $newViewMost = new Article(); $newViewMost->where('recycle', 0); $newViewMost->where_in('newscatalogue_id', $this->listAllCat); $newViewMost->order_by('view_count', 'desc'); $newViewMost->get(10); $dis['newViewMost'] = $newViewMost; //load view $this->isRobotFollow = 3; $dis['base_url'] = base_url(); $dis['view'] = 'front/includes/main_content'; $this->viewfront($dis); }
function GL() { // get all province $estateProvince = new Estatecity(); $estateProvince->order_by('position', 'asc'); $estateProvince->get_iterated(); $dis['estateProvince'] = $estateProvince; // get all Areas $estateAreas = new Estatearea(); $estateAreas->order_by('position', 'asc'); $estateAreas->get_iterated(); $dis['estateAreas'] = $estateAreas; // get all Prices $estatePrices = new Estateprice(); $estatePrices->order_by('position', 'asc'); $estatePrices->get_iterated(); $dis['estatePrices'] = $estatePrices; // get all Direction $estateDirection = new Estatedirection(); $estateDirection->order_by('position', 'asc'); $estateDirection->get_iterated(); $dis['estateDirection'] = $estateDirection; // get all District $estateDistrict = new Estatedistrict(); $estateDistrict->order_by('position', 'asc'); $estateDistrict->get_iterated(); $dis['estateDistrict'] = $estateDistrict; // get estates new $estatesNew = new Estate(); $estatesNew->order_by('created', 'desc'); $estatesNew->get(25); $dis['estatesNew'] = $estatesNew; // get estates vip $estatesVip = new Estate(); $estatesVip->order_by('id', 'desc'); $estatesVip->where('isVip', 1); $estatesVip->get(10); $dis['estatesVip'] = $estatesVip; //load view $dis['base_url'] = base_url(); $dis['view'] = 'front/includes/main_content'; $this->viewfront($dis); }
function listPostByUser() { if ($this->session->userdata('userLoginFlag') != 1) { redirect(base_url() . 'dang-nhap'); } $customer = new Estateuser($this->session->userdata('userLoginId')); if (!$customer->exists()) { show_404(); } $dis['customer'] = $customer; $level = 1; $page = $this->uri->segment($level + 1, "") == "" ? 0 : $this->uri->segment($level + 1); $dis['page'] = $page; $limit = 15; $offset = $page + 1; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $estatecatalogue_id = $this->input->post('estatecatalogue_id'); $estatetype_id = $this->input->post('estatetype_id'); $estateprice_id = $this->input->post('estateprice_id'); $estates = new Estate(); $estates->where_related_estateuser('id', $this->session->userdata('userLoginId')); $estates->where(array('isFree' => 0)); if ($estatecatalogue_id != 0) { $estates->where('estatecatalogue_id', $estatecatalogue_id); } if ($estatetype_id != 0) { $estates->where('estatetype_id', $estatetype_id); } if ($estateprice_id != 0) { $estates->where('estateprice_id', $estateprice_id); } $estates->order_by('created', 'desc'); $estates->get_paged($offset, $limit, TRUE); $dis['estates'] = $estates; setPaginationVb('chinh-sua-tin-da-dang/', $estates->paged->total_rows, $limit, 2); } else { $estates = new Estate(); $estates->where_related_estateuser('id', $this->session->userdata('userLoginId')); $estates->where('isFree', 0); $estates->order_by('created', 'desc'); $estates->get_paged($offset, $limit, TRUE); $dis['estates'] = $estates; setPaginationVb('chinh-sua-tin-da-dang/', $estates->paged->total_rows, $limit, 2); /*$estatesAll = new Estate(); $estatesAll->where_related_estateuser('id', $this->session->userdata('userLoginId')); $estatesAll->order_by('created','desc'); $estatesAll->get(); $total = $estatesAll->result_count();*/ } $dis['base_url'] = base_url(); $dis['view'] = 'front/user/list-post'; $this->viewfront($dis); }
function searchView() { $this->isRobotFollow = false; $query_string = explode('tim-kiem-bat-dong-san/?', $_SERVER['REQUEST_URI']); parse_str($query_string[1], $_GET); $estatecatalogue_id = $_GET['danhmuc']; $estatetype_id = $_GET['loai']; $estatecity_id = $_GET['tinh']; $estatedistrict_id = $_GET['huyen']; $estatearea_id = $_GET['dientich']; $estateprice_id = $_GET['gia']; $estatedirection_id = $_GET['huong']; $dis['estatecatalogue_id'] = $estatecatalogue_id; $level = 1; $page = $this->uri->segment($level + 1, "") == "" ? 1 : $this->uri->segment($level + 1); $dis['page'] = $page; $page = $_GET['per_page']; $limit = 20; $offset = ($page - 1) * $limit; $estates = new Estate(); if ($estatecatalogue_id != 0) { $estates->where('estatecatalogue_id', $estatecatalogue_id); } if ($estatetype_id != 0) { $estates->where('estatetype_id', $estatetype_id); } if ($estatecity_id != 0) { $estates->where('estatecity_id', $estatecity_id); } if ($estatedistrict_id != 0) { $estates->where('estatedistrict_id', $estatedistrict_id); } if ($estatearea_id != 0) { if ($estatearea_id == -1) { $estates->where('isArea', 1); } else { $estates->where('estatearea_id', $estatearea_id); } } if ($estateprice_id != 0) { if ($estateprice_id == -1) { $estates->where('isPrice', 1); } else { $estates->where('estateprice_id', $estateprice_id); } } if ($estatedirection_id != 0) { $estates->where('estatedirection_id', $estatedirection_id); } $estates->order_by('isVip', 'desc'); $estates->order_by('created', 'desc'); $estates->get_paged($offset, $limit, TRUE); $estatesAll = new Estate(); if ($estatecatalogue_id != 0) { $estatesAll->where('estatecatalogue_id', $estatecatalogue_id); } if ($estatetype_id != 0) { $estatesAll->where('estatetype_id', $estatetype_id); } if ($estatecity_id != 0) { $estatesAll->where('estatecity_id', $estatecity_id); } if ($estatedistrict_id != 0) { $estatesAll->where('estatedistrict_id', $estatedistrict_id); } if ($estatearea_id != 0) { if ($estatearea_id == -1) { $estatesAll->where('isArea', 1); } else { $estatesAll->where('estatearea_id', $estatearea_id); } } if ($estateprice_id != 0) { if ($estateprice_id == -1) { $estatesAll->where('isPrice', 1); } else { $estatesAll->where('estateprice_id', $estateprice_id); } } if ($estatedirection_id != 0) { $estatesAll->where('estatedirection_id', $estatedirection_id); } $estatesAll->order_by('isVip', 'desc'); $estatesAll->order_by('created', 'desc'); $estatesAll->get_iterated(); $dis['estates'] = $estates; /*Begin pagination for product*/ $url = $this->uri->segment(1) . '/?danhmuc=' . $_GET['danhmuc'] . '&loai=' . $_GET['get'] . '&tinh=' . $_GET['tinh'] . '&huyen=' . $_GET['huyen'] . '&dientich=' . $_GET['dientich'] . '&gia=' . $_GET['gia'] . '&huong=' . $_GET['huong']; $config['base_url'] = site_url($url); $config['total_rows'] = $estatesAll->result_count(); $config['per_page'] = $limit; $config['use_page_numbers'] = TRUE; $config['page_query_string'] = TRUE; $config['uri_segment'] = 2; $config['num_links'] = 2; $config['full_tag_open'] = '<div class="news-pagination">'; $config['full_tag_close'] = "</div>"; $config['first_link'] = FALSE; $config['first_tag_open'] = ''; $config['first_tag_close'] = ''; $config['last_link'] = FALSE; $config['last_tag_open'] = ''; $config['last_tag_close'] = ''; $config['next_link'] = '>'; $config['next_tag_open'] = ''; $config['next_tag_close'] = ''; $config['prev_link'] = '<'; $config['prev_tag_open'] = ''; $config['prev_tag_close'] = ''; $config['num_tag_open'] = ''; $config['num_tag_close'] = ''; $config['cur_tag_open'] = '<span class="active">'; $config['cur_tag_close'] = '</span>'; $this->pagination->initialize($config); $this->page_title = ""; if ($estatecatalogue_id != 0) { $estatetype = new Estatetype($estatetype_id); $this->page_title .= $estatetype->name; } if ($estatecity_id != 0) { $estatecity = new Estatecity($estatecity_id); $this->page_title = $this->page_title . ', ' . $estatecity->name; } if ($estatedistrict_id != 0) { $estatedistrict = new Estatedistrict($estatedistrict_id); $this->page_title = $this->page_title . ', ' . $estatedistrict->name; } if ($estatearea_id != 0) { $estatearea = new Estatearea($estatearea_id); $this->page_title = $this->page_title . ', ' . $estatearea->label; } if ($estateprice_id != 0) { $estateprice = new Estateprice($estateprice_id); $this->page_title = $this->page_title . ', ' . $estateprice->label; } $dis['base_url'] = base_url(); $dis['view'] = 'front/estates/search'; $this->viewfront($dis); }
function listEstates($user_id) { $estateuser = new Estateuser($user_id); $estates = new Estate(); $estates->where('estateuser_id', $user_id); $estates->order_by('created', 'desc'); $estates->get_iterated(); $dis['estates'] = $estates; $dis['estateuser'] = $estateuser; $dis['base_url'] = base_url(); $dis['view'] = 'estateuser/list_by_user'; $dis['menu_active'] = "Thành viên"; $dis['title'] = 'Danh sách các Tin bất động sản của "' . $estateuser->firstname . ' ' . $estateuser->name . '"'; $dis['title_table'] = "Trang hiện tại:" . $estates->paged->current_page . '/' . $estates->paged->total_pages; $this->viewadmin($dis); }
function index($offset = 0, $limit = 800) { $estates = new Estate(); $estates->where('isFree', 0); $estates->order_by('id', 'desc'); $estates->get_paged($offset, $limit, TRUE); $xmlFile = "mitula_feed_" . $offset . "_" . $limit . ".xml"; $xmlFile = $_SERVER['DOCUMENT_ROOT'] . '/feeds/' . $xmlFile; //$f = fopen($xmlFile, 'w'); //create the xml document $xmlDoc = new DOMDocument('1.0', 'UTF-8'); $root = $xmlDoc->createElement('Mitula'); $xmlDoc->appendChild($root); foreach ($estates as $row) { $ad = $xmlDoc->createElement('ad'); // create id for ad $id = $xmlDoc->createElement('id'); $id->appendChild($xmlDoc->createCDATASection($row->code)); // create url for ad $url = $xmlDoc->createElement('name'); $url->appendChild($xmlDoc->createCDATASection(base_url() . $row->estatecatalogue->name_none . '/' . $row->estatecity->name_none . '/' . $row->title_none . '.html')); // create title for ad $title = $xmlDoc->createElement('title'); $title->appendChild($xmlDoc->createCDATASection($row->title)); // create type for ad $type = $xmlDoc->createElement('type'); $type->appendChild($xmlDoc->createCDATASection($row->estatetype->name)); // create content for ad $content = $xmlDoc->createElement('content'); $content->appendChild($xmlDoc->createCDATASection($row->description)); // create price for ad $price = $xmlDoc->createElement('price'); $period = $xmlDoc->createAttribute('period'); $period->value = 'monthly'; $price->appendChild($period); $price->appendChild($xmlDoc->createCDATASection($row->price_text . ' ' . getpricetype($row->price_type))); // create floor_area for ad $floor_area = $xmlDoc->createElement('floor_area'); $floor_area->appendChild($xmlDoc->createCDATASection($row->area_text . ' m2')); // create city for ad $city = $xmlDoc->createElement('city'); $city->appendChild($xmlDoc->createCDATASection($row->estatecity->name)); // create address for ad $address = $xmlDoc->createElement('address'); $address->appendChild($xmlDoc->createCDATASection($row->address)); $photos = new Estate_photo(); $photos->where('estate_id', $row->id); $photos->get(); if ($row->photo != null || $photos->result_count() > 0) { $pictures = $xmlDoc->createElement('pictures'); $picture = $xmlDoc->createElement('picture'); $pictureTitle = $xmlDoc->createElement('picture_title'); $pictureTitle->appendChild($xmlDoc->createCDATASection($row->title)); $pictureUrl = $xmlDoc->createElement('picture_url'); $pictureUrl->appendChild($xmlDoc->createCDATASection(image($row->photo, 'slide_580_380'))); $picture->appendChild($pictureUrl); $picture->appendChild($pictureTitle); if ($photos->result_count() > 0) { foreach ($photos as $photo) { $rowPhoto = new Estate_photo($photo->id); $picture = $xmlDoc->createElement('picture'); $pictureTitle = $xmlDoc->createElement('picture_title'); $pictureTitle->appendChild($xmlDoc->createCDATASection($row->title)); $pictureUrl = $xmlDoc->createElement('picture_url'); $pictureUrl->appendChild($xmlDoc->createCDATASection(image($rowPhoto->name, 'slide_580_380'))); $picture->appendChild($pictureUrl); $picture->appendChild($pictureTitle); $pictures->appendChild($picture); } } $pictures->appendChild($picture); } $ad->appendChild($id); $ad->appendChild($url); $ad->appendChild($title); $ad->appendChild($type); $ad->appendChild($content); $ad->appendChild($price); $ad->appendChild($floor_area); $ad->appendChild($city); $ad->appendChild($address); $ad->appendChild($pictures); $root->appendChild($ad); } //make the output pretty $xmlDoc->formatOutput = true; // Flush XML from memory to file in one go $result = file_put_contents($xmlFile, $xmlDoc->saveXML()) or print_r(error_get_last()); if ($result == false) { echo "Error"; } else { echo $xmlFile . " All good, {$result} bytes written"; } die; }
function searchFree($params) { $this->load->library('pagination'); parse_str(array_pop(explode('?', $_SERVER['REQUEST_URI'], 2)), $_GET); $limit = 50; $offset = $_GET['per_page'] == "" ? 0 : $_GET['per_page']; $estates = new Estate(); $estates->where('isFree', 1); $estates->order_by('id', 'desc'); if ($_GET['searchKey'] != "" && isset($_GET['searchKey'])) { $estates->like('code', $_GET['searchKey']); } if ($_GET['estatecatalogue_id'] != "" && isset($_GET['estatecatalogue_id'])) { $estates->where('estatecatalogue_id', $_GET['estatecatalogue_id']); } if ($_GET['estatetype_id'] != "" && isset($_GET['estatetype_id'])) { $estates->where('estatetype_id', $_GET['estatetype_id']); } if ($_GET['estateprice_id'] != "" && isset($_GET['estateprice_id'])) { $estates->where('estateprice_id', $_GET['estateprice_id']); } if ($_GET['estatearea_id'] != "" && isset($_GET['estatearea_id'])) { $estates->where('estatearea_id', $_GET['estatearea_id']); } if ($_GET['isReals'] != "" && isset($_GET['isReals'])) { if ($_GET['isReals'] != -1) { $estates->where('isReals', $_GET['isReals']); } } $estates->get_paged($offset, $limit, TRUE); // get all estate search $estatesAll = new Estate(); $estatesAll->where('isFree', 1); $estatesAll->order_by('id', 'desc'); if ($_GET['searchKey'] != "" && isset($_GET['searchKey'])) { $estatesAll->like('code', $_GET['searchKey']); } if ($_GET['estatecatalogue_id'] != "" && isset($_GET['estatecatalogue_id'])) { $estatesAll->where('estatecatalogue_id', $_GET['estatecatalogue_id']); } if ($_GET['estatetype_id'] != "" && isset($_GET['estatetype_id'])) { $estatesAll->where('estatetype_id', $_GET['estatetype_id']); } if ($_GET['estateprice_id'] != "" && isset($_GET['estateprice_id'])) { $estatesAll->where('estateprice_id', $_GET['estateprice_id']); } if ($_GET['estatearea_id'] != "" && isset($_GET['estatearea_id'])) { $estatesAll->where('estatearea_id', $_GET['estatearea_id']); } if ($_GET['isReals'] != "" && isset($_GET['isReals'])) { if ($_GET['isReals'] != -1) { $estatesAll->where('isReals', $_GET['isReals']); } } $estatesAll->get_iterated(); $url = $_SERVER['REQUEST_URI']; $config['base_url'] = $url; $config['total_rows'] = $estatesAll->result_count(); $config['per_page'] = $limit; $config['page_query_string'] = TRUE; $this->pagination->initialize($config); $estateareas = new Estatearea(); $estateareas->order_by('position', 'asc'); $estateareas->get_iterated(); $dis['estateareas'] = $estateareas; $estateusers = new Estateuser(); $estateusers->order_by('name', 'asc'); $estateusers->get_iterated(); $dis['estateusers'] = $estateusers; $dis['estates'] = $estates; $dis['page_i'] = $offset; $dis['base_url'] = base_url(); $dis['view'] = 'estate/searchFree'; $dis['menu_active'] = 'Tin bất động sản (miễn phí)'; $dis['title'] = "Tìm kiếm bất động sản"; $this->viewadmin($dis); }