if ($category_id == NULL || $category_id == FALSE) { $category_id = 1; } // Get product and category data $current_category = $categoryDB->getCategory($category_id); $categories = $categoryDB->getCategories(); $products = $productDB->getProductsByCategory($category_id); // Display the product list include 'product_list.php'; } else { if ($action == 'delete_product') { // Get the IDs $product_id = filter_input(INPUT_POST, 'product_id', FILTER_VALIDATE_INT); $category_id = filter_input(INPUT_POST, 'category_id', FILTER_VALIDATE_INT); // Delete the product $productDB->deleteProduct($product_id); // Display the Product List page for the current category header("Location: .?category_id={$category_id}"); } else { if ($action == 'show_add_form') { $categories = $categoryDB->getCategories(); include 'product_add.php'; } else { if ($action == 'add_product') { $category_id = filter_input(INPUT_POST, 'category_id', FILTER_VALIDATE_INT); $code = filter_input(INPUT_POST, 'code'); $name = filter_input(INPUT_POST, 'name'); $price = filter_input(INPUT_POST, 'price'); if ($category_id == NULL || $category_id == FALSE || $code == NULL || $name == NULL || $price == NULL || $price == FALSE) { $error = "Invalid product data. Check all fields and try again."; include '../errors/error.php';
if ($category_id == NULL || $category_id == FALSE) { $category_id = 1; } // Get product and category data $current_category = CategoryDB::getCategory($category_id); $categories = CategoryDB::getCategories(); $products = ProductDB::getProductsByCategory($category_id); // Display the product list include 'product_list.php'; } else { if ($action == 'delete_product') { // Get the IDs $product_id = filter_input(INPUT_POST, 'product_id', FILTER_VALIDATE_INT); $category_id = filter_input(INPUT_POST, 'category_id', FILTER_VALIDATE_INT); // Delete the product ProductDB::deleteProduct($product_id); // Display the Product List page for the current category header("Location: .?category_id={$category_id}"); } else { if ($action == 'show_add_form') { $categories = CategoryDB::getCategories(); include 'product_add.php'; } else { if ($action == 'add_product') { $category_id = filter_input(INPUT_POST, 'category_id', FILTER_VALIDATE_INT); $code = filter_input(INPUT_POST, 'code'); $name = filter_input(INPUT_POST, 'name'); $price = filter_input(INPUT_POST, 'price'); if ($category_id == NULL || $category_id == FALSE || $code == NULL || $name == NULL || $price == NULL || $price == FALSE) { $error = "Invalid product data. Check all fields and try again."; include '../errors/error.php';