Exemple #1
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists()) {
         $o = new showroom();
         $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);
 }
Exemple #2
0
 function down_position()
 {
     $min = new showroom();
     $min->select_min('position');
     $min->where('position >', $this->position);
     $min->get();
     $o = new showroom();
     $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;
     }
 }
Exemple #3
0
 function edit($id = 0)
 {
     $showrooms = new showroom($id);
     if ($_SERVER['REQUEST_METHOD'] == "GET") {
     } else {
         $showrooms->name_vietnamese = $this->input->post('name_vietnamese');
         $showrooms->name_english = $this->input->post('name_english');
         $showrooms->kind = $this->input->post('kind');
         $showrooms->description = $this->input->post('description');
         $showrooms->keyword = $this->input->post('keyword');
         $showrooms->txtDescription_vietnamese = $this->input->post('txtDescription_vietnamese');
         $showrooms->txtDescription_english = $this->input->post('txtDescription_english');
         $showrooms->video = $this->input->post('video');
         $this->load->helper('remove_vn_helper');
         $showrooms->name_none = remove_vn($showrooms->name_vietnamese);
         $filePath = 'img/showroom/';
         $this->load->library('file_lib');
         $dataupload = $this->file_lib->upload('image', $filePath);
         if (is_array($dataupload)) {
             $showrooms->image = $filePath . $dataupload['file_name'];
         }
         if ($showrooms->save()) {
             redirect($this->admin . 'showrooms/listAll');
         }
     }
     $photos = new showroomphoto();
     $photos->where('showroom_id', $id);
     $photos->get_iterated();
     $dis['photos'] = $photos;
     $dis['base_url'] = base_url();
     $dis['title'] = "Thêm/ Sửa Showroom";
     $dis['menu_active'] = "Showroom";
     $dis['view'] = "showroom/edit";
     $dis['object'] = $showrooms;
     $dis['nav_menu'] = array(array("type" => "back", "text" => "Quay về", "link" => "{$this->admin_url}showrooms/", "onclick" => ""), array("type" => "add", "text" => "Thêm Showroomphoto", "link" => "{$this->admin_url}showroomphotos/edit/" . $id, "onclick" => ""));
     $this->viewadmin($dis);
 }
Exemple #4
0
 function detail($name_none)
 {
     $title_none = $this->uri->segment(3);
     $arrTitle = explode('.', $title_none);
     if ($arrTitle[1] == '' || $arrTitle[1] != 'html') {
         redirect('');
     }
     $title_none = $arrTitle[0];
     $showrooms = new showroom();
     $showrooms->order_by('id', 'DESC');
     $showrooms->where('name_none', $title_none);
     $showrooms->get();
     $dis['showrooms'] = $showrooms;
     $showroomphotos = new showroomphoto();
     $showroomphotos->where('showroom_id', $showrooms->id);
     $showroomphotos->get_iterated();
     $dis['showroomphotos'] = $showroomphotos;
     $this->page_title = $showrooms->name;
     $this->page_description = $showrooms->description;
     $this->page_keyword = $showrooms->keyword;
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/showroom/detail';
     $this->viewfront($dis);
 }