<?php require_once "../Model/Database.php"; require_once "../Model/Food.php"; require_once "../Model/FoodDB.php"; $foods = FoodDB::getAll(); echo $foods;
$mark = FoodDB::calculateMark($_GET["id"]); FoodDB::setHistory($_GET["id"]); $cartnumber = ShoppingcartDB::getCount(AuthModel::getUser('id')); include "food_product.php"; } else { if (isset($_POST["action"])) { if ($_POST["action"] == "add") { $count = ShoppingcartDB::insertItemById($_POST['foodId'], AuthModel::getUser('id'), $_POST['quantity'], $_POST['size'], $_POST['cinema']); } else { if ($_POST["action"] == "insertcomment") { $count = FoodDB::insertCommentById($_POST["orderitemid"], $_POST["foodid"], $_POST["comment"], $_POST["mark"], $_POST["satisfaction"], $_POST["file"], AuthModel::getUser('id')); } } } else { if (isset($_GET["foodid"])) { $food = FoodDB::getFoodById($_GET["foodid"]); $cartnumber = ShoppingcartDB::getCount(AuthModel::getUser('id')); include "CommentForm.php"; } else { if (isset($_POST["submit"])) { //path of the file in temp directory $file_temp = $_FILES['upfile']['tmp_name']; //original path and file name of the uploaded file $file_name = $_FILES['upfile']['name']; //size of the uploaded file in bytes $file_size = $_FILES['upfile']['size']; //type of the file(if browser provides) $file_type = $_FILES['upfile']['type']; //error number $file_error = $_FILES['upfile']['error']; echo $file_temp . "<br />";
public static function getHistory($count) { $foods = json_decode(FoodDB::getAll()); $time = array(); $t = time(); foreach ($foods as $food) { if (isset($_COOKIE[$food->Food_id]) && $_COOKIE[$food->Food_id] >= strtotime('-7 day', $t)) { $time[$food->Food_id] = $_COOKIE[$food->Food_id]; } } arsort($time); $results = array(); foreach ($time as $key => $item) { $food = FoodDB::getFoodById($key); $results[] = $food; if (count($results) >= $count) { break; } } return $results; }
$foods = ShoppingcartDB::getGuess(AuthModel::getUser('id'), 6); include "bottomload.php"; } else { if ($action == "update") { ShoppingcartDB::updateSizeById($_GET["id"], $_GET["size"]); } else { if ($action == "updatecinema") { ShoppingcartDB::updateCinemaById($_GET["id"], $_GET["cinema"]); } else { if ($action == "updateq") { ShoppingcartDB::updateQuantityById($_GET["id"], $_GET["quantity"]); echo $_GET["id"] . " " . $_GET["quantity"]; } else { if ($page == "cart_list") { $cart = ShoppingcartDB::getCartByUserId(AuthModel::getUser('id')); $cinemas = FoodDB::getFoodCinema(); $guess = ShoppingcartDB::getGuess(AuthModel::getUser('id'), 6); include "food-shopping-cart.php"; } else { if ($page == "order_management") { include "Order_Management.php"; } } } } } } } } } }
<?php require_once "../Model/Food.php"; require_once "../Model/FoodDB.php"; if (isset($_GET["id"])) { $foods = FoodDB::getFoodCommentById($_GET["id"]); echo $foods; }
public static function calculateMark($foodid) { self::$db = Database::getDB(); $results = json_decode(self::getFoodCommentById($foodid)); $count = count($results); if ($count > 0) { $sum = 0; foreach ($results as $result) { $sum += $result->Mark; } $average = $sum / $count; } else { $average = 5; } $query = "update food set Food_mark= :foodmark where Food_id= :foodid"; $stm = self::$db->prepare($query); $stm->bindParam(":foodmark", $average); $stm->bindParam(":foodid", $foodid); $count = $stm->execute(); return $average; }
echo AuthModel::getUser('id'); } else { echo false; } } } } else { if (isset($_GET["search"])) { $foods = FoodDB::search($_GET["search"]); echo $foods; } else { if ($page == "all") { $foods = FoodDB::getAll(); $foods = json_decode($foods); $topfoods = FoodDB::getTopFoods(5); $pages = FoodDB::pages($foods); $cartnumber = ShoppingcartDB::getCount(AuthModel::getUser('id')); $userid = ""; include "Food_Menu.php"; } else { if ($page == "allFoods") { $foods = FoodDB::getAll(); echo $foods; // include "Food Management/show.php"; } else { $foods = FoodDB::getFoodsByCatagory($page); echo $foods; } } } }
$itemquantity = $_POST['itemquantity']; $_SESSION["food"] = true; $_SESSION["food1"]["total"] = $total; $_SESSION["food1"]["phone"] = $phone; $_SESSION["food1"]["id"] = $id; $_SESSION["food1"]["foodid"] = $itemid; $_SESSION["food1"]["itemquantity"] = $itemquantity; include "payment.php"; } else { if ($page == "paid") { $orderdb->updateOrder($_GET['total'], 1, $_GET['phone'], $_GET['id']); foreach ($_GET['foodid'] as $key => $id) { $food = FoodDB::getFoodById($id); $stock = $food->getInstock() - $_GET['itemquantity'][$key]; $sale = $food->getSalesVolume() + 1; FoodDB::updateFoodById($id, $stock, $sale); } } else { if ($page == "ajax") { echo $_SESSION["food"]; } else { if ($page == "paying") { echo json_encode($_SESSION["food1"]); } } } } } } } }