$message .= "Order: Insert: " . ($orderId != -1 ? "Success, Id: {$orderId}" : "Failure") . "\n"; $message .= "WorkerId: {$workerId}\n\n"; $order = array_slice($order, 1); //Removes the student array order[0] from order. Moves all indexes forward. foreach ($order as $detail) { switch ($detail[0]) { case 0: //Custom Pizza $pizzaId = makeCustomPizza($detail[3], $detail[2]); //Size, ToppingArray makeOrderDetailPizza($orderId, $detail[1], $pizzaId); //orderId, Quantity, pizzaId break; case 1: //Specialty Pizza makeOrderDetailPizza($orderId, $detail[1], $detail[2]); //orderId, Quantity, pizzaId break; case 2: //Item makeOrderDetailItem($orderId, $detail[1], $detail[2]); //orderId, Quantity, pizzaId break; } } respond(0, $orderId); //echo $message; if ($removeData) { mysqli_query($GLOBALS["conn"], "TRUNCATE TABLE Pizza_Toppings;"); mysqli_query($GLOBALS["conn"], "TRUNCATE TABLE Order_Details;"); mysqli_query($GLOBALS["conn"], "TRUNCATE TABLE Pizza_Toppings;");
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); echo "Pizza 1. result: " . ($pizza_1 != -1 ? "Success (id: {$pizza_1})" : "Failure") . "<br>"; echo "Pizza 2. result: " . ($pizza_2 != -1 ? "Success (id: {$pizza_2})" : "Failure") . "<br>"; echo "Pizza 3. result: " . ($pizza_3 != -1 ? "Success (id: {$pizza_3})" : "Failure") . "<br>"; echo "<br>"; //Create Order_Details for these 3 pizzas to connect them to the order echo "Making Details for the Pizzas<br>"; $detail_1 = makeOrderDetailPizza($orderId, $quantity_pizza_1, $pizza_1); $detail_2 = makeOrderDetailPizza($orderId, $quantity_pizza_2, $pizza_2); $detail_3 = makeOrderDetailPizza($orderId, $quantity_pizza_3, $pizza_3); echo "Pizza 1 detail result: " . ($detail_1 ? "Success" : "Failure") . "<br>"; echo "Pizza 2 detail result: " . ($detail_2 ? "Success" : "Failure") . "<br>"; echo "Pizza 3 detail result: " . ($detail_3 ? "Success" : "Failure") . "<br>"; echo "<br>"; //Create Order_Details for 3 items to connect them to the order echo "Making Details for the Items<br>"; $detail_1 = makeOrderDetailItem($orderId, $quantity_item_1, $items[0]); $detail_2 = makeOrderDetailItem($orderId, $quantity_item_2, $items[1]); $detail_3 = makeOrderDetailItem($orderId, $quantity_item_3, $items[2]); echo "Item 1 detail result: " . ($detail_1 ? "Success" : "Failure") . "<br>"; echo "Item 2 detail result: " . ($detail_2 ? "Success" : "Failure") . "<br>"; echo "Item 3 detail result: " . ($detail_3 ? "Success" : "Failure") . "<br>"; echo "<br>"; echo "totalcost: " . mysqli_fetch_array(mysqli_query($GLOBALS["conn"], "SELECT totalCost FROM Orders WHERE orderId=" . $orderId . ";"))["totalCost"]; if ($removeData) {