예제 #1
0
 function edit($id = 0)
 {
     $newscatalogue = new newscatalogue($id);
     if ($_SERVER['REQUEST_METHOD'] == "GET") {
     } else {
         $newscatalogue->name_vietnamese = $this->input->post('name_vietnamese');
         $newscatalogue->name_english = $this->input->post('name_english');
         $newscatalogue->name_japanese = $this->input->post('name_japanese');
         $parentcat = new newscatalogue(trim($this->input->post('parentcat')));
         $newscatalogue->title_bar = $this->input->post('title_bar');
         $newscatalogue->slogan = $this->input->post('slogan');
         $newscatalogue->keyword = $this->input->post('keyword');
         $newscatalogue->group = $this->input->post('group');
         if ($this->logged_in_user->adminrole->id == 1) {
             $newscatalogue->navigation = $this->input->post('navigation');
             $newscatalogue->menu_active = $this->input->post('menu_active');
         }
         $this->load->helper('remove_vn_helper');
         $newscatalogue->name_none = remove_vn($newscatalogue->name_vietnamese);
         if ($newscatalogue->save(array('parentcat' => $parentcat))) {
             redirect($this->admin . 'newscatalogues/list_all/');
         }
     }
     $parentcat = new newscatalogue();
     $parentcat->where('parentcat_id', NULL);
     if ($newscatalogue->exists()) {
         $parentcat->where('id !=', $newscatalogue->id);
     }
     $parentcat->order_by('position', 'asc');
     $parentcat->get();
     $sitelanguage = new Sitelanguage();
     $sitelanguage->get()->all;
     $dis['sitelanguage'] = $sitelanguage;
     $dis['base_url'] = base_url();
     $dis['parentcat'] = $parentcat;
     $dis['title'] = "Thêm/ Sửa danh mục tin tức";
     $dis['menu_active'] = "Danh mục tin tức";
     $dis['view'] = "newscatalogue/edit";
     $dis['object'] = $newscatalogue;
     $dis['nav_menu'] = array(array("type" => "back", "text" => "Back", "link" => "{$this->admin_url}newscatalogues/", "onclick" => ""));
     $this->viewadmin($dis);
 }
예제 #2
0
 function down_position()
 {
     $min = new newscatalogue();
     $min->select_min('position');
     $min->where('position >', $this->position);
     $min->where('parentcat_id', $this->parentcat->id);
     $min->get();
     $o = new newscatalogue();
     $o->where('position', $min->position);
     $o->where('parentcat_id', $this->parentcat->id);
     $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;
     }
 }