Exemplo n.º 1
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.º 2
0
 function edit($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->estateuser_id = $this->session->userdata('userLoginId');*/
         $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->tag = $this->input->post('tag');
         $tags = remove_vn($this->input->post('tag') . ' ' . $this->input->post('title'));
         $tags = explode('-', $tags);
         $estate->tag_search = implode(' ', $tags);
         // 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'];
             }
         }
         // Add thumbnail to slide
         if ($_FILES['thumb']['name'] != "") {
             $folder = 'img/project/';
             $dataupload = $this->file_lib->upload('thumb', $folder, $rename_file = true);
             if (!is_array($dataupload)) {
                 flash_message('error', $dataupload);
             } else {
                 $estate_photos = new Estate_photo();
                 $estate_photos->estate_id = $estate->id;
                 $estate_photos->name = $folder . $dataupload['file_name'];
                 $estate_photos->save();
                 $estate_photos->clear();
             }
         }
         $estate->title_none = remove_vn($this->input->post('title')) . $estate->code;
         if ($estate->save()) {
             flash_message('success', 'Bản tin đã được thay đổi thành công.');
             redirect($this->admin_url . 'estates/list_all/');
             //redirect($this->admin_url.'estates/edit/'.$estate->id);
         } else {
             flash_message('error', 'Đã có lỗi xãy ra !');
             //redirect($this->admin_url.'estates/list_all/');
             redirect($this->admin_url . 'estates/edit/' . $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->where('estatecatalogue_id', $estate->estatecatalogue_id);
     $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->where('estatedistrict_id', $estate->estatedistrict_id);
     $project->order_by('title_vietnamese', 'asc');
     $project->get_iterated();
     $dis['project'] = $project;
     $photos = new Estate_photo();
     $photos->where('estate_id', $estate->id);
     $photos->get_iterated();
     $dis['photos'] = $photos;
     $dis['object'] = $estate;
     $dis['base_url'] = base_url();
     $dis['view'] = 'estate/edit';
     $dis['menu_active'] = 'Tin bất động sản';
     $dis['title'] = "Thêm/Sửa Tin '" . $estate->title . "'";
     $dis['nav_menu'] = array(array("type" => "back", "text" => "Quay về", "link" => "{$this->admin_url}estates/list_all/", "onclick" => ""));
     $this->viewadmin($dis);
 }