Example #1
0
    $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 />";
Example #2
0
 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;
 }
Example #3
0
         $id = $_POST["id"];
         $phone = $_POST['phone'];
         $itemid = $_POST['itemid'];
         $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"]);
                 }
             }
         }
     }
 }