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())]; }
public function deleteSubCategoryAction($field = 'category_id', $id = NULL) { header('Content-type: text/plain; charset=utf-8'); header('Cache-Control: no-store, no-cache'); header('Expires: ' . date('r')); if (isset($_GET['subcatid']) && !empty($_GET['subcatid'])) { $id = Validate::validateInputVar('subcatid', 'INPUT_GET', 'int'); $this->deleteProductsAction('subcategory_id', $id); $field = 'id'; } else { $this->deleteProductsAction($field = 'category_id', $id); } $model = new SubCategoryTableModel(); $model->setTable('subcategory'); $model->setId($id); if ($model->deleteRecord($field)) { return TRUE; } }
public function newSubCatAction() { $fc = FrontController::getInstance(); $model = new SubCategoryTableModel(); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $model->setTable('subcategory'); $model->setData(); $model->addRecord(); } // header('Location: ' . $_SERVER['HTTP_REFERER']); // exit; }