Ejemplo n.º 1
0
 public function stripe($stripeToken)
 {
     $customer = \Stripe\Customer::create(array('email' => AuthModel::getUser('email'), 'source' => $stripeToken));
     $charge = \Stripe\Charge::create(array('customer' => $customer->id, 'amount' => $_SESSION['grandPrice'][0] * 100, 'currency' => 'cad'));
     unset($_SESSION['grandPrice']);
     // TODO: need handle payment errors
     return true;
 }
Ejemplo n.º 2
0
 /**
  *
  * init Detail page
  */
 public function index()
 {
     $editItemSession = new Session('editItem');
     $editItemSession->emptySession();
     if (!\Project\Auth\models\AuthModel::getUser()) {
         // echo "you should log in first";
         if (isset($_POST["filmId"])) {
             $filmId = $_POST["filmId"];
             header("Location: ./index.php?route=HomePageController/postToBooking/{$filmId}&click=click");
         } else {
             header("Location: ./index.php");
         }
     } else {
         //var_dump(\Project\Auth\models\AuthModel::getUser());
         $filmBooking = new FilmBookingModel();
         $cart = new ShoppingCart();
         if (!empty($_POST["OrderInfo"]) && !empty($_POST["filmId"])) {
             // if(isset($_POST["OrderInfo"])&& isset($_POST["seatsNums"]) &&isset($_POST["filmId"])){
             $bookingInfo = explode("| ", $_POST["OrderInfo"]);
             $seats = explode(" ", $_POST["seatsNums"]);
             $price = $_POST["totalPrice"];
             $tax = 0.13;
             $totalPrice = (1 + $tax) * $price;
             $bookInfo = new stdClass();
             $bookInfo->Run_Time = $bookingInfo[0];
             $bookInfo->Film_Name = $bookingInfo[1];
             $bookInfo->Cinema = $bookingInfo[2];
             $bookInfo->Room = $bookingInfo[3];
             $bookInfo->Cinema_Address = $bookingInfo[4];
             $bookInfo->Room_ID = $bookingInfo[5];
             $bookInfo->Seats = $_POST["seatsNums"];
             $bookInfo->TotalPrice = $totalPrice;
             $bookInfo->Price = $price;
             $bookInfo->Tax = $tax;
             $bookInfo->FilmId = $_POST["filmId"];
             $bookInfo->Cinema_ID = $_POST["Cinema"];
             $bookInfo->showDate = $bookingInfo[6];
             $bookInfo->showTime = $bookingInfo[7];
             $itemId = trim($_POST["itemId"]);
             //$cart->showCart();
             if (!empty($_POST["seatsNums"])) {
                 //check database first
                 foreach ($seats as $seat) {
                     $sql = "SELECT Seat_Name, available\n                           From seats WHERE Room_ID=:Room_ID AND Run_Time=:Run_Time AND Seat_Name=:Seat_Name";
                     $param = ["Room_ID" => $bookInfo->Room_ID, "Run_Time" => $bookInfo->Run_Time, "Seat_Name" => $seat];
                     $seatInfo = $filmBooking->getBookingDetail($param, $sql);
                     // var_dump($seatInfo);
                     if (is_array($seatInfo)) {
                         if ($seatInfo[0]->available == 'N') {
                             // require_once"./View/Error404.php";
                             self::seatsOccupied($bookInfo, $itemId);
                             exit;
                         }
                     }
                 }
             } else {
                 self::seatsEmpty($bookInfo, $itemId);
                 exit;
             }
             if ($itemId != "") {
                 //echo"Item id not null";
                 $cart->updateCartByItemId($itemId, $bookInfo);
             } else {
                 $cart->addToCart($bookInfo);
             }
             /*
              * Calculate Total Price
              *
              */
             $grandPrice = 0;
             foreach ($cart->shoppingCart->data as $item) {
                 $grandPrice += $item->TotalPrice;
             }
             $totalPrice = new Session('grandPrice');
             $totalPrice->emptySession();
             $totalPrice->data[] = $grandPrice;
             //var_dump($bookInfo);
             //$cart->showCart();
             foreach ($seats as $seat) {
                 $sql = "UPDATE seats\n                       SET available='N'\n                       WHERE Room_ID=:Room_ID AND Run_Time=:Run_Time AND Seat_Name=:Seat_Name";
                 $param = ["Room_ID" => $bookInfo->Room_ID, "Run_Time" => $bookInfo->Run_Time, "Seat_Name" => $seat];
                 $filmBooking->updateSeats($param, $sql);
                 require_once "./View/Comfirm.php";
             }
         }
     }
 }
Ejemplo n.º 3
0
    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 />";
                echo $file_name . "<br />";
Ejemplo n.º 4
0
/**
 * Created by PhpStorm.
 * User: yi
 * Date: 22/03/16
 * Time: 9:57 AM
 */
# PHP
// Add these to the top
use Project\Auth\models\AuthModel;
// needs auto loader
include '../autoloader.php';
// This returns username by default,
// if user is not logged in, returns false.
AuthModel::getUser();
// You can also pass in string as parameter to get email, id, role
AuthModel::getUser('email');
// => return user's email
AuthModel::getUser('id');
// => return user's id
AuthModel::getUser('role');
// => return user's role
# JavaScript
// make sure jQuery and bootstrap js are loaded.
// add <script src="/Assets/js/authApp.js"></script> to the bottom of page.
// place <div id="login"></div> at the place you want to have login and register buttons.
// After Login js is loaded, you can call
// login.show(), login.hide() in JavaScript to show and hide login form.
# API
// /Auth/getLogin can be used to get login status if you need it in JavaScript
// When logged in, it returns "{"success": true, "username": "******"}"
// when not logged in, it gives "{"success": false, "error": []}"
Ejemplo n.º 5
0
                        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";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Ejemplo n.º 6
0
<?php

// disable the catch from the client browser
header("Cache-Control: no-cache");
require_once 'database.php';
include '../autoloader.php';
require_once './Model/Ratings.php';
$db = Database::getDB();
$units = Database::unit();
$getRollId = Project\Auth\models\AuthModel::getUser('roleId');
if ($getRollId === false) {
    echo "Please Login First to Rate the movies !! Thank You.";
} else {
    $ip = \Project\Auth\models\AuthModel::getUser('id');
    //getting id of movie-1,2,3 which one is click that id from the rating.js page
    $id_sent = preg_replace("/[^0-9]/", "", $_REQUEST['id']);
    //Take the value of star based on user select Ex-user select 1-5 star take that value
    $vote_sent = preg_replace("/[^0-9]/", "", $_REQUEST['stars']);
    // Get The IP address of the local server host machine.
    //$ip =$_SERVER['REMOTE_ADDR'] ;
    $getIP = new Ratings();
    $getIP->getRating_IP($id_sent);
    // kill the script
    if ($vote_sent > $units) {
        die("Sorry, vote appears to be invalid.");
    }
    $disAll = new Ratings();
    $numbers = $disAll->displayValues($id_sent);
    $checkIP = unserialize($numbers['used_ips']);
    $count = $numbers['total_votes'];
    //Grab total votes from database column
Ejemplo n.º 7
0
                            $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"]);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
if (isset($_POST["check"])) {
    $total = $_POST["total"];
    $orderid = $orderdb->insertOrder(AuthModel::getUser('id'));
    foreach ($_POST["info"] as $item) {
        $food = ShoppingcartDB::getItemById($item[0]);
        $orderdb->insertOrderItem($orderid, $item[1], $item[2], $item[3], $item[4], $food);
    }
    $orderdb->updateOrder($total, 0, "", $orderid);
}