-
Notifications
You must be signed in to change notification settings - Fork 0
/
rest_details.php
346 lines (306 loc) · 10.6 KB
/
rest_details.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
335
336
337
338
339
340
341
342
343
344
345
346
<?php
session_start();
include 'templates/header.php';
?>
<style>
.media-body{
font-size: 14px;
}
.textarea{
font-size: 12px;
}
</style>
<script>
document.body.setAttribute("data-spy", "scroll");
document.body.setAttribute("data-target", "#side-navigation");
document.body.setAttribute("data-offset", "80");
$(document).ready(function(){
// Add scrollspy to <body>
$('body').scrollspy({target: "#side-navigation", offset: 50});
// Add smooth scrolling on all links inside the navbar
$("#side-navigation a").on('click', function(event) {
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "") {
// Prevent default anchor click behavior
event.preventDefault();
// Store hash
var hash = this.hash;
// Using jQuery's animate() method to add smooth page scroll
// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 300, function(){
// Add hash (#) to URL when done scrolling (default click behavior)
window.location.hash = hash;
});
} // End if
});
});
</script>
<?php
include 'templates/navbar.php';
include 'templates/db-con.php';
function addcss(){
echo '<link rel="stylesheet" type="text/css" href="styles/rest_details.css">';
echo '<script src="scripts/fav.js"></script>';
echo '<script>$("body").scrollspy({ target: "#side-navigation" })</script>';
}
$rest_id=$_GET['rest_id'];
if(isset($_SESSION['uname'])){
$temp = $_SESSION['uname'];
$sql = "SELECT fname,lname FROM person where user_id = '$temp';";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) != 0) {
$row = mysqli_fetch_assoc($result);
$fname = $row['fname'];
$lname = $row['lname'];
}
}
$sql = "SELECT * FROM rest where rest_id = '$rest_id'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) != 0) {
$rest_data = mysqli_fetch_assoc($result);
}
$sql = "SELECT contact FROM rest_contact where rest_id = '$rest_id'";
$result = mysqli_query($conn, $sql);
$contact = array();
if (mysqli_num_rows($result) != 0) {
while($contact_data = mysqli_fetch_assoc($result))
{
$contact[] = $contact_data['contact'];
}
}
$sql = "select distinct category from menu";
$result = mysqli_query($conn, $sql);
$category = array();
if (mysqli_num_rows($result) != 0) {
while($category_data = mysqli_fetch_assoc($result))
{
$category[] = $category_data['category'];
}
}
?>
<div class="jumbotron jumbotron-fluid">
<div class="container-fluid">
<div class="row">
<div class="col-sm-3">
<img src="images/<?php echo abs(crc32($rest_id))%30; ?>.jpg" alt="<?php echo $rest_data['rest_name'];?>" class="img-thumbnail">
</div>
<div class="col-sm-9" id="rest-data">
<h1 class="display-4">
<?php echo $rest_data['rest_name'] ?></h1>
<p> <?php
$cuisine = explode(',', $rest_data['rest_cuisine']);
for ($x = 0; $x < sizeof($cuisine); $x++) {
echo $cuisine[$x];
if($x != sizeof($cuisine)-1)
echo ", ";
}
?>
</p>
<p>
<span class="fa fa-star" id="rating-star"></span>
<span id="rating-value" style="padding-right:50px"><?php echo $rest_data['rating'] ?></span>
<span id="cost-for-2" style="padding-right:50px;">Cost for two: ₹ <?php echo $rest_data['cost'] ?></span>
<span><button class="btn btn-light" id="fav-btn" onclick="add_fav(<?php echo $rest_id; ?>);">
<span id="fav-heart" class="
<?php
if(isset($_SESSION['uname'])){
$user_id = $_SESSION['uname'];
$sql = "select * from favourites where user_id = '$user_id' and rest_id = '$rest_id';";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) != 0)
echo 'fa fa-heart';
else
echo 'fa fa-heart-o';
}
else
echo 'fa fa-heart-o';
?>
"></span>Favourite</button></span>
<?php
if(isset($_SESSION['uname'])){ ?>
<a href = "reservation_form.php?rest_id=<?php echo $rest_id ?>">
<span><button class="btn btn-light" id="res-btn">
<span id="res-clock" class="fa fa-clock-o"></span>Reserve</button></span></a>
<?php
} ?>
</p>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-sm-2">
<div class="sticky-top">
<nav id="side-navigation">
<ul class="nav nav-pills flex-column side-nav bg-light">
<li class="nav-item" id="side-nav-item"><a href="#rest_info" class="nav-link" id="side-nav-link">About</a></li>
<li class="nav-item" id="side-nav-item"><a href="#menu" class="nav-link" id="side-nav-link">Menu</a>
<ul class="nav nav-pills nav-stacked bg-light inner-nav">
<?php
foreach ($category as $cat){
echo '<li class="nav-item ml-3 my-1" id="side-nav-item"><a class="nav-link" id="side-nav-link" href="#';
echo str_replace(' ', '-', $cat);
echo '" >';
echo $cat;
echo '</a></li>';
}
?>
</ul>
</li>
<li class="nav-item" id="side-nav-item"><a href="#reviews" class="nav-link" id="side-nav-link" >Reviews</a></li>
</ul>
</nav>
</div>
</div>
<div class="col-sm-10"><div class="container">
<div class="row" id="rest_info">
<div class="col-md">
<h1>Address</h1>
<div class="uline"></div>
<p><a target="_blank" href="https://maps.google.com/maps/search/<?php echo $rest_data['rest_name'];
echo ',';
echo $rest_data['rest_addr'];?>"><?php echo $rest_data['rest_addr']; ?></a></p>
</div>
<div class="col-md" >
<h1>Contact</h1>
<div class="uline"></div>
<p><?php
for ($x = 0; $x < sizeof($contact); $x++) {
echo $contact[$x];
if($x != sizeof($contact)-1)
echo ", ";
}
?></p>
</div>
<div class="col-md">
<h1>Timings</h1>
<div class="uline"></div>
<p>
<?php echo $rest_data['start_time'];
echo ' to ';
echo $rest_data['end_time'];
?>
</p>
</div>
</div>
</div>
<div class="table-responsive" id="menu">
<?php
foreach ($category as $cat){
echo '<h2 id="';
echo str_replace(' ', '-', $cat);
echo '">';
echo $cat;
echo "</h2>";
echo '<table class="table table-hover" id="menu-table">
<colgroup>
<col span="1" style="width: 20%;">
<col span="1" style="width: 70%;">
<col span="1" style="width: 10%;">
</colgroup>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Price</th>
</tr>
</thead>
<tbody>';
$sql = "SELECT item_name, description, price FROM menu WHERE category = '$cat'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) != 0) {
while($menu_item = mysqli_fetch_assoc($result))
{
echo "<tr>
<td>";
echo $menu_item['item_name'];
echo "</td>
<td>";
echo $menu_item['description'];
echo "</td>
<td>";
echo $menu_item['price'];
echo "</td>
</tr>";
}
}
echo '</tbody>
</table>';
}
?>
</div>
<hr> <h1 id="reviews">Reviews</h1><br>
<?php
if(isset($_SESSION['uname'])){ ?>
<div id="write-review">
<div class="media">
<img class="mr-3" src="images/profile.jpeg" alt="Generic placeholder image" height="64px" width="64px">
<div class="media-body">
<h4 class="mt-0"><?php echo $fname.' '.$lname;?></h4>
<div class="container">
<div class="row" style="margin-top:10px;">
<div class="col-md-6">
<div class="well well-sm">
<div class="text-right">
<a class="btn btn-info" href="#reviews-anchor" id="open-review-box"><h5 style><span class="glyphicon glyphicon-pencil"></span> Write Review</h5></a>
</div>
<div class="row" id="post-review-box" style="display:none;">
<div class="col-md-12">
<form accept-charset="UTF-8" method="post">
<input id="ratings-hidden" name="rating" type="hidden">
<textarea class="form-control animated" cols="50" id="new-review" name="comment" placeholder="Enter your review here..." rows="10" style="font-size:16px"></textarea>
<div class="text-right"style="padding-top:10px;">
<!--<div class="stars starrr" data-rating="0" style="font-size:22px;float:left"></div>-->
<a class="btn btn-danger btn-sm" href="#" id="close-review-box" style="display:none; margin-right: 10px;">
<h4><span class="glyphicon glyphicon-remove"></span> Cancel </h4></a>
<button class="btn btn-success btn-sm" type="submit" formaction="new_review.php?uid=<?php echo $_SESSION['uname'].'&rid='.$rest_id;?>"><h4><span class="glyphicon glyphicon-ok"></span> Save </h4></button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div><?php } ?>
<hr>
<div id="read-reviews">
<?php
$sql = "select user_id, comment,date_time from review where rest_id = '$rest_id' ORDER BY date_time DESC;";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) != 0) {
while($row = mysqli_fetch_assoc($result)){
$comment = $row['comment'];
$time = $row['date_time'];
$user_name = $row['user_id'];
$sql1 = "select fname, lname from person where user_id = '$user_name';";
$result1 = mysqli_query($conn, $sql1);
if (mysqli_num_rows($result) != 0) {
$row1 = mysqli_fetch_assoc($result1);
$fname = $row1['fname'];
$lname = $row1['lname'];?>
<div class="media">
<img class="mr-3" src="images/profile.jpeg" alt="Generic placeholder image" height="64px" width="64px">
<div class="media-body">
<h4 class="mt-0"><?php echo $fname.' '.$lname;?></h4>
<p><?php echo $time;?></p><hr><strong><?php echo $comment;?></strong><hr>
</div>
</div>
<?php
}
}
}
?>
</div>
</div>
</div>
</div>
<hr>
<?php
include 'templates/footer.php';
?>