diff --git a/src/application/controllers/Subcategory.php b/src/application/controllers/Subcategory.php index b114a910..dedce008 100644 --- a/src/application/controllers/Subcategory.php +++ b/src/application/controllers/Subcategory.php @@ -1,49 +1,50 @@ load->model("subcategory_model","subcategory"); + $this->load->model('subcategory_model', 'subcategory'); } - + function update_value() { - $id = $this->input->post ( "id" ); - $value = urldecode ( $this->input->post ( "value" ) ); - $field = $this->input->post ( "field" ); - $values = array ( - $field => $value - ); - $output = $this->subcategory->update ( $id, $values ); - - - echo $output; + $id = $this->input->post('id'); + $value = urldecode($this->input->post('value')); + $field = $this->input->post('field'); + $values = [ + $field => $value + ]; + $output = $this->subcategory->update($id, $values); + + print $output; } - -function create($category_id) + + function create($category_id) { - $this->load->model ( 'category_model', 'category' ); + $this->load->model('category_model', 'category'); $category = $this->category->get($category_id); $data['category_id'] = $category_id; - $data ['title'] = sprintf('Create a New Subcategory for %s',$category->category); - $data ['target'] = 'subcategory/edit'; - $data ['action'] = 'insert'; - $data ['subcategory'] = FALSE; - if ($this->input->get ( 'ajax' )) { - $this->load->view ( 'page/modal', $data ); + $data['title'] = sprintf('Create a New Subcategory for %s', $category->category); + $data['target'] = 'subcategory/edit'; + $data['action'] = 'insert'; + $data['subcategory'] = FALSE; + if ($this->input->get('ajax')) { + $this->load->view('page/modal', $data); } else { - $this->load->view ( 'page/index', $data ); + $this->load->view('page/index', $data); } } function insert() { - if ($subcategory = $this->input->post ( 'subcategory' )) { + if ($subcategory = $this->input->post('subcategory')) { $category_id = $this->input->post("category_id"); - if (! $this->subcategory->exists ($category_id, $subcategory )) { - $this->subcategory->insert ( $category_id, $subcategory ); + if (!$this->subcategory->exists($category_id, $subcategory)) { + $this->subcategory->insert($category_id, $subcategory); } } - redirect ( 'category' ); + redirect('category'); } -} \ No newline at end of file +}