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); }
function editPost($postId) { $postId = $this->uri->segment(2); $dis['postId'] = $postId; $o = new Estate($postId); if (!$o->exists()) { show_404(); } $customer = new Estateuser($this->session->userdata('userLoginId')); if (!$customer->exists()) { show_404(); } $dis['customer'] = $customer; if ($_SERVER['REQUEST_METHOD'] == 'POST') { try { $o->estatecity_id = $this->input->post('estatecity_id'); $o->estatedistrict_id = $this->input->post('estatedistrict_id'); $o->estatecatalogue_id = $this->input->post('estatecatalogue_id'); $o->estatetype_id = $this->input->post('estatetype_id'); $o->estatedirection_id = $this->input->post('estatedirection_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->area_text = $this->input->post('area_text'); $o->estatedirection_id = $this->input->post('estatedirection_id'); //$o->estateuser_id = $this->session->userdata('userLoginId'); $o->title = ucfirst(mb_strtolower($this->input->post('title'), "utf-8")); $o->description = $this->input->post('description'); if ($o->estatecatalogue_id == 1) { $o->price_type = $this->input->post('price_type'); } else { $o->price_type = $this->input->post('price_type_2'); } $o->article_id = $this->input->post('article_id'); $o->created = date('Y-m-d H:i:s'); $o->updateTime = date('Y-m-d H:i:s'); 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 { // 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); $o->photo = ''; } else { $o->photo = $folder . $dataupload['file_name']; $img = getimagesize($folder . $dataupload['file_name']); if (!empty($img[2])) { $typeImage = image_type_to_mime_type($img[2]); } $fileWatermark = 'img/watermark/chen-hinh-tin-rao.png'; $fileImage = $folder . $dataupload['file_name']; $stamp = imagecreatefrompng($fileWatermark); if ($typeImage == 'image/jpeg') { $im = imagecreatefromjpeg($fileImage); } else { if ($typeImage == 'image/gif') { $im = imagecreatefromgif($fileImage); } else { $im = imagecreatefrompng($fileImage); } } // Get dimensions $sx = imagesx($im); $sy = imagesy($im); $sx1 = imagesx($stamp); $sy1 = imagesy($stamp); // width to calculate positioning of the stamp. imagecopy($im, $stamp, ($sx - $sx1) / 2, ($sy - $sy1) / 2, 0, 0, imagesx($stamp), imagesy($stamp)); // Output and free memory header('Content-type: image/png'); imagejpeg($im, $fileImage, 100); } } // Add thumbnail to slide if ($_FILES['thumb1']['name'] != "") { $folder = 'img/project/'; $numfile = $this->input->post('numfile'); foreach ($numfile as $row) { $dataupload = $this->file_lib->upload('thumb' . $row, $folder, $rename_file = true); 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(); $img = getimagesize($folder . $dataupload['file_name']); if (!empty($img[2])) { $typeImage = image_type_to_mime_type($img[2]); } $fileWatermark = 'img/watermark/chen-hinh-tin-rao.png'; $fileImage = $folder . $dataupload['file_name']; $stamp = imagecreatefrompng($fileWatermark); if ($typeImage == 'image/jpeg') { $im = imagecreatefromjpeg($fileImage); } else { if ($typeImage == 'image/gif') { $im = imagecreatefromgif($fileImage); } else { $im = imagecreatefrompng($fileImage); } } // Get dimensions $sx = imagesx($im); $sy = imagesy($im); $sx1 = imagesx($stamp); $sy1 = imagesy($stamp); // width to calculate positioning of the stamp. imagecopy($im, $stamp, ($sx - $sx1) / 2, ($sy - $sy1) / 2, 0, 0, imagesx($stamp), imagesy($stamp)); // Output and free memory header('Content-type: image/png'); imagejpeg($im, $fileImage, 100); } } } if ($o->save()) { redirect(base_url() . 'chinh-sua-tin-da-dang'); } } } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; die; } } $project = new Article(); $project->where('estatecity_id', $o->estatecity_id); $project->get_iterated(); $dis['project'] = $project; $photo = new Estate_photo(); $photo->where('estate_id', $postId); $photo->get_iterated(); $dis['photo'] = $photo; $this->page_title = "Đăng tin rao vặt bất động sản | Rao vặt nhà đất | SotayNhadat.vn"; $dis['o'] = $o; $dis['base_url'] = base_url(); $dis['view'] = 'front/user/post-edit'; $dis['msg'] = $msg; $dis['type'] = $type; $this->viewfront($dis); }
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); }