Exemplo n.º 1
0
 function edit($id = 0)
 {
     $price = new Estateprice($id);
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $this->load->helper('remove_vn_helper');
         $price->label = $this->input->post('label');
         $price->from = $this->input->post('from');
         $price->to = $this->input->post('to');
         $price->estatecatalogue_id = $this->input->post('estatecatalogue_id');
         $price->url = remove_vn($price->label);
         if ($price->save()) {
             flash_message('success', 'Thao tác đã được thực hiện');
             redirect($this->admin . 'estateprices/list_all');
         } else {
             flash_message('error', 'Đã có lỗi xãy ra !');
         }
     }
     $estatecatalogues = new Estatecatalogue();
     $estatecatalogues->get_iterated();
     $dis['estatecatalogues'] = $estatecatalogues;
     $dis['object'] = $price;
     $dis['base_url'] = base_url();
     $dis['view'] = 'estateprice/edit';
     $dis['menu_active'] = 'Mức giá';
     $dis['title'] = "Thêm/Sửa Mức giá";
     $dis['nav_menu'] = array(array("type" => "back", "text" => "Quay về", "link" => "{$this->admin_url}estateprices/list_all/", "onclick" => ""));
     $this->viewadmin($dis);
 }
Exemplo n.º 2
0
 function delete()
 {
     $id = $this->uri->segment(4);
     $catalogue = new Estatecatalogue($id);
     //delete catalogue
     if (count($catalogue->child->all) > 0) {
         flash_message('error', 'Không thể xóa danh mục cha, vui lòng xóa mục con trước');
     } else {
         $catalogue->delete();
         flash_message('success', 'Xóa thành công');
     }
     //redirect to catalogue
     redirect($this->admin . 'estatecatalogues/list_all');
 }
Exemplo n.º 3
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists()) {
         $o = new Estatecatalogue();
         $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);
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
 function postDetail($url)
 {
     $typeNameNone = $this->uri->segment(1, "");
     $type = new Estatetype();
     $type->where('name_none', $typeNameNone)->get();
     if ($type->exists()) {
         show_404();
     }
     $cate = new Estatecatalogue();
     $cate->where('name_none', $this->uri->segment(1, ''))->get();
     if (!$cate->exists()) {
         show_404();
     }
     $dis['cate'] = $cate;
     $url = geturlfromuri($this->uri->segment(3));
     $estate = new Estate();
     $estate->where('title_none', $url);
     $estate->where_related_estatecatalogue('id', $cate->id);
     $estate->where('active', 0);
     $estate->get();
     if (!$estate->exists()) {
         redirect(base_url() . $this->uri->segment(1, '') . '-' . $this->uri->segment(2, ''));
         die;
     }
     $dis['o'] = $estate;
     $photo = new Estate_photo();
     $photo->where('estate_id', $estate->id);
     $photo->get_iterated();
     $dis['photo'] = $photo;
     $tag = $estate->tag;
     $dis['tag'] = explode(',', $tag);
     $description = str_replace(array("\r", "\n"), '', strip_tags($estate->description));
     $keyword = explode(' ', $estate->title);
     $this->page_title = $estate->title . ' | SotayNhadat.vn';
     $this->page_description = cut_string($description, 180);
     $this->page_keyword = implode(', ', $keyword);
     /*Get estate related vip*/
     $estates_vip = new Estate();
     $estates_vip->where('id !=', $estate->id);
     $estates_vip->where('estatetype_id', $estate->estatetype_id);
     $estates_vip->where('estatecity_id', $estate->estatecity_id);
     $estates_vip->where('estateprice_id', $estate->estateprice_id);
     $estates_vip->where('isVip', 1);
     $estates_vip->where('active', 0);
     $estates_vip->order_by('created', 'desc');
     $estates_vip->get(10);
     $count_vip = $estates_vip->result_count();
     $dis['estates_vip'] = $estates_vip;
     /*Get estate related follow type, city and price*/
     $estates_related_type_city_area = new Estate();
     $estates_related_type_city_area->where('id !=', $estate->id);
     $estates_related_type_city_area->where('estatetype_id', $estate->estatetype_id);
     $estates_related_type_city_area->where('estatecity_id', $estate->estatecity_id);
     $estates_related_type_city_area->where('estateprice_id', $estate->estateprice_id);
     $estates_related_type_city_area->where('isVip', 0);
     $estates_related_type_city_area->where('active', 0);
     $estates_related_type_city_area->order_by('created', 'desc');
     $estates_related_type_city_area->get(10 - $count_vip);
     $dis['estates_related_type_city_area'] = $estates_related_type_city_area;
     $count_type_city_area = $estates_related_type_city_area->result_count();
     /*Get all id estate*/
     $list_estates_id = array(0);
     foreach ($estates_related_type_city_area as $row) {
         array_push($list_estates_id, $row->id);
     }
     /*Get estate related follow type, city and area*/
     if (10 - $count_vip - $count_type_city_area > 0) {
         /*If count more than 10*/
         $estates_related_area_price = new Estate();
         $estates_related_area_price->where('estatetype_id', $estate->estatetype_id);
         $estates_related_area_price->where('estatearea_id', $estate->estatearea_id);
         $estates_related_area_price->where('estatecity_id', $estate->estatecity_id);
         $estates_related_area_price->where_not_in('id', $list_estates_id);
         $estates_related_area_price->where('isVip', 0);
         $estates_related_area_price->where('active', 0);
         $estates_related_area_price->order_by('created', 'desc');
         $estates_related_area_price->get(10 - $count_vip - $count_type_city_area);
         //$dis['estates_related_area_price'] = $estates_related_area_price;
     }
     //$limit_lv3 = $estates_related_area_price->result_count()==$limit_lv2?0:$limit_lv2-$estates_related_area_price->result_count();
     foreach ($estates_related_area_price as $row) {
         array_push($list_estates_id, $row->id);
     }
     $estates_related_new = new Estate();
     $estates_related_new->where('estatetype_id', $estate->estatetype_id);
     $estates_related_new->where('estatearea_id', $estate->estatearea_id);
     $estates_related_new->where('estatecity_id', $estate->estatecity_id);
     $estates_related_new->where('estateprice_id', $estate->estateprice_id);
     $estates_related_new->where_not_in('id', $list_estates_id);
     $estates_related_new->where('active', 0);
     $estates_related_new->order_by('created', 'desc');
     $estates_related_new->get($limit_lv3);
     $dis['estates_related_new'] = $estates_related_new;
     $estates_related_price = new Estate();
     $estates_related_price->where('estateprice_id', $estate->estateprice_id);
     $estates_related_price->where('estatecity_id', $estate->estatecity_id);
     $estates_related_price->where('id !=', $estate->id);
     $estates_related_price->where('active', 0);
     $estates_related_price->order_by('created', 'desc');
     $estates_related_price->get(10);
     $dis['estates_related_price'] = $estates_related_price;
     $estatePrices = new Estateprice();
     $estatePrices->where('estatecatalogue_id', $estate->estatecatalogue_id);
     $estatePrices->order_by('position', 'asc');
     $estatePrices->get_iterated();
     $dis['estatePrices'] = $estatePrices;
     $this->isRobotFollow = 3;
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/user/post-detail';
     $this->viewfront($dis);
 }
Exemplo n.º 6
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;
     }
 }
Exemplo n.º 7
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);
 }