示例#1
0
<?php

/*
 * Student Info: Name=Tsai-Chang Mai, ID=10010
 * Subject: CS526(C)_HW5_Spring_2016
 * Author: Arvin-tcm 
 * Filename: view_food.php 
 * Date and Time: Mar 24, 2016 4:35:07 PM 
 * Project Name: TsaiChangMai_10010_CS526A_HW5 
 */
$food_id = 1;
if (isset($_GET['food_id'])) {
    $food_id = $_GET['food_id'];
}
$categories = CategoryRepository::getCategories();
$food_id = $_GET['food_id'];
$food = FoodRepository::getFood($food_id);
return 'views/food_view.php';
示例#2
0
<?php

/*
 * Student Info: Name=Tsai-Chang Mai, ID=10010
 * Subject: CS526(C)_HW5_Spring_2016
 * Author: Arvin-tcm 
 * Filename: delete_food.php 
 * Date and Time: Mar 24, 2016 4:27:09 PM 
 * Project Name: TsaiChangMai_10010_CS526A_HW5 
 */
// get the IDs
$food_id = $_POST['food_id'];
$category_id = $_POST['category_id'];
// delete the food
FoodRepository::deleteBook($food_id);
// display the food list page for the current category
header("Location: .?controller=admin&category_id={$category_id}");
示例#3
0
<?php

/*
 * Student Info: Name=Tsai-Chang Mai, ID=10010
 * Subject: CS526(C)_HW5_Spring_2016
 * Author: Arvin-tcm 
 * Filename: list_foods.php 
 * Date and Time: Mar 24, 2016 4:29:17 PM 
 * Project Name: TsaiChangMai_10010_CS526A_HW5 
 */
$category_id = 1;
if (isset($_GET['category_id'])) {
    $category_id = $_GET['category_id'];
}
$categories = CategoryRepository::getCategories();
$category = CategoryRepository::getCategory($category_id);
$foods = FoodRepository::getFoodsByCategory($category_id);
return 'views/manage_food_list_view.php';
示例#4
0
<?php

/*
 * Student Info: Name=Tsai-Chang Mai, ID=10010
 * Subject: CS526(C)_HW5_Spring_2016
 * Author: Arvin-tcm 
 * Filename: add_food.php 
 * Date and Time: Mar 24, 2016 4:16:12 PM 
 * Project Name: TsaiChangMai_10010_CS526A_HW5 
 */
$addFoodSubmitted = isset($_POST['addfood_submitted']);
if ($addFoodSubmitted) {
    $category_id = $_POST['category_id'];
    $calories = $_POST['calories'];
    $title = $_POST['food_title'];
    $price = $_POST['food_price'];
    // validate the inputs
    if (empty($calories) || empty($title) || empty($price)) {
        $error = "Invalid food data. Check all fields and try again";
        include '../errors/error.php';
    } else {
        $category = CategoryRepository::getCategory($category_id);
        $food = new Food($calories, $title, $price, $category);
        FoodRepository::addFood($food);
        // Display the Food list page for the current category
        header("Location: .?controller=admin&category_id={$category_id}");
    }
} else {
    $categories = CategoryRepository::getCategories();
    return 'views/add_food_view.php';
}