function down_position() { $min = new bannercat(); $min->select_min('position'); $min->where('position >', $this->position); $min->get(); $o = new bannercat(); $o->where('position', $min->position); $o->get(); if ($o->result_count() > 0) { $tg = $this->position; $this->position = $o->position; $o->position = $tg; $o->save(); $this->save(); return true; } else { return false; } }
function edit($id = 0) { $bannercat = new bannercat($id); if ($_SERVER['REQUEST_METHOD'] == "GET") { } else { $bannercat->name = $this->input->post('name'); $bannercat->description = $this->input->post('description'); $this->load->helper('remove_vn_helper'); $bannercat->name_none = remove_vn($bannercat->name); if ($bannercat->save()) { redirect($this->admin . 'bannercats/list_all/'); } } $dis['base_url'] = base_url(); $dis['title'] = "Thêm/ Sửa Banner"; $dis['menu_active'] = "Hình quảng cáo"; $dis['view'] = "banner/edit"; $dis['object'] = $bannercat; $dis['nav_menu'] = array(array("type" => "back", "text" => "Quay về", "link" => "{$this->admin_url}bannercats/", "onclick" => "")); $this->viewadmin($dis); }
function add_image($banner_id) { $this->load->library('file_lib'); $banner = new banner($banner_id); $dataupload = $this->file_lib->upload('image', "img/banner"); $this->resize_image("img/banner/" . $dataupload['file_name'], 200, 100); if (!is_array($dataupload)) { flash_message('error', "Hình ảnh :" . $dataupload); $flag_error = true; } else { $bannercat = new bannercat(); $bannercat->link = $dataupload['file_name']; $bannercat->title = $this->input->post('title'); $bannercat->banner_id = $banner_id; $bannercat->save(); } redirect($this->admin_url . "banners/list_image/" . $banner_id); }