-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
334 lines (272 loc) · 12 KB
/
index.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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<?php
session_start();
include($_SERVER['DOCUMENT_ROOT'] . '/Model/product_service.php');
include($_SERVER['DOCUMENT_ROOT'] . '/Model/category_service.php');
$productService = new ProductService();
$categoryService = new CategoryService();
if (count($categoryService->getAllCategories()) > 0) {
$categories = $categoryService->getCategories();
}
$cart_count = 0;
if (isset($_SESSION["authenticated"])) {
$productService->getCart();
$cart_count = $productService->getCartCount();
$email = $_SESSION["email"];
}
?>
<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" />
<link rel="shortcut icon" href="./Images/logo.png" type="image/x-icon" />
<link rel="stylesheet" href="./View/style.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="./View/mediaquery.css" />
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://kit.fontawesome.com/09789629f4.js" crossorigin="anonymous"></script>
<title>Fast Food</title>
</head>
<body>
<!---Preloader start--->
<div id="loader"></div>
<!---Preloader end--->
<div class="content">
<!--Nav bar -- Start -->
<nav class="navbar navbar-expand-lg navbar-dark fixed-top navTop">
<div class="container-fluid">
<a class="navbar-brand" href="#"><img src="./Images/logo.png" alt="" height="70px" width="70px" /></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mx-auto mb-2 mb-lg-0">
<li class="nav-item mx-auto">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item mx-auto">
<a class="nav-link" href="#product_list">Browse Foods</a>
</li>
<li class="nav-item mx-auto">
<a class="nav-link" href="#">Services</a>
</li>
<li class="nav-item mx-auto">
<a class="nav-link" href="/View/About Us/about_us.php">About Us</a>
</li>
</ul>
<!-- cart Button trigger modal start -->
<form class="d-flex">
<a href="/View/Cart/cart.php" class="btn btn-primary mx-auto position-relative">
<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">
<?php echo $cart_count ?>
<span class="visually-hidden">
cart items
</span>
</span>
<i class="fa-solid fa-cart-shopping"></i>
</a>
</form>
<!-- cart Button trigger modal end -->
<div data-bs-toggle="collapse" style="width: 20px"></div>
<!-- Account Button trigger modal start-->
<?php if (isset($_SESSION["authenticated"])) { ?>
<form class="d-flex me-3">
<button type="button" class="btn btn-primary mx-auto " data-bs-toggle="modal" data-bs-target="#ProfileIntro"><i class="fa-solid fa-user"></i> My Profile </button>
</form>
<form class="d-flex">
<a class="btn btn-primary mx-auto " href="./View//Login/logout.php" role="button"><i class="fa fa-sign-out" aria-hidden="true"></i> </i> </a>
</form>
<?php } else { ?>
<form class="d-flex">
<a class="btn btn-primary mx-auto " href="./View/Login/login.php" role="button"><i class="fa-solid fa-user"></i> Account </a>
</form>
<?php } ?>
<!-- Account Button trigger modal end-->
</div>
</div>
</nav>
<!---Navbar -- End-->
<!---Landing Page --- Start-->
<div class="container-fluid">
<br><br>
<div class="row landing-page pt-20">
<!--Left Column start --->
<div class="col-12 col-lg-5 col-md-5 col-sm-12 d-flex flex-column justify-content-center px-5 newCol">
<div class="mt-4 p-5 text-white rounded">
<h1>Fast Food</h1>
<h6>Find your favorite & delicous foods from here !</h6>
<br>
<form action="./View/category.php" method="post">
<div class="row">
<div class="col-12 col-lg-5 d-flex flex-column align-items-center justify-content-center mb-2">
<select class="form-control m-0" id="categorySelection" name="categories">
<option value="null" selected> All Categories</option>
<?php if (isset($categories)) {
foreach ($categories as $cat) {
?>
<option value="<?php echo $cat->getName() ?>">
<?php echo $cat->getName() ?> (<?php echo $cat->getProduct_count() ?>)
</option>
<?php }
} ?>
</select>
</div>
<div class="col-12 col-lg-6 d-flex flex-column align-items-lg-start justify-content-center mb-2">
<button class="btn btn-primary" type="submit"><i class="fa-solid fa-bowl-food"></i> Browse Foods</button>
</div>
</div>
</form>
</div>
<br />
</div>
<!--Left Column end --->
<!--Right Column start --->
<div class="col-12 col-lg-7 col-md-7 col-sm-12 d-flex flex-column justify-content-center newCol">
<div id="carouselExampleControls" class="carousel slide w-70 " data-bs-ride="carousel">
<div class="carousel-inner w-70">
<div class="carousel-item active w-70">
<img src="./Images/home-img-1.png" class="d-block w-70" alt="...">
</div>
<div class="carousel-item w-70 ">
<img src="./Images/home-img-2.png" class="d-block w-70" alt="...">
</div>
<div class="carousel-item w-70">
<img src="./Images/home-img-3.png" class="d-block w-70" alt="...">
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</div>
<!--Right Column end --->
</div>
</div>
<!---Landing Page --- End-->
<br><br>
<!---Search & Sort Row Start-->
<div class="container">
<div class="row w-100">
<div class="col-6 d-flex justify-content-center">
<div class="input-group">
<span class="input-group-text bg-primary text-light" id="basic-addon1"><i class="fa fa-search" aria-hidden="true"></i></span>
<input type="text" class="form-control" placeholder="Search your favorite food" aria-label="Search" aria-describedby="basic-addon1">
</div>
</div>
<div class="col-6 d-flex justify-content-end">
<a class="btn btn-outline-primary btn-sm d-flex align-items-center" href="#" role="button">Sort <i class="fa-solid fa-arrow-down-short-wide"></i> </a>
</div>
</div>
</div>
<!---Search & Sort Row End-->
<br><br>
<!--Product Item List Start-->
<div class="container">
<div class="row w-100 d-sm-flex justify-content-center" id="product_list">
<!-------Product Items Start #from database-->
<?php
if (isset($_GET["cato"])) {
$productService->showAllProducts($_GET["cato"]);
} else {
$productService->showAllProducts("null");
}
?>
</div>
</div>
<!-------Product Items End-->
</div>
<!---Product Item List End--->
<br><br>
<!----Pagination Start-->
<div>
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">Next</a></li>
</ul>
</nav>
</div>
<!------Pagination end-->
</div>
<!---toast-Start-->
<div class="toast-container position-fixed bottom-0 end-0 p-3">
<div id="toastmessage" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img src="./Images/icons8-close-64.png" class="rounded me-2" alt="error-icon" height="30" width="30">
<strong class="me-auto" id="heading">Error !</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
</div>
</div>
</div>
<!--- toast-End-->
<!-- Profile Intro Start -->
<?php if (isset($_SESSION["authenticated"])) { ?>
<div class="modal fade" id="ProfileIntro" tabindex="-1" aria-labelledby="ProfileIntroLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="avatar-pic text-center" style="width: 100%;">
<img src="<?php echo "data:image/jpeg;base64," . base64_encode($_SESSION['avatar']) . ""; ?>" alt="" id="avatar" height="150" width=150 class="rounded-circle m-4 mb-2">
</div>
<div class="user-details text-center">
<h4><?php echo "" . $_SESSION["fname"] . " " . $_SESSION["lname"] . "" ?></h4>
<p><?php echo $email ?></p>
<br><br>
</div>
</div>
<div class="modal-footer d-flex justify-content-center">
<a class="btn btn-primary" href="#" role="button"> View Profile</a>
</div>
</div>
</div>
</div>
<?php } ?>
<!-- Profile Intro End -->
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="./View/script.js"></script>
<script>
changeSelected('<?php echo isset($_GET["cato"]) ? $_GET["cato"] : "null" ?>')
</script>
<!---Toast Trigger---->
<?php if (isset($_GET["status"])) { ?>
<?php if ($_GET["status"] == "auth_fail") { ?>
<script>
showToast("Please login to continue !", true);
</script>
<?php } else if ($_GET["status"] == "added") { ?>
<script>
showToast("Added to cart successfully !", false);
</script>
<?php } else if ($_GET["status"] == "login_success") { ?>
<script>
showToast("Hey " + '<?php echo $_SESSION["lname"] ?>' + " Welcome Back !", false);
</script>
<?php } else if ($_GET["status"] == "register_success") { ?>
<script>
showToast("Hello " + '<?php echo $_SESSION["lname"] ?>' + " Welcome to fast food !", false);
</script>
<?php } else if ($_GET["status"] == "order_placed") { ?>
<script>
showToast("Order Placed Successfully !", false);
</script>
<?php } ?>
<?php } ?>
<script>
if (typeof window.history.pushState == 'function') {
window.history.pushState({}, "Hide", "/index.php");
}
</script>
</body>
</html>