<?php

include_once 'methods.php';
$removeData = false;
$message = "Recieved:\n";
$order;
$student;
$orderId;
$order = json_decode($_POST['order']);
foreach ($order as $value) {
    $message .= json_encode($value) . "\n";
}
$message .= "\n";
$student = $order[0];
//banner, fname, lname, email, phone
$result = makeStudent($student[0], $student[1], $student[2], $student[3], $student[4]);
$message .= "Student: " . json_encode($student) . "\n";
$message .= "Insert Status: " . ($result ? "Success" : "Failure") . "\n\n";
$workerId = getLeastBusyWorker();
//If count is more than 5, then we also have a hallId. Otherwise we will not insert a hallId
if (count($student) > 5) {
    $orderId = makeOrder($student[0], $workerId, $student[5]);
} else {
    $orderId = makeOrder($student[0], $workerId);
}
if ($orderId == -2) {
    respond(1);
}
$message .= "Order:  Insert: " . ($orderId != -1 ? "Success, Id: {$orderId}" : "Failure") . "\n";
$message .= "WorkerId: {$workerId}\n\n";
$order = array_slice($order, 1);
Пример #2
0
$workerId = rand(0, 1) == 0 ? "1" : "2";
$studentInfo = array("Johnny", "Football", "*****@*****.**", "7049950943");
$toppingIds_pizza_1 = array(1, 4, 5, 8, 11);
$toppingIds_pizza_2 = array(1, 3);
$toppingIds_pizza_3 = array();
$quantity_pizza_1 = 1;
$quantity_pizza_2 = 4;
$quantity_pizza_3 = 2;
$items = array(2, 4, 6);
//Cheese Bread (12in),   Cinnamon Knots,   Ranch
$quantity_item_1 = 2;
$quantity_item_2 = 1;
$quantity_item_3 = 3;
//Create a student entry
//                      bannerId      FirstName        LastName           Email         PhoneNumber
$student = makeStudent($studentId, $studentInfo[0], $studentInfo[1], $studentInfo[2], $studentInfo[3]);
echo "Creating student. Result: " . ($student ? "Success" : "Failure");
echo "<br>";
//Create an Order for Pickup.
//If deliver, call like:   $orderId = makeOrder($studentId, $hallId, $workerId);
//                    bannerId
$orderId = makeOrder($studentId, $workerId, $studentHall);
echo "Creating order.  Result: " . ($orderId != -1 ? "Success (id: {$orderId})" : "Failure") . "<br>";
//echo "Creating order. Result: " . ($orderId ? "Success" : "Failure");
echo "<br>";
//Insert 3 custom pizzas and their toppings (as defined in the topping arrays above)
echo "Inserting Custom Pizzas...<br>";
$pizza_1 = makeCustomPizza(1, $toppingIds_pizza_1);
//size(0= medium, 1=large)  toppingId array
$pizza_2 = makeCustomPizza(0, $toppingIds_pizza_2);
$pizza_3 = makeCustomPizza(1, $toppingIds_pizza_3);