Example #1
0
 function max_id()
 {
     $max = new Estate();
     $max->select_max('id');
     $max->get();
     return $max->id;
 }
Example #2
0
 public function run()
 {
     $faker = Faker::create();
     $count = 50;
     $ids = Estate::lists('estate_id');
     $images = read_dir(dir_path('estates'));
     $images = array_values(array_diff($images, ['alien.png']));
     for ($i = 0; $i < $count; $i++) {
         Image::create(['image' => $images[$i], 'estate_id' => $faker->randomElement($ids), 'preview' => $faker->boolean(30)]);
     }
 }
Example #3
0
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();
}
Example #4
0
function filters()
{
    $filter_types = ['type' => 'type', 'commercial' => 'type', 'sea_dist' => 'range', 'price' => 'range', 'district_id' => 'type', 'town_id' => 'type', 'house_area' => 'range', 'rooms' => 'range', 'yard_area' => 'range', 'period' => 'type', 'pool' => 'check', 'producer' => 'list'];
    $take = 10;
    $sort = 'title';
    $order = 'asc';
    $filters = 'house_area=120;380&district_id=2&town_id=3&pool=bool&producer=[asus;acer;lenovo;toshiba;sony]&price=10000;160000&yard_area=100;800&commercial=rent&period=daily&type=cottage&rooms=3;7';
    // $query = Estate::join('districts', 'estates.district_id', '=', 'districts.district_id')->join('towns', 'towns.town_id', '=', 'districts.town_id'); // get Illuminate\Database\Eloquent\Builder
    $query = Estate::joined();
    // get Illuminate\Database\Eloquent\Builder
    $query = apply_filters($query, $filters);
    // $query = Filter::apply($query, $filters);
    $query = $query->orderBy($sort, $order);
    try {
        $estates = $query->skip($skip)->take($take)->get();
    } catch (Exception $e) {
        return redirect()->back();
    }
}
Example #5
0
 public function searchAction($keyword)
 {
     $terms = explode(" ", $keyword);
     $termCounter = 0;
     $conditions = '';
     $bind = array();
     foreach ($terms as $term) {
         if ($conditions != '') {
             $conditions .= ' AND ';
         }
         $termCounter++;
         $conditions .= ' (name like ?' . $termCounter . ' OR builder like ?' . $termCounter . ') ';
         $bind[$termCounter] = '%' . $term . '%';
     }
     $data = Estate::find(array('conditions' => $conditions, 'bind' => $bind, 'limit' => 15));
     $json = array();
     foreach ($data as $row) {
         $json[] = $row->getDataAsArray();
     }
     echo json_encode($json);
 }
Example #6
0
 function tagsDangTin($url)
 {
     $title = geturlfromuri($this->uri->segment(2));
     $tags = explode('-', $title);
     $title = implode(' ', $tags);
     $estates = new Estate();
     $estates->order_by('created', 'desc');
     $estates->group_start();
     $estates->like('tag_search', '%' . $title . '%');
     $estates->group_end();
     $estates->get();
     $dis['estates'] = $estates;
     // seo
     $this->page_title = $title . ' | ' . $this->page_title;
     $this->page_description = "Có " . $estates->result_count() . " kết quả tìm kiếm với từ khóa " . $title . ' | ' . $this->page_description;
     $this->page_keyword = $this->page_keyword;
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/estates/tags';
     $this->viewfront($dis);
 }
Example #7
0
 function tagsDangTin($url)
 {
     $url = $this->uri->segment(2, "");
     $arrUrl = explode('.', $url);
     $title = $arrUrl[0];
     $query_string = explode($arrUrl[0] . '.html&', $this->uri->segment(2, ""));
     parse_str($query_string[1], $_GET);
     $this->load->library('pagination');
     $limit = 20;
     $page = $_GET['per_page'] == "" ? 1 : $_GET['per_page'];
     $offset = ($page - 1) * $limit;
     $tags = explode('-', $title);
     $title = implode(' ', $tags);
     $estates = new Estate();
     $estates->order_by('isVip', 'desc');
     $estates->order_by('created', 'desc');
     $estates->group_start();
     $estates->like('tag_search', '%' . $title . '%');
     $estates->group_end();
     $estates->get_paged($offset, $limit, TRUE);
     $dis['estates'] = $estates;
     $estatesAll = new Estate();
     $estatesAll->order_by('isVip', 'desc');
     $estatesAll->order_by('created', 'desc');
     $estatesAll->group_start();
     $estatesAll->like('tag_search', '%' . $title . '%');
     $estatesAll->group_end();
     $estatesAll->get_iterated();
     $url = base_url() . $this->uri->segment(1) . '/' . $arrUrl[0] . '.html';
     $config['base_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);
     // support seo
     $this->page_title = 'Thông tin ' . $title . ' mới nhất';
     $this->page_description = $title . ' với đầy đủ thông tin giá, hình ảnh, hướng, vị trí...cập nhật nhất';
     $keyword = explode(' ', $this->page_title);
     $this->page_keyword = implode(',', $keyword);
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/estates/tags';
     $this->viewfront($dis);
 }
Example #8
0
 function deletePhotoDefault($estateID)
 {
     $estate = new Estate($estateID);
     // remove image from folder.
     $pathImageDefault = $_SERVER['DOCUMENT_ROOT'] . '/' . $estate->photo;
     unlink($pathImageDefault);
     // set image to default.
     $estate->photo = "";
     if ($estate->save()) {
         flash_message('success', 'Hình ảnh đại diện đã được xóa khỏi tin nhà đất');
         redirect(base_url() . 'chinh-sua-tin/' . $estateID);
     } else {
         flash_message('error', 'Đã có lỗi xãy ra !');
         redirect(base_url() . 'chinh-sua-tin/' . $estateID);
     }
 }
Example #9
0
 public function postFree()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $o = new Estate();
         $o->estatecity_id = $this->input->post('estatecity_id');
         $o->estatedistrict_id = $this->input->post('estatedistrict_id');
         $o->estatedirection_id = $this->input->post('estatedirection_id');
         $o->estatecatalogue_id = $this->input->post('estatecatalogue_id');
         $o->estatetype_id = $this->input->post('estatetype_id');
         $o->estatearea_id = $this->input->post('estatearea_id');
         $o->estateprice_id = $this->input->post('estateprice_id');
         $o->estateward_id = $this->input->post('estateward_id');
         $o->address = $this->input->post('address');
         $o->isArea = $this->input->post('IsArea');
         $o->area = $this->input->post('area');
         $o->legally = $this->input->post('legally');
         $o->isPrice = $this->input->post('IsPrice');
         $o->price_text = $this->input->post('price_text');
         $o->estatedirection_id = $this->input->post('estatedirection_id');
         $o->estateuser_id = $this->session->userdata('userLoginId');
         $o->title = ucfirst($this->input->post('title'));
         $o->description = $this->input->post('description');
         $o->price_text = $this->input->post('price_text');
         $o->area_text = $this->input->post('area_text');
         if ($o->estatecatalogue_id == 1) {
             $o->price_type = $this->input->post('price_type');
         } else {
             $o->price_type = $this->input->post('price_type_2');
         }
         $o->name_contact = $this->input->post('name_contact');
         $o->address_contact = $this->input->post('address_contact');
         $o->phone_contact = $this->input->post('phone_contact');
         $o->mobile_contact = $this->input->post('mobile_contact');
         $o->email_contact = $this->input->post('email_contact');
         $o->isFree = 1;
         $o->active = 1;
         $o->code = $this->add_code(7, $o->max_id() + 1, $o->estatecatalogue_id);
         $o->title_none = remove_vn($this->input->post('title')) . $o->code;
         if ($this->securimage->check($_POST['captcha_code']) == false) {
             $msg = '<div class="frm-error error-capcha">Vui lòng nhập đúng mã xác nhận !</div>';
             $type = 0;
         } else {
             $folder = 'img/project/';
             $dataupload = $this->file_lib->upload('image', $folder, $rename_file = true);
             if (!is_array($dataupload)) {
                 $o->photo = '';
             } else {
                 $o->photo = $folder . $dataupload['file_name'];
             }
             if ($o->save()) {
                 $msg = '<div class="frm-success">Cảm ơn Bạn! Tin của Bạn đã được gửi đến Chúng tôi thành công. Thông thường sau 30 phút, tin sẽ được kích hoạt<br /><br />Bạn chưa đăng ký thành viên nên Chúng tôi sẽ kiểm duyệt tin đăng của Bạn trước khi hiển thị. Bạn không thể sửa/xóa tin đăng này. Để thuận tiện hơn, Bạn có thể <a style="color: #018e07;font-weight: bolder;" href="' . base_url() . 'dang-ky' . '">đăng ký thành viên</a> - Tin đăng được hiển thị ngay và nhận nhiều hỗ trợ từ Chúng tôi! <br/><br/>  Hoặc, Bạn có thể tiếp tục <a style="color: #018e07;font-weight: bolder;" href="' . base_url() . 'dang-tin-rao-vat-nha-dat-mien-phi' . '">đăng tin rao vặt miễn phí</a>!</div>';
                 $type = 1;
                 /*Upload list images for estates*/
                 $numfile = $this->input->post('numfile');
                 foreach ($numfile as $row) {
                     $dataupload = $this->file_lib->upload('image' . $row, $folder);
                     if (is_array($dataupload)) {
                         $estate_photos = new Estate_photo();
                         $estate_photos->estate_id = $o->id;
                         $estate_photos->name = $folder . $dataupload['file_name'];
                         $estate_photos->save();
                         $estate_photos->clear();
                     }
                 }
             }
         }
     }
     $dis['msg'] = $msg;
     $dis['type'] = $type;
     $dis['o'] = $o;
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/estates/post-free';
     $this->page_title = "Đăng tin rao vặt nhà đất | rao vặt bất động sản | SotayNhadat.vn";
     $this->page_description = "Đăng tin rao vặt nhà đất, căn hộ, đất nền, biệt thự...không cần đăng ký thành viên tại SotayNhadat.vn. Giúp Bạn giao dịch nhà đất đơn giản, nhanh chóng hơn!";
     $this->viewfront($dis);
 }
Example #10
0
 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);
 }
Example #11
0
 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;
 }
Example #12
0
 function deletePhotoDefault($estateID, $isFree = false)
 {
     $estate = new Estate($estateID);
     // remove image from folder.
     $pathImageDefault = $_SERVER['DOCUMENT_ROOT'] . '/' . $estate->photo;
     unlink($pathImageDefault);
     // set image to default.
     $estate->photo = "";
     if ($estate->save()) {
         flash_message('success', 'Hình ảnh đại diện đã được xóa khỏi tin nhà đất');
         if (!$isFree) {
             redirect($this->admin . 'estates/edit/' . $estateID);
         } else {
             redirect($this->admin . 'estates/editFree/' . $estateID);
         }
     } else {
         flash_message('error', 'Đã có lỗi xãy ra !');
         if (!$isFree) {
             redirect($this->admin . 'estates/edit/' . $estateID);
         } else {
             redirect($this->admin . 'estates/editFree/' . $estateID);
         }
     }
 }
Example #13
0
<?php

$url = "../index.php?mod=estate_type&act=list";
require_once "../model/Estate.php";
$model = new Estate();
$estate_type_id = (int) $_POST['estate_type_id'];
$estate_type_name = $model->processData($_POST['estate_type_name']);
$estate_alias = $model->changeTitle($estate_type_name);
if ($estate_type_id > 0) {
    $model->updateEstate($estate_type_id, $estate_type_name, $estate_alias);
    header('location:' . $url);
} else {
    $model->insertEstate($estate_type_name, $estate_alias);
    header('location:' . $url);
}