public function edit() { if (!isset($_SESSION['userId']) && $_SESSION['editor'] != true && $_SESSION['admin'] != true) { header('Location: /php_project/application/public/'); exit; } $category_id = $this->input->get(0); $categoryDb = new \Models\Category(); $category = $categoryDb->get('category_id = ' . $category_id)[0]; if (isset($_POST['name'])) { $cleaner = new \Framework\Common(); $name = $cleaner->normalize($_POST['name'], 'trim|xss|string'); if ($name == $category['name']) { header('Location: /php_project/application/public/editor/index'); exit; } $updateCategory = array(); $updateCategory['name'] = $name; $updateCategory['category_id'] = $category_id; $categoryDb->update('category', $updateCategory); header('Location: /php_project/application/public/editor/index'); exit; } if (!is_numeric($category_id) || !$category) { header('Location: /php_project/application/public/'); exit; } $this->view->appendToLayout('body', 'editCategory'); $this->view->display('layouts.default', $category); }
public function index() { $categories = new \Models\Category(); $allCategories = $categories->find(); $products = new \Models\Product(); $allProducts = $products->getProductsWithDiscount(); $data = array(); $data[] = $allCategories; $data[] = $allProducts; $this->view->appendToLayout('body', 'index'); $this->view->display('layouts.default', $data); }
public function category() { $category_id = $this->input->get(0); $productDb = new \Models\Product(); $products = $productDb->getByCategory($category_id); $categories = new \Models\Category(); $allCategories = $categories->find(); $data = array(); $data[] = $allCategories; $data[] = $products; $this->view->appendToLayout('body', 'index'); $this->view->display('layouts.default', $data); }
public function index() { if (!isset($_SESSION['userId'])) { header('Location: /php_project/application/public/'); exit; } $categories = new \Models\Category(); $allCategories = $categories->find(); $products = new \Models\Product(); $allProducts = $products->getProductsWithDiscount(); $data = array(); $data[] = $allCategories; $data[] = $allProducts; $this->view->appendToLayout('body', 'index'); $this->view->display('layouts.default', $data); }
public function index() { if (!isset($_SESSION['userId']) && $_SESSION['editor'] != true && $_SESSION['admin'] != true) { header('Location: /php_project/application/public/'); exit; } $categories = new \Models\Category(); $allCategories = $categories->find(); $products = new \Models\Product(); $allProducts = $products->find(); $promotionDb = new \Models\Promotion(); $allPromos = $promotionDb->find(); $data = array(); $data[] = $allCategories; $data[] = $allProducts; $data[] = $allPromos; $this->view->appendToLayout('body', 'editorIndex'); $this->view->display('layouts.default', $data); }
public function add() { if (!isset($_SESSION['userId']) && $_SESSION['admin'] != true) { header('Location: /php_project/application/public/'); exit; } if (isset($_POST['name'])) { $cleaner = new \Framework\Common(); $newCat = array(); $newCat['name'] = $cleaner->normalize($_POST['name'], 'trim|xss|string'); $newCat['user_id'] = $_SESSION['userId']; $categoryDb = new \Models\Category(); $categoryDb->add($newCat); header('Location: /php_project/application/public/editor/index'); exit; } $this->view->appendToLayout('body', 'addPromotion'); $this->view->display('layouts.default'); }
public function delete($parameter) { $item_id = $parameter[0]; $category_model = new \Models\Category(); $delete = $category_model->deleteId($item_id); if (isset($delete)) { Session::set('success', 'record deleted'); Url::previous(); } }