-
Notifications
You must be signed in to change notification settings - Fork 3
/
menu.php
175 lines (149 loc) · 5.64 KB
/
menu.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
session_start();
include('dbconnect.php');
$cusID = $_SESSION['cusID'];
$resID = $_REQUEST['resID'];
// $_SESSION['resID'] = $resID;
$query = "SELECT name FROM restaurant WHERE resID = '$resID'";
$result = mysqli_query($connection, $query);
$restaurant = mysqli_fetch_assoc($result);
$query = "SELECT food.foodID as foodID, food.foodName as foodName, food.price as price
FROM available_foods INNER JOIN food
ON available_foods.foodID = food.foodID
WHERE available_foods.resID = '$resID'";
$result = mysqli_query($connection, $query);
$foods = mysqli_fetch_all($result, MYSQLI_ASSOC);
$message = "";
// if (isset($_GET['message'])) {
// $message = $_GET['message'];
// echo '<script>';
// echo 'alert("'.$message.'")';
// echo '</script>';
// }
if (isset($_GET['message'])) {
$message = $_GET['message'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title><?php echo $restaurant['name']; ?></title>
</head>
<body>
<!-- Add your restaurant content here -->
<div class="restaurant-menu" id="restaurant1-menu">
<h1>Menu</h1>
<div class="menu-content">
<h3 class="restaurant-name"><?php echo $restaurant['name']; ?></h3>
<!-- <p class="restaurant-quantity">Items in Cart: <span id="restaurant-quantity-label">0</span></p> -->
<div class="menu-items">
<!-- Menu Items -->
<?php foreach($foods as $food): ?>
<div class="menu-item" data-id="<?php echo $food['foodID']; ?>" data-available-quantity="3">
<img class="menu-img" src="resources/<?php echo $food['foodID'];?>.png">
<div class="menu-desc">
<h4><?php echo $food['foodName']; ?></h4>
<p>$<?php echo $food['price']; ?></p>
<div class="cart-controls">
<form action="add-to-cart.php" method="post" class="add-to-cart-form">
<input type="hidden" name="cusID" value="<?php echo $cusID; ?>">
<input type="hidden" name="resID" value="<?php echo $resID; ?>">
<input type="hidden" name="foodID" class="food-id" value="<?php echo $food['foodID']; ?>">
<input type="hidden" name="price" class="food-price" value="<?php echo $food['price']; ?>">
<input type="number" name="quantity" class="food-quantity" value="0">
<input type="submit" class="add-to-cart-btn" name="Add to Cart">
</form>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<button class="cartbutton" onclick="window.location.href='cart.php'">Go to Cart</button>
</div>
<style>
.cartbutton{
margin: 0 auto;
margin-top: 30px;
background-color: white;
color: #87CEEB;
padding: 7px 9px;
border: none;
cursor: pointer;
width: 20%;
}
.restaurant-menu {
text-align: center;
margin:50px;
width:100% ;
display: grid;
padding: 5%;
border-radius: 8px;
gap: 1.5rpm;
overflow: hidden;
}
.menu-items {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 20px;
margin-top: 30px;
cursor: pointer;
}
.menu-item {
background-color: #f5f5f5;
border-radius: 10px;
padding: 20px;
text-align: center;
}
.menu-img {
max-width: 100%;
border-radius: 20px;
width: 150px;
height: 150px;
}
.menu-desc {
margin-top: 10px;
}
#restaurant1-menu ,#restaurant2-menu{
background-color: var(--secondaryColor);
border: #222;
}
.restaurant1-menu:hover ,.restaurant2-menu:hover{
background-color: var(--primaryColor);
color: var(--whiteColor);
}
</style>
<script>
// document.addEventListener("DOMContentLoaded", function () {
// const quantityInputs = document.querySelectorAll('.quantity-input');
// const totalPriceElements = document.querySelectorAll('.total-price');
// const quantityIncrementButtons = document.querySelectorAll('.quantity-increment');
// const quantityDecrementButtons = document.querySelectorAll('.quantity-decrement');
// const restaurantQuantityLabel = document.getElementById('restaurant-quantity-label');
// const addBtn = document.querySelectorAll('.add-to-cart-btn')
// addBtn.forEach(btn => {
// btn.addEventListener('click', () => {
// const foodId = btn.closest('.menu-item').dataset.id;
// const price = document.querySelector('.food-price').value;
// const quantity = document.querySelector('.food-quantity').value;
// document.querySelector('.food-id').value = foodId;
// document.querySelector('.food-price').value = price;
// document.querySelector('.food-quantity').value = quantity;
// document.querySelector('.add-to-cart-form').submit();
// });
// });
// })
function displayAlert(message) {
alert(message);
}
<?php if (isset($_GET['message'])): ?>
displayAlert("<?php echo $message; ?>");
<?php endif; ?>
</script>
</body>
</html>