function viewAction()
 {
     $fc = FrontController::getInstance();
     $model = new FrontModel();
     $id = filter_var($fc->getParams()['id'], FILTER_SANITIZE_NUMBER_INT);
     if (!$id) {
         header('Location: /admin/notFound');
         exit;
     }
     $productModel = new ProductTableModel();
     $productModel->setId($id);
     $productModel->setTable('product');
     $ImageModel = new ImageTableModel();
     $ImageModel->setId($id);
     $ImageModel->setTable('image');
     $images = $ImageModel->readRecordsById('product_id', '*', 'ORDER BY main');
     $product = $productModel->readRecordsById()[0];
     $categoryModel = new CategoryTableModel();
     $product['category'] = $categoryModel->getCategoryById($product['category_id'])['category_name'];
     $product['subCategory'] = $categoryModel->getSubCategoryById($product['subcategory_id'])['subcategory_name'];
     if (!$product) {
         header('Location: /admin/notFound');
         exit;
     }
     $recProducts = (new IndexWidgets())->recAndPopProductsWidget('recommended');
     $model->setData(['product' => $product, 'images' => $images, 'recommendedProducts' => Generator::recommendedProducts($recProducts)]);
     $output = $model->render('../views/product/product.php', 'withoutSlider');
     $fc->setPage($output);
 }
 protected function getCatsAndSubCats($flag = FALSE)
 {
     $condition = '';
     $categoryModel = new CategoryTableModel();
     $categoryModel->setTable('category');
     $categoryModel->readAllRecords();
     $subCategoryModel = new SubCategoryTableModel();
     $subCategoryModel->setTable('subcategory');
     if (!$flag) {
         $condition .= "WHERE subcategory.category_id = " . end($categoryModel->getAllRecords())['id'];
     }
     $subCategoryModel->readAllRecords('*', $condition);
     return ['cats' => array_reverse($categoryModel->getAllRecords()), 'subcats' => array_reverse($subCategoryModel->getAllRecords())];
 }
Esempio n. 3
0
 public function deleteCategoryAction($id = NULL)
 {
     header('Content-type: text/plain; charset=utf-8');
     header('Cache-Control: no-store, no-cache');
     header('Expires: ' . date('r'));
     $id = Validate::validateInputVar('catid', 'INPUT_GET', 'int');
     $this->deleteSubCategoryAction('category_id', $id);
     $model = new CategoryTableModel();
     $model->setTable('category');
     $model->setId($id);
     if ($model->deleteRecord()) {
         $this->getCategoriesAction();
     }
 }
Esempio n. 4
0
 public function newCatAction()
 {
     $fc = FrontController::getInstance();
     $model = new CategoryTableModel();
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         $model->setTable('category');
         if ($model->setData()) {
             $model->addRecord();
         }
     }
     //         header('Location: ' . $_SERVER['HTTP_REFERER']);
     //         exit;
 }