<?php
include('includes/header.php');
?>
<!doctype html>
<html lang="en-us">
<head>
<title>Restaurant Order Calculator</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<h2> Welcome to Taylor's Restaurant!</h2>
<form method="post">
<h3>Please Select Your Order:</h3>
<input type="checkbox" name="food[]" value="Burger"> Burger($8) <br>
<input type="checkbox" name="food[]" value="Pizza"> Pizza($10) <br>
<input type="checkbox" name="food[]" value="Pasta"> Pasta($5) <br>
<input type="checkbox" name="food[]" value="Soda"> Soda($2) <br>
<input type="checkbox" name="food[]" value="Water"> Water($1) <br>
<input type="submit" name="order" value="Place Order">
</form>
<?php
if (isset($_POST['order']) && isset($_POST['food'])) {
$menu = [
"Burger" => 8,
"Pizza" => 10,
"Pasta" => 5,
"Soda" => 2,
"Water" => 1,
];
$selectedFoods = $_POST['food'];
$subtotal = 0;
echo "<h3>Your Order Receipt</h3>";
foreach ($selectedFoods as $item) {
$price = $menu[$item];
$subtotal += $price;
echo "$item - $$price <br>";
}
echo "Subtotal: $$subtotal <br>";
if ($subtotal > 15) {
$discount = $subtotal * 0.10;
$subtotal -= $discount;
echo "Discount (10%): -$" . number_format($discount, 2) . "<br>";
} else {
echo "No discount.<br>";
}
$tax = $subtotal * 0.06;
$total = $subtotal + $tax;
echo "Tax (6%): $" . number_format($tax, 2) . "<br>";
echo "Total: $" . number_format($total, 2) . "<br>";
} elseif (isset($_POST['order'])) {
echo "<p>Please Select At Least One Item.</p>";
}
include('includes/footer.php');
?>
</body>
</html>