예제 #1
0
파일: home.php 프로젝트: lxthien/batdongsan
 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);
 }
예제 #2
0
 function delete()
 {
     $id = $this->uri->segment(4);
     $city = new Estatecity($id);
     //delete city
     if (count($city->estatedistrict->all) > 0) {
         flash_message('error', 'Không thể xóa Thành phố/Tỉnh, vui lòng xóa Quận/Huyện trước');
     } else {
         $city->delete();
         flash_message('success', 'Xóa Thành phố/Tỉnh thành công');
     }
     //redirect to city
     redirect($this->admin . 'estatecitys/list_all');
 }
예제 #3
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists()) {
         $o = new Estatecity();
         $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);
 }
예제 #4
0
 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);
 }
예제 #5
0
 function isolate_edit($catalogue_id = 0, $news_id = 0)
 {
     $newscatalogue = new newscatalogue($catalogue_id);
     if (!$newscatalogue->exists()) {
         show_404();
     }
     $news = new article($news_id);
     if ($_SERVER['REQUEST_METHOD'] == "GET") {
         if (!$news->exists()) {
             $news->newscatalogue_id = $catalogue_id;
             $news->dir = getconfigkey("default_news_dir");
         }
     } else {
         $this->load->helper('remove_vn_helper');
         $this->load->library('file_lib');
         $news->title_vietnamese = $this->input->post('title_vietnamese');
         $news->title_english = $this->input->post('title_english');
         $news->title_japanese = $this->input->post('title_japanese');
         $news->title_none = remove_vn($news->title_vietnamese);
         $news->estatecity_id = $this->input->post('estatecity_id');
         $news->estatedistrict_id = $this->input->post('estatedistrict_id');
         $news->estatetype_id = $this->input->post('estatetype_id');
         $news->equity = $this->input->post('equity');
         $news->timeStart = $this->input->post('timeStart');
         $news->timeCompleted = $this->input->post('timeCompleted');
         $news->investors = $this->input->post('investors');
         $news->short_vietnamese = $this->input->post('short_vietnamese');
         $news->short_english = $this->input->post('short_english');
         $news->full_vietnamese = $this->input->post('txtFull_vietnamese');
         $news->full_english = $this->input->post('txtFull_english');
         $news->full_japanese = $this->input->post('txtFull_japanese');
         $news->hot = $this->input->post('hot');
         $news->hotHome = $this->input->post('hotHome');
         $news->source = $this->input->post('source');
         $news->tag = $this->input->post('tag');
         $news->dir = $this->input->post('dir');
         $new_image = $this->input->post('newimage');
         $news->pagi = $this->input->post('pagi');
         $tags = remove_vn($this->input->post('tag') . ' ' . $this->input->post('title_vietnamese') . ' ' . $this->input->post('short_vietnamese'));
         $tags = explode('-', $tags);
         $news->tag_search = implode(' ', $tags);
         if ($_FILES['image']['name'] != "") {
             $dataupload = $this->file_lib->upload('image', $news->dir);
             if (!is_array($dataupload)) {
                 flash_message('error', $dataupload);
             } else {
                 $news->image = $dataupload['file_name'];
             }
         }
         //newstopic
         $newstp = new newstopic($this->input->post('newstopic'));
         $newsc = new newscatalogue($this->input->post('newscatalogue'));
         $isnews = $news->exists();
         if (!$news->exists()) {
             $news->active = 1;
         }
         if ($news->save(array($newsc, $newstp))) {
             // save photo for image
             $filePath = 'img/news/';
             $numfile = $this->input->post('numfile');
             foreach ($numfile as $row) {
                 $dataupload = $this->file_lib->upload('image' . $row, $filePath);
                 if (is_array($dataupload)) {
                     $newsphotos = new newsphoto();
                     $newsphotos->article_id = $news_id;
                     $newsphotos->image = $filePath . $dataupload['file_name'];
                     $newsphotos->name = $this->input->post('name' . $row);
                     $newsphotos->save();
                     $newsphotos->clear();
                     flash_message('success', $dataupload['file_name'] . ' đã được thêm.');
                 }
             }
             $this->session->unset_userdata('dir_for_news');
             if ($isnews) {
                 flash_message("success", "Cập nhật thành công");
             } else {
                 flash_message("success", "Thêm mới thành công");
             }
             if ($news->navigation != "") {
                 $this->session->set_userdata(array(config_item('session_admin') . 'menu_current' => $newscatalogue->navigation));
                 if (empty($newscatalogue->menu_active)) {
                     $dis['menu_active'] = "Danh sách bài viết";
                 } else {
                     $dis['menu_active'] = $newscatalogue->menu_active;
                 }
             } else {
                 $this->session->set_userdata(array(config_item('session_admin') . 'menu_current' => $news->navigation));
                 if (empty($newscatalogue->menu_active)) {
                     $dis['menu_active'] = "Danh sách bài viết";
                 } else {
                     $dis['menu_active'] = $news->title_vietnamese;
                 }
             }
             redirect($this->admin . 'cnews/isolate_edit/' . $news->newscatalogue->id . '/' . $news->id);
         } else {
             flash_message("error", "Lỗi");
         }
     }
     // get all province
     $estatecity = new Estatecity();
     $estatecity->order_by('position', 'asc');
     $estatecity->get_iterated();
     $dis['estatecity'] = $estatecity;
     // get all province
     $estatecate = new Estatecatalogue();
     $estatecate->order_by('position', 'asc');
     $estatecate->get_iterated();
     $dis['estatecate'] = $estatecate;
     $newscat = new newscatalogue();
     $newscat->where('parentcat_id !=', 'NULL');
     $newscat->where('parentcat_id', $newscatalogue->parentcat_id);
     $newscat->order_by('position', 'asc');
     $newscat->get();
     $newstopic = new newstopic();
     $newstopic->order_by('id', 'desc');
     $newstopic->get();
     $sitelanguage = new Sitelanguage();
     $sitelanguage->order_by('position', 'asc');
     $sitelanguage->get();
     $dis['sitelanguage'] = $sitelanguage;
     $dis['newstopic'] = $newstopic;
     $dis['base_url'] = base_url();
     $dis['newscatalogue'] = $newscat;
     $dis['currentcatalogue'] = $newscatalogue;
     $dis['title'] = "Thêm/ Sửa tin tức";
     $dis['menu_active'] = "Danh sách bài viết";
     //specific view for catelogue name "gia pha toan toc" , id =39
     if ($catalogue_id == 39) {
         $dis['view'] = "news/isolate_full_hirarchy_edit";
     } else {
         $dis['view'] = "news/isolate_edit";
     }
     $dis['object'] = $news;
     $dis['nav_menu'] = array(array("type" => "back", "text" => "Back", "link" => "{$this->admin_url}cnews/isolate_list_by_cat/" . $catalogue_id, "onclick" => ""));
     if ($news->exists()) {
         if (!empty($news->navigation)) {
             $this->session->set_userdata(array(config_item('session_admin') . 'menu_current' => $news->navigation));
             $dis['menu_active'] = $news->title_vietnamese;
         } else {
             $this->session->set_userdata(array(config_item('session_admin') . 'menu_current' => $newscatalogue->navigation));
             if (empty($newscatalogue->menu_active)) {
                 $dis['menu_active'] = $newscatalogue->name_vietnamese;
             } else {
                 $dis['menu_active'] = $newscatalogue->menu_active;
             }
         }
     } else {
         $this->session->set_userdata(array(config_item('session_admin') . 'menu_current' => $newscatalogue->navigation));
         $dis['menu_active'] = $newscatalogue->name_vietnamese;
     }
     if ($this->logged_in_user->adminrole->id == 1) {
         array_push($dis['nav_menu'], array("type" => "copymove", "text" => "Copy/Move", "link" => "javascript:void(0);", "onclick" => "show_copy()"));
     }
     $this->viewadmin($dis);
 }
예제 #6
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);
 }
예제 #7
0
 function estateByTypeCity()
 {
     $typeUrl = $this->uri->segment(1, '');
     $cityUrl = $this->uri->segment(2, '');
     $type = new Estatetype();
     $type->where('name_none', $typeUrl)->get();
     if (!$type->exists()) {
         show_404();
     }
     $dis['type'] = $type;
     $city = new Estatecity();
     $city->where('name_none', $cityUrl)->get();
     if (!$city->exists()) {
         show_404();
     }
     $dis['city'] = $city;
     $level = 2;
     $page = $this->uri->segment($level + 1, "") == "" ? 1 : $this->uri->segment($level + 1);
     $dis['page'] = $page;
     $limit = 20;
     $offset = ($page - 1) * $limit;
     /*get estates by type and city*/
     $estates = new Estate();
     $estates->order_by('isVip', 'desc');
     $estates->order_by('created', 'desc');
     $estates->where('estatecity_id', $city->id);
     $estates->where('estatetype_id', $type->id);
     $estates->where(array('active' => 0, 'isFree' => 0));
     $estates->get_paged($offset, $limit, TRUE);
     $dis['estates'] = $estates;
     /*get estates by category and type*/
     $estatesAll = new Estate();
     $estatesAll->order_by('isVip', 'desc');
     $estatesAll->order_by('created', 'desc');
     $estatesAll->where('estatecity_id', $city->id);
     $estatesAll->where('estatetype_id', $type->id);
     $estatesAll->where(array('active' => 0, 'isFree' => 0));
     $estatesAll->get();
     $total = $estatesAll->result_count();
     /*Begin pagination for product*/
     $url = $this->uri->segment(1) . '/' . $this->uri->segment(2);
     $config['base_url'] = site_url($url);
     $config['total_rows'] = $total;
     $config['per_page'] = $limit;
     $config['use_page_numbers'] = TRUE;
     $config['uri_segment'] = 3;
     $config['num_links'] = 3;
     $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 = $type->name . ' ' . $city->name . ' | ' . $type->name . ' tại ' . $city->name;
     $this->page_description = $type->name . ' tại ' . $city->name . ' với nhiều mức giá, diện tích, hướng, vị trí khác nhau. ' . $type->name . ' ' . $city->name . ' 2015, 2016 mới nhất, cập nhật liên tục...';
     $keyword = explode(" ", $this->page_title);
     $this->page_keyword = str_replace('|,', '', implode(',', $keyword));
     $this->isRobotFollow = 3;
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/estates/by_type_and_city';
     $this->viewfront($dis);
 }
예제 #8
0
 function MY_Controller()
 {
     parent::Controller();
     $this->load->library('enum');
     $this->load->config('fireignition');
     $this->load->helper('language');
     $this->lang->load('site');
     $this->load->library('hit_counter');
     $this->load->library('FirePHP');
     if ($this->config->item('fireignition_enabled')) {
         if (floor(phpversion()) < 5) {
             log_message('error', 'PHP 5 is required to run fireignition');
         } else {
             $this->load->library('FirePHP');
         }
     } else {
         $this->load->library('Firephp_fake');
         $this->firephp =& $this->firephp_fake;
     }
     //redirect from old website
     $this->redirectList();
     $cauhinh = new cauhinh();
     $cauhinh->get();
     $this->cauhinh = $cauhinh;
     if ($this->uri->segment(1, "") == "admin") {
         $this->logged_in_user = $this->_get_user();
         $this->admin = $this->config->item('admin');
         $this->admin_url = $this->config->item('admin_url');
         $this->admin_images = base_url() . "images/admin/";
         //LOAD HELPER
         $this->load_admin_resource();
         //check maintenance admin , only webmaster can login
         $this->resetNewsViewMost();
     } else {
         //check login user
         //$this->flogged_in_user=$this->_fget_user();
         $this->isCache = true;
         $this->userLoginFlag = 0;
         $userLogin = $this->session->userdata('userLogin');
         $userToken = $this->session->userdata('userToken');
         $customer = new Customer();
         $customer->get_by_username($userLogin);
         if ($customer->exists() && md5($customer->id) == trim($userToken)) {
             $loginUsername = $customer->username;
             $this->customer = $customer;
             if ($this->session->userdata('userloginFlag') == "1") {
                 $this->userLoginFlag = 1;
                 $this->session->set_userdata('userloginFlag', "0");
             }
         } else {
             $loginUsername = "";
         }
         $this->loginUsername = $loginUsername;
         $this->loginUser = $customer;
         $this->page_title = getconfigkey("defaultPageTitle");
         $this->load->helper('language');
         $this->show_analytic = TRUE;
         $this->page_keyword = getconfigkey("defaultKeyword");
         $this->page_description = getconfigkey("defaultDescription");
         $this->isRobotFollow = true;
         //------------------------------------------------
         // get data handler
         //------------------------------------------------
         $listAllCat = array();
         $newsCate = new Newscatalogue();
         $newsCate->order_by('position');
         $newsCate->where(array('recycle' => 0, 'parentcat_id' => 58));
         $newsCate->get_iterated();
         $this->newsCate = $newsCate;
         foreach ($newsCate as $row) {
             array_push($listAllCat, $row->id);
         }
         /*Get all business cat*/
         $businessCat = new Newscatalogue();
         $businessCat->order_by('position');
         $businessCat->where(array('recycle' => 0, 'parentcat_id' => 91));
         $businessCat->get_iterated();
         $this->businessCat = $businessCat;
         $guideCate = new Newscatalogue();
         $guideCate->order_by('position');
         $guideCate->where(array('recycle' => 0, 'parentcat_id' => 76));
         $guideCate->get_iterated();
         $this->guideCate = $guideCate;
         foreach ($guideCate as $row) {
             array_push($listAllCat, $row->id);
         }
         $this->listAllCat = $listAllCat;
         $projectsCate = new Newscatalogue();
         $projectsCate->order_by('position');
         $projectsCate->where(array('recycle' => 0, 'parentcat_id' => 83));
         $projectsCate->get_iterated();
         $this->projectsCate = $projectsCate;
         $arrayCateNewsId = array();
         foreach ($this->projectsCate as $row) {
             $arrayCateNewsId[] = $row->id;
         }
         $this->arrCateProject = $arrayCateNewsId;
         // project hot
         $projectHot = new Article();
         $projectHot->where('recycle', 0);
         $projectHot->where('hot', 1);
         $projectHot->where_in('newscatalogue_id', $arrayCateNewsId);
         $projectHot->order_by('created', 'desc');
         $projectHot->get(3);
         $this->projectHot = $projectHot;
         //get all housesale
         $typeHouseSale = new Estatetype();
         $typeHouseSale->where('estatecatalogue_id', 1);
         $typeHouseSale->order_by('position');
         $typeHouseSale->get_iterated();
         $this->typeHouseSale = $typeHouseSale;
         //get all houselease
         $typeHouseLease = new Estatetype();
         $typeHouseLease->where('estatecatalogue_id', 2);
         $typeHouseLease->order_by('position');
         $typeHouseLease->get_iterated();
         $this->typeHouseLease = $typeHouseLease;
         //get all housedemand
         $typeHouseDemand = new Estatetype();
         $typeHouseDemand->where('estatecatalogue_id', 3);
         $typeHouseDemand->order_by('position');
         $typeHouseDemand->get_iterated();
         $this->typeHouseDemand = $typeHouseDemand;
         // get all province
         $estateProvince = new Estatecity();
         $estateProvince->order_by('position', 'asc');
         $estateProvince->get_iterated();
         $this->estateProvince = $estateProvince;
         // get all Direction
         $estateDirection = new Estatedirection();
         $estateDirection->order_by('id', 'desc');
         $estateDirection->get_iterated();
         $this->estateDirection = $estateDirection;
         // get all Estatecatalogues
         $estateCatalogues = new Estatecatalogue();
         $estateCatalogues->order_by('position', 'asc');
         $estateCatalogues->get_iterated();
         $this->estateCatalogues = $estateCatalogues;
         // get all business world
         $businessWorld = new Article();
         $businessWorld->order_by('id', 'desc');
         $businessWorld->where(array('recycle' => 0, 'newscatalogue_id' => 78));
         $businessWorld->get(20);
         $this->businessWorld = $businessWorld;
         // get all project news
         $projectNews = new Article();
         $projectNews->order_by('id', 'desc');
         $projectNews->where(array('recycle' => 0, 'newscatalogue_id' => 71));
         $projectNews->get(6);
         $this->projectNews = $projectNews;
         $this->projectNewsFirst = $projectNews->limit(1);
         // get all legal advice
         $legalAdvices = new Article();
         $legalAdvices->order_by('id', 'desc');
         $legalAdvices->where(array('recycle' => 0, 'newscatalogue_id' => 82));
         $legalAdvices->get(11);
         $this->legalAdvices = $legalAdvices;
         // get all new STND
         $newsPrivate = new Article();
         $newsPrivate->order_by('id', 'desc');
         $newsPrivate->where(array('recycle' => 0, 'newscatalogue_id' => 75));
         $newsPrivate->get_iterated();
         $this->newsPrivate = $newsPrivate;
         // get all estateareas
         $estateareas = new Estatearea();
         $estateareas->order_by('position', 'asc');
         $estateareas->get_iterated();
         $this->estateareas = $estateareas;
         // get all estateprices
         $estateprices = new Estateprice();
         $estateprices->order_by('position', 'asc');
         $estateprices->get_iterated();
         $this->estateprices = $estateprices;
         //------------------------------------------------
         // Top Advertise
         //------------------------------------------------
         $banner = new banner();
         $banner->where('bannercat_id', 1);
         $banner->get_iterated();
         $this->banner = $banner;
         $bannerAdversiting = new Banner();
         $bannerAdversiting->where('bannercat_id', 19);
         $bannerAdversiting->get_iterated();
         $this->bannerAdversiting = $bannerAdversiting;
         $bannerLeft = new Banner();
         $bannerLeft->where('bannercat_id', 21);
         $bannerLeft->get_iterated();
         $this->bannerLeft = $bannerLeft;
         $bannerFooter = new Banner();
         $bannerFooter->where('bannercat_id', 20);
         $bannerFooter->get_iterated();
         $this->bannerFooter = $bannerFooter;
         $menu = new menu();
         $menu->order_by('position', 'asc');
         $menu->get_iterated(8);
         $this->menu = $menu;
         $productFooter = new menuitem();
         $productFooter->where('menu_id', 9);
         $productFooter->order_by('position', 'asc');
         $productFooter->get_iterated();
         $this->productFooter = $productFooter;
         $relation = new menuitem();
         $relation->order_by('position', 'asc');
         $relation->where('menu_id', 10);
         $relation->get_iterated();
         $this->relation = $relation;
         $this->_increaseVisiter();
         //load product manufacture
         $productManufacture = new Productmanufacture();
         $productManufacture->order_by('name', 'asc');
         $productManufacture->get_iterated();
         $this->productManufacture = $productManufacture;
         $adverHeader = new Banner();
         $adverHeader->where('bannercat_id', 25);
         $adverHeader->get(1);
         $this->adverHeader = $adverHeader;
         // get estates hot
         $newsHot = new Article();
         $newsHot->where_in('newscatalogue_id', array(71, 72, 73, 74, 75, 77, 78, 79, 80, 81, 82));
         $newsHot->order_by('id', 'desc');
         $newsHot->where('hotHome', 1);
         $newsHot->get(5);
         $this->newsHot = $newsHot;
     }
 }
예제 #9
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);
 }