-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.php
executable file
·244 lines (217 loc) · 14.5 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Are you hungry? You are at the right place. We offer mouth watering foods at your doorstep. Click now and order food online.">
<meta name="author" content="Ashish Acharya, Bibek Mahat, Parask K. Bhandari, Suresh Dahal">
<meta name="theme-color" content="#F7922F">
<link rel="shortcut icon" href="./images/logo.png" type="image/x-icon">
<title>Menu | RestroHub</title>
<link rel="stylesheet" href="./styles/style.css">
<link rel="stylesheet" href="./styles/responsive.css">
</head>
<body>
<?php require("./components/header.php"); ?>
<!-- filter icon for small screen devices -->
<img src="./images/ic_filter.svg" alt="filter icon" class="menu_filter_icon">
<aside class="sidebar menu_sidebar shadow p_7-20">
<h4 class="heading">Filter</h4>
<div class="mt-20">
<input type="radio" onchange="vegFilter('all')" class="cbox-veg_nonveg" name="veg-filter" value="all" id="all" <?php if (isset($_GET['veg']) && $_GET['veg'] == "all") echo "checked"; ?>>
<label for="all"> All</label>
</div>
<div style="margin-top:10px">
<input type="radio" onchange="vegFilter(1)" class="cbox-veg_nonveg" name="veg-filter" value="veg" id="veg" <?php if (isset($_GET['veg']) && $_GET['veg'] == "1") echo "checked"; ?>>
<label for="veg"> Veg</label>
</div>
<div style="margin-top:10px">
<input type="radio" onchange="vegFilter(0)" class="cbox-veg_nonveg" name="veg-filter" value="non-veg" id="non-veg" <?php if (isset($_GET['veg']) && $_GET['veg'] == "0") echo "checked"; ?>>
<label for="non-veg"> Non-Veg</label>
</div>
</aside>
<main class="menu_container">
<div class="menu_container_inner">
<button class="go_top no_bg no_outline"><img src="./images/ic_top.svg" alt="go to top"></button>
<section class="food_categories">
<div class="flex items-center">
<h2 class="food_category-title heading"></h2>
<button class="toggle_categories button"></button>
</div>
<div class="category_container mt-20 flex gap wrap justify-center">
<!-- fetch categories from db -->
<?php
require("./config.php");
$sql = "SELECT image, cat_name FROM category";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
?>
<form action="./backend/category-filter.php" method="post" class="food_category">
<input type="hidden" name="cat-name" value="all">
<button class="text-center pointer no_bg no_outline" type="submit" name="category-filter">
<img src="./images/all.jpg" class="border-curve food_category-img" alt="all food">
<p class="food_category-name">All</p>
</button>
</form>
<?php
while ($row = mysqli_fetch_assoc($result)) {
?>
<form action="./backend/category-filter.php" method="post" class="food_category">
<input type="hidden" name="cat-name" value="<?php echo $row['cat_name']; ?>">
<button class="text-center pointer no_bg no_outline" type="submit" name="category-filter">
<img src="./uploads/category/<?php echo $row['image']; ?>" class="border-curve food_category-img" alt="food category">
<p class="food_category-name"><?php echo $row['cat_name']; ?></p>
</button>
</form>
<?php
}
} else
echo "No categories found";
?>
</div>
</section>
<div class="menu_food-card-category-container">
<!-- fetch categories from db -->
<?php
if (isset($_GET['veg'])) {
$isVeg = $_GET['veg'];
}
if (isset($_GET['search'])) {
$searchKey = $_GET['search'];
$sql = "SELECT * FROM food where name like '%$searchKey%'" . (isset($_GET['veg']) && $_GET['veg'] != "all" ? " and veg = '{$_GET['veg']}'" : "") . " order by f_id desc";
} else {
if (isset($_SESSION['cat_name']) && $_SESSION['cat_name'] !== "all") {
$sql = "SELECT cat_name FROM category where cat_name = '{$_SESSION['cat_name']}'";
} else {
$sql = "SELECT cat_name FROM category";
}
}
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
if (!isset($_GET['search'])) {
while ($row = mysqli_fetch_assoc($result)) {
?>
<section class="menu_food-card-container mt-20 flex direction-col">
<?php
$sql_food = "SELECT * FROM food inner join category on food.category = category.cat_id where category.cat_name = '$row[cat_name]' and disabled = 0" . (isset($_GET['veg']) && $_GET['veg'] != "all" ? " and veg = '{$_GET['veg']}'" : "") . " order by food.f_id desc";
$res = mysqli_query($conn, $sql_food);
if (mysqli_num_rows($res) > 0) {
?>
<h2 class="heading h2"><?php if (isset($row['cat_name']))
echo $row['cat_name'];
else
echo $searchKey; ?></h2>
<div class="food_cards mt-20 flex gap wrap justify-start">
<?php while ($data = mysqli_fetch_assoc($res)) {
?>
<div class="menu_food-card border-curve shadow">
<!-- testing badge or something for card -->
<p class="card__tag text-center heading">
<?php
if ($data['veg'] == 1)
echo "Veg";
else
echo "Non-veg";
?>
</p>
<div class="card__food-img">
<a href="./details.php?name=<?php echo str_replace(" ", "-", strtolower($data['name'])); ?>">
<img src="./uploads/foods/<?php echo $data['img']; ?>" alt="food image" class="border-curve food_img">
</a>
</div>
<article class="card__food-info flex items-center">
<a href="./details.php?name=<?php echo str_replace(" ", "-", strtolower($data['name'])); ?>">
<h2 class="card__food-title heading"><?php echo $data['name']; ?></h2>
</a>
<p class="card__food-price heading">Rs. <?php echo $data['price']; ?></p>
</article>
<p class="card__food-desc"><?php echo $data['short_desc']; ?></p>
<div class="card__btns flex">
<div class="form mr-10">
<a href="./details.php?name=<?php echo str_replace(" ", "-", strtolower($data['name'])); ?>" class="button card__btn flex justify-center border-curve" name="view"><img src="./images/ic_eye.svg" alt="view"></a>
</div>
<form action="./backend/add-to-cart.php" method="post" class="form_food-card" name="form_food-card">
<input type="hidden" name="f_id" value="<?php echo $data['f_id']; ?>">
<button type="button" class="button card__btn btn_add-to-cart flex justify-center border-curve" name="add-to-card"><img src="./images/ic_add-cart.svg" alt="add to cart"></button>
</form>
</div>
</div>
<?php }
}
?>
</div>
</section>
<?php }
} else {
?>
<section class="menu_food-card-container mt-20 flex direction-col">
<?php
$sql_food = "SELECT * FROM food where name like '%$searchKey%' and disabled = 0" . (isset($_GET['veg']) && $_GET['veg'] != "all" ? " and veg = '{$_GET['veg']}'" : "") . " order by f_id desc";
$res = mysqli_query($conn, $sql_food);
if (mysqli_num_rows($res) > 0) {
?>
<h2 class="heading h2"><?php if (isset($row['cat_name']))
echo $row['cat_name'];
else
echo $searchKey; ?></h2>
<div class="food_cards mt-20 flex gap wrap justify-start">
<?php while ($data = mysqli_fetch_assoc($res)) {
?>
<div class="menu_food-card border-curve shadow">
<!-- testing badge or something for card -->
<p class="card__tag text-center heading">
<?php
if ($data['veg'] == 1)
echo "Veg";
else
echo "Non-veg";
?>
</p>
<div class="card__food-img">
<a href="./details.php?name=<?php echo str_replace(" ", "-", strtolower($data['name'])); ?>">
<img src="./uploads/foods/<?php echo $data['img']; ?>" alt="food image" class="border-curve food_img">
</a>
</div>
<article class="card__food-info flex items-center">
<a href="./details.php?name=<?php echo str_replace(" ", "-", strtolower($data['name'])); ?>">
<h2 class="card__food-title heading"><?php echo $data['name']; ?></h2>
</a>
<p class="card__food-price heading">Rs. <?php echo $data['price']; ?></p>
</article>
<p class="card__food-desc"><?php echo $data['short_desc']; ?></p>
<div class="card__btns flex">
<div class="form mr-10">
<a href="./details.php?name=<?php echo str_replace(" ", "-", strtolower($data['name'])); ?>" class="button card__btn flex justify-center border-curve" name="view"><img src="./images/ic_eye.svg" alt="view"></a>
</div>
<form action="./backend/add-to-cart.php" method="post" class="form_food-card" name="form_food-card">
<input type="hidden" name="f_id" value="<?php echo $data['f_id']; ?>">
<button type="button" class="button card__btn btn_add-to-cart flex justify-center border-curve" name="add-to-card"><img src="./images/ic_add-cart.svg" alt="add to cart"></button>
</form>
</div>
</div>
<?php }
}
?>
</div>
</section>
<?php }
} else
echo "No food items found";
?>
</div>
</div>
<?php require("./components/footer.php"); ?>
</main>
<script>
function vegFilter(key) {
let searchKey = "<?php echo isset($_GET['search']) ? $_GET['search'] : ''; ?>";
if (searchKey != "")
window.location.href = "./menu.php?search=" + searchKey + "&veg=" + key;
else
window.location.href = "./menu.php?veg=" + key;
}
</script>
<script type="module" src="./js/app.js"></script>
</body>
</html>