Example #1
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists()) {
         $o = new Estatedistrict();
         $o->select_max('position');
         $o->get();
         if (count($o->all) != 0) {
             $max = $o->position + 1;
             $this->position = $max;
         } else {
             $this->postion = 1;
         }
     }
     return parent::save($object, $related_field);
 }
Example #2
0
 function getDistrict()
 {
     $provincesId = $this->input->post('provincesId');
     $districts = new Estatedistrict();
     $districts->where('estatecity_id', $provincesId);
     $districts->order_by('position', 'asc');
     $districts->get();
     $option = '<option value="">Chọn Quận/Huyện</option>';
     foreach ($districts as $row) {
         if ($row->id == $this->input->post('districtSelected')) {
             $option .= '<option selected="selected" value=' . $row->id . '>' . $row->name . '</option>';
         } else {
             $option .= '<option value=' . $row->id . '>' . $row->name . '</option>';
         }
     }
     echo $option;
     die;
 }
Example #3
0
 function getEstateByAddress()
 {
     $cityUrl = $this->uri->segment(2, '');
     $districtUrl = $this->uri->segment(3, '');
     $city = new Estatecity();
     $city->where('name_none', $cityUrl)->get();
     if (!$city->exists()) {
         show_404();
     }
     $district = new Estatedistrict();
     $district->where('name_none', $districtUrl)->get();
     if (!$district->exists()) {
         show_404();
     }
     $dis['district'] = $district;
     /*get estates by category and type*/
     $estates = new Estate();
     $estates->order_by('isVip', 'desc');
     $estates->order_by('created', 'desc');
     $estates->where('estatedistrict_id', $district->id);
     $estates->where('isVip', 0);
     $estates->get_iterated();
     $dis['estates'] = $estates;
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/estates/by_address';
     $this->viewfront($dis);
 }
Example #4
0
 function staticByPrices()
 {
     $url_type = $this->uri->segment(2);
     $cat_type = new Estatetype();
     $cat_type->where('name_none', $url_type)->get();
     $dis['cat_type'] = $cat_type;
     $url_district = $this->uri->segment(3);
     $cat_districts = new Estatedistrict();
     $cat_districts->where('name_none', $url_district)->get();
     $dis['cat_districts'] = $cat_districts;
     $url_price = $this->uri->segment(4);
     $cat_price = new Estateprice();
     $cat_price->where('url', $url_price)->get();
     $dis['cat_price'] = $cat_price;
     $level = 4;
     $page = $this->uri->segment($level + 1, "") == "" ? 1 : $this->uri->segment($level + 1);
     $dis['page'] = $page;
     $limit = 20;
     $offset = ($page - 1) * $limit;
     /*get page estate*/
     $estates = new Estate();
     $estates->order_by('isVip', 'desc');
     $estates->order_by('created', 'desc');
     $estates->where_related_estatetype('name_none', $url_type);
     $estates->where_related_estatedistrict('name_none', $url_district);
     $estates->where_related_estateprice('url', $url_price);
     $estates->get_paged($offset, $limit, TRUE);
     $dis['estates'] = $estates;
     /*get all estate*/
     $estates = new Estate();
     $estates->order_by('isVip', 'desc');
     $estates->order_by('created', 'desc');
     $estates->where_related_estatetype('name_none', $url_type);
     $estates->where_related_estatedistrict('name_none', $url_district);
     $estates->where_related_estateprice('url', $url_price);
     $estates->get();
     $total = $estates->result_count();
     /*Begin pagination for product*/
     $url = 'thong-ke-theo-muc-gia/' . $url_type . '/' . $url_district . '/' . $url_price;
     $config['base_url'] = site_url($url);
     $config['total_rows'] = $total;
     $config['per_page'] = $limit;
     $config['use_page_numbers'] = TRUE;
     $config['uri_segment'] = 5;
     $config['num_links'] = 5;
     $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);
     /*End pagination for product*/
     $this->page_title = $cat_type->name . ' tại ' . $cat_districts->name . ' giá từ ' . $cat_price->label . ' | ' . $cat_type->name . ' tại ' . $cat_districts->name;
     $this->page_description = $cat_type->name . ' tại ' . $cat_districts->name . ' giá từ ' . $cat_price->label . ' với đầy đủ hình ảnh, hướng, vị trí khác nhau... để bạn lựa chọn. ' . 'Thông tin ' . $cat_type->name . ' tại ' . $cat_districts->name . ' cập nhật nhất!';
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/estates/by-prices';
     $this->viewfront($dis);
 }
Example #5
0
 function delete()
 {
     $id = $this->uri->segment(4);
     $district = new Estatedistrict($id);
     //delete city
     $district->delete();
     flash_message('success', 'Xóa Quận/Huyện thành công.');
     //redirect to city
     redirect($this->admin . 'estatedistricts/list_all');
 }
Example #6
0
 function editFree($id = 0)
 {
     $estate = new estate($id);
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $this->load->helper('remove_vn_helper');
         $this->load->library('file_lib');
         $estate->estatecity_id = $this->input->post('estatecity_id');
         $estate->estatedistrict_id = $this->input->post('estatedistrict_id');
         $estate->estateward_id = $this->input->post('estateward_id');
         $estate->estatedirection_id = $this->input->post('estatedirection_id');
         $estate->estatecatalogue_id = $this->input->post('estatecatalogue_id');
         $estate->estatetype_id = $this->input->post('estatetype_id');
         $estate->estatearea_id = $this->input->post('estatearea_id');
         $estate->estateprice_id = $this->input->post('estateprice_id');
         $estate->address = $this->input->post('address');
         $estate->isArea = $this->input->post('IsArea');
         $estate->area = $this->input->post('area');
         $estate->legally = $this->input->post('legally');
         $estate->isPrice = $this->input->post('IsPrice');
         $estate->price_text = $this->input->post('price_text');
         $estate->estatedirection_id = $this->input->post('estatedirection_id');
         $estate->title = $this->input->post('title');
         $estate->description = $this->input->post('description');
         $estate->price_text = $this->input->post('price_text');
         $estate->area_text = $this->input->post('area_text');
         $estate->article_id = $this->input->post('article_id');
         $estate->price_type = $this->input->post('price_type');
         if ($estate->isVip == 0) {
             $estate->updateTime = date('Y-m-d H:i:s');
         } else {
             $estate->created = $estate->created;
             $estate->updated = $estate->updated;
             $estate->updateTime = date('Y-m-d H:i:s');
         }
         $estate->name_contact = $this->input->post('name_contact');
         $estate->address_contact = $this->input->post('address_contact');
         $estate->phone_contact = $this->input->post('phone_contact');
         $estate->mobile_contact = $this->input->post('mobile_contact');
         $estate->email_contact = $this->input->post('email_contact');
         $estate->tag = $this->input->post('tag');
         $tags = remove_vn($this->input->post('tag') . ' ' . $this->input->post('title'));
         $tags = explode('-', $tags);
         $estate->tag_search = implode(' ', $tags);
         $estate->title_none = remove_vn($this->input->post('title')) . $estate->code;
         // Change images default
         if ($_FILES['image']['name'] != "") {
             $folder = 'img/project/';
             $dataupload = $this->file_lib->upload('image', $folder, $rename_file = true);
             if (!is_array($dataupload)) {
                 flash_message('error', $dataupload);
                 $estate->photo = '';
             } else {
                 $estate->photo = $folder . $dataupload['file_name'];
             }
         }
         if ($estate->save()) {
             flash_message('success', 'Bản tin đã được thay đổi thành công.');
             redirect($this->admin_url . 'estates/listFree/');
             //redirect($this->admin_url.'estates/editFree/'.$estate->id);
         } else {
             flash_message('error', 'Đã có lỗi xãy ra !');
             //redirect($this->admin_url.'estates/listFree/');
             redirect($this->admin_url . 'estates/editFree/' . $estate->id);
         }
     }
     $estateCategory = new Estatecatalogue();
     $estateCategory->get_iterated();
     $dis['estateCategory'] = $estateCategory;
     $estateType = new Estatetype();
     $estateType->order_by('id');
     $estateType->where('estatecatalogue_id', $estate->estatecatalogue_id);
     $estateType->get_iterated();
     $dis['estateType'] = $estateType;
     $estateAreas = new Estatearea();
     $estateAreas->order_by('position');
     $estateAreas->get_iterated();
     $dis['estateAreas'] = $estateAreas;
     $estateDirection = new Estatedirection();
     $estateDirection->order_by('id');
     $estateDirection->get_iterated();
     $dis['estateDirection'] = $estateDirection;
     $estatePrices = new Estateprice();
     $estatePrices->where('estatecatalogue_id', $estate->estatecatalogue_id);
     $estatePrices->order_by('position', 'asc');
     $estatePrices->get_iterated();
     $dis['estatePrices'] = $estatePrices;
     $estateCities = new Estatecity();
     $estateCities->order_by('id');
     $estateCities->get_iterated();
     $dis['estateCities'] = $estateCities;
     $estateDictricts = new Estatedistrict();
     $estateDictricts->where('estatecity_id', $estate->estatecity_id);
     $estateDictricts->order_by('position', 'asc');
     $estateDictricts->get_iterated();
     $dis['estateDictricts'] = $estateDictricts;
     $estateWards = new Estateward();
     $estateWards->where('estatedistrict_id', $estate->estatedistrict_id);
     $estateWards->order_by('position');
     $estateWards->get_iterated();
     $dis['estateWards'] = $estateWards;
     $project = new Article();
     $project->where('recycle', 0);
     $project->where('estatecity_id', $estate->estatecity_id);
     $project->order_by('title_vietnamese', 'asc');
     $project->get_iterated();
     $dis['project'] = $project;
     $dis['object'] = $estate;
     $dis['base_url'] = base_url();
     $dis['view'] = 'estate/edit_free';
     $dis['menu_active'] = 'Tin bất động sản (miễn phí)';
     $dis['title'] = "Thêm/Sửa Tin '" . $estate->title . "'";
     $dis['nav_menu'] = array(array("type" => "back", "text" => "Quay về", "link" => "{$this->admin_url}estates/listFree", "onclick" => ""));
     $this->viewadmin($dis);
 }