-
Notifications
You must be signed in to change notification settings - Fork 0
/
property_detail.php
574 lines (505 loc) · 22.4 KB
/
property_detail.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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
<?php
session_start();
require "includes/database_connect.php";
// If http://domain:port/PGLIFE/property_detail.php link is directly opened without any "property_id" parameter passed, the user
// will be redirected to the index.php page
if( !isset($_GET["property_id"]) )
{
header("location: index.php");
exit();
}
//If connected to database successfully...
if( $con )
{
$pg_id = $_GET["property_id"];
$sql_query1 = "SELECT * FROM properties WHERE id=$pg_id; ";
$property_result = mysqli_query($con,$sql_query1);
if( !$property_result )
{
echo mysqli_error($con);
exit();
}
elseif( mysqli_num_rows($property_result)==0 )
{
//Code when SQL query gives empty set, i.e., no PG corresponding to provided PG id exists.
//This might happen when user manually tampers the URL parameters.
//In such case, user is redirected to index page
header("location: index.php");
exit();
}
elseif( mysqli_num_rows($property_result)==1 ) //PG id corresponds to correct single PG records
{
$property_row = mysqli_fetch_assoc($property_result);
$pg_city_id = $property_row["city_id"];
$pg_name = $property_row["name"];
$pg_address = $property_row["address"];
$pg_description = $property_row["description"];
$gender_allowed = $property_row["gender"];
$pg_rent = $property_row["rent"];
$pg_rating_clean = $property_row["rating_clean"];
$pg_rating_food = $property_row["rating_food"];
$pg_rating_safety = $property_row["rating_safety"];
$pg_rating_overall = round(( $property_row["rating_clean"] + $property_row["rating_food"] + $property_row["rating_safety"] )/3 , 1 );
$sql_query2 = "SELECT * FROM cities WHERE id=$pg_city_id; ";
$city_result = mysqli_query($con,$sql_query2);
if( !$city_result )
{
echo mysqli_error($con);
exit();
}
else{
$city_row = mysqli_fetch_assoc($city_result);
$city_name = $city_row["name"];
}
//Fetching the number of person that marked the property interested...
$sql_interest = "SELECT * FROM interested_users_properties WHERE property_id = $pg_id; ";
$interest_result = mysqli_query($con,$sql_interest);
if( $interest_result ){
$num_interested = mysqli_num_rows($interest_result);
}
}
}
else{
echo "Database Connectivity Error!";
echo mysqli_connect_error();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ganpati Paying Guest | PG Life</title>
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link href="https://use.fontawesome.com/releases/v5.11.2/css/all.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,300;1,400;1,600;1,700;1,800&display=swap" rel="stylesheet" />
<link href="css/common.css" rel="stylesheet" />
<link href="css/property_detail.css" rel="stylesheet" />
</head>
<body>
<!-- Header Section -->
<?php require "./includes/header.php"; ?>
<div id="loading">
</div>
<nav aria-label="breadcrumb">
<ol class="breadcrumb py-2">
<li class="breadcrumb-item">
<a href="index.php">Home</a>
</li>
<?php if($city_result){ ?>
<li class="breadcrumb-item">
<a href="property_list.php?city=<?php echo $city_name; ?>"><?php echo $city_name; ?></a>
</li>
<li class="breadcrumb-item active" aria-current="page">
<?php echo $pg_name; ?>
</li>
<?php } ?>
</ol>
</nav>
<?php
// Details of property when correct single property / pg is fetched from database
if( $property_result && mysqli_num_rows($property_result)==1 )
{
?>
<div id="property-images" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#property-images" data-slide-to="0" class="active"></li>
<li data-target="#property-images" data-slide-to="1" class=""></li>
<li data-target="#property-images" data-slide-to="2" class=""></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="img/properties/1/1d4f0757fdb86d5f.jpg" alt="slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="img/properties/1/46ebbb537aa9fb0a.jpg" alt="slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="img/properties/1/eace7b9114fd6046.jpg" alt="slide">
</div>
</div>
<a class="carousel-control-prev" href="#property-images" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#property-images" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<div class="property-summary page-container">
<div class="row no-gutters justify-content-between">
<div class="star-container" title="<?php echo $pg_rating_overall; ?>">
<!--
<i class="fas fa-star"></i> - full coloured star
<i class="fas fa-star-half-alt"></i> - half coloured star
<i class="far fa-star"></i> - full empty start
-->
<?php
$star_full = floor($pg_rating_overall);
$star_empty = 5-1-$star_full;
//Full coloured star loop
for( $i=1 ; $i<=$star_full ; $i++ ){
?> <i class="fas fa-star"></i> <?php
}
// Half coloured star placeholder
if( ($pg_rating_overall - $star_full)>0.2 && ($pg_rating_overall - $star_full)<0.8 ){
?> <i class="fas fa-star-half-alt"></i> <?php
}
elseif( ($pg_rating_overall - $star_full)>=0.8 ){
?> <i class="fas fa-star"></i> <?php
}
elseif( ($pg_rating_overall - $star_full)<=0.2 ){
?> <i class="far fa-star"></i> <?php
}
//Empty coloured star loop
for( $i=1 ; $i<=$star_empty ; $i++ ){
?> <i class="far fa-star"></i> <?php
}
?>
</div>
<div class="interested-container">
<?php
//During 1st time loading of page, checking if property is already marked interested by the logged in user, or not.
//This check is done to
if( isset($_SESSION["user_id"]) ){
//User is logged in...
$user_id = $_SESSION["user_id"];
$sql_isLiked = "SELECT * FROM interested_users_properties WHERE user_id = $user_id AND property_id = $pg_id";
$isLiked_result = mysqli_query($con, $sql_isLiked);
}
?>
<?php
if( isset($_SESSION["user_id"]) && mysqli_num_rows($isLiked_result)==1 ){
?>
<i class="is-interested-image fas fa-heart"></i>
<?php
}
else{
?>
<i class="is-interested-image far fa-heart"></i>
<?php
} ?>
<div class="interested-text">
<?php if( $interest_result )
{ ?>
<span class="interested-user-count">
<?php
//Printing the Number of users interested
if($num_interested>=0)
{echo $num_interested;}
else
{echo 0;}
?>
</span> interested
<?php
} ?>
</div>
</div>
</div>
<div class="detail-container">
<div class="property-name"><?php echo $pg_name; ?></div>
<div class="property-address"><?php echo $pg_address; ?></div>
<div class="property-gender">
<?php
if( $gender_allowed=='male' ){
?> <img src="img/male.png" /> <?php
}
elseif( $gender_allowed=='female' ){
?> <img src="img/female.png" /> <?php
}
else{
?> <img src="img/unisex.png" /> <?php
}
?>
</div>
</div>
<div class="row no-gutters">
<div class="rent-container col-6">
<div class="rent">Rs <?php echo $pg_rent; ?>/-</div>
<div class="rent-unit">per month</div>
</div>
<div class="button-container col-6">
<a href="#" class="btn btn-primary">Book Now</a>
</div>
</div>
</div>
<div class="property-amenities">
<div class="page-container">
<h1>Amenities</h1>
<div class="row justify-content-between">
<div class="col-md-auto">
<h5>Building</h5>
<?php
//Getting amenities of type=Building in corresponding PG / property
$query_building = "SELECT properties_amenities.id, property_id, amenity_id, amenities.name, amenities.type, amenities.icon FROM properties_amenities JOIN amenities ON properties_amenities.amenity_id=amenities.id WHERE amenities.type='Building' AND properties_amenities.property_id=$pg_id; ";
$result_building = mysqli_query($con,$query_building);
if( $result_building && mysqli_num_rows($result_building)>0 )
{
while( $building_row = mysqli_fetch_assoc($result_building) )
{
$amenity_name = $building_row["name"];
$amenity_icon = $building_row["icon"];
?>
<div class="amenity-container">
<img src="img/amenities/<?php echo $amenity_icon; ?>.svg">
<span> <?php echo $amenity_name; ?> </span>
</div>
<?php
}
}
?>
</div>
<div class="col-md-auto">
<h5>Common Area</h5>
<?php
//Getting amenities of type=Common Area in corresponding PG / property
$query_common_area = "SELECT properties_amenities.id, property_id, amenity_id, amenities.name, amenities.type, amenities.icon FROM properties_amenities JOIN amenities ON properties_amenities.amenity_id=amenities.id WHERE amenities.type='Common Area' AND properties_amenities.property_id=$pg_id; ";
$result_common_area = mysqli_query($con,$query_common_area);
if( $result_common_area && mysqli_num_rows($result_common_area)>0 )
{
while( $common_area_row = mysqli_fetch_assoc($result_common_area) )
{
$amenity_name = $common_area_row["name"];
$amenity_icon = $common_area_row["icon"];
?>
<div class="amenity-container">
<img src="img/amenities/<?php echo $amenity_icon; ?>.svg">
<span> <?php echo $amenity_name; ?> </span>
</div>
<?php
}
}
?>
</div>
<div class="col-md-auto">
<h5>Bedroom</h5>
<?php
//Getting amenities of type=Bedroom in corresponding PG / property
$query_bedroom = "SELECT properties_amenities.id, property_id, amenity_id, amenities.name, amenities.type, amenities.icon FROM properties_amenities JOIN amenities ON properties_amenities.amenity_id=amenities.id WHERE amenities.type='Bedroom' AND properties_amenities.property_id=$pg_id; ";
$result_bedroom = mysqli_query($con,$query_bedroom);
if( $result_bedroom && mysqli_num_rows($result_bedroom)>0 )
{
while( $bedroom_row = mysqli_fetch_assoc($result_bedroom) )
{
$amenity_name = $bedroom_row["name"];
$amenity_icon = $bedroom_row["icon"];
?>
<div class="amenity-container">
<img src="img/amenities/<?php echo $amenity_icon; ?>.svg">
<span> <?php echo $amenity_name; ?> </span>
</div>
<?php
}
}
?>
</div>
<div class="col-md-auto">
<h5>Washroom</h5>
<?php
//Getting amenities of type=Washroom in corresponding PG / property
$query_washroom = "SELECT properties_amenities.id, property_id, amenity_id, amenities.name, amenities.type, amenities.icon FROM properties_amenities JOIN amenities ON properties_amenities.amenity_id=amenities.id WHERE amenities.type='Washroom' AND properties_amenities.property_id=$pg_id; ";
$result_washroom = mysqli_query($con,$query_washroom);
if( $result_washroom && mysqli_num_rows($result_washroom)>0 )
{
while( $washroom_row = mysqli_fetch_assoc($result_washroom) )
{
$amenity_name = $washroom_row["name"];
$amenity_icon = $washroom_row["icon"];
?>
<div class="amenity-container">
<img src="img/amenities/<?php echo $amenity_icon; ?>.svg">
<span> <?php echo $amenity_name; ?> </span>
</div>
<?php
}
}
?>
</div>
</div>
</div>
</div>
<div class="property-about page-container">
<h1>About the PG</h1>
<p><?php echo $pg_description; ?></p>
</div>
<div class="property-rating">
<div class="page-container">
<h1>Property Rating</h1>
<div class="row align-items-center justify-content-between">
<div class="col-md-6">
<div class="rating-criteria row">
<div class="col-6">
<i class="rating-criteria-icon fas fa-broom"></i>
<span class="rating-criteria-text">Cleanliness</span>
</div>
<div class="rating-criteria-star-container col-6" title="<?php echo $pg_rating_clean; ?>">
<?php
$star_full = floor($pg_rating_clean);
$star_empty = 5-1-$star_full;
//Full coloured star loop
for( $i=1 ; $i<=$star_full ; $i++ ){
?> <i class="fas fa-star"></i> <?php
}
// Half coloured star placeholder
if( ($pg_rating_clean - $star_full)>0.2 && ($pg_rating_clean - $star_full)<0.8 ){
?> <i class="fas fa-star-half-alt"></i> <?php
}
elseif( ($pg_rating_clean - $star_full)>=0.8 ){
?> <i class="fas fa-star"></i> <?php
}
elseif( ($pg_rating_clean - $star_full)<=0.2 ){
?> <i class="far fa-star"></i> <?php
}
//Empty coloured star loop
for( $i=1 ; $i<=$star_empty ; $i++ ){
?> <i class="far fa-star"></i> <?php
}
?>
</div>
</div>
<div class="rating-criteria row">
<div class="col-6">
<i class="rating-criteria-icon fas fa-utensils"></i>
<span class="rating-criteria-text">Food Quality</span>
</div>
<div class="rating-criteria-star-container col-6" title="<?php echo $pg_rating_food; ?>">
<?php
$star_full = floor($pg_rating_food);
$star_empty = 5-1-$star_full;
//Full coloured star loop
for( $i=1 ; $i<=$star_full ; $i++ ){
?> <i class="fas fa-star"></i> <?php
}
// Half coloured star placeholder
if( ($pg_rating_food - $star_full)>0.2 && ($pg_rating_food - $star_full)<0.8 ){
?> <i class="fas fa-star-half-alt"></i> <?php
}
elseif( ($pg_rating_food - $star_full)>=0.8 ){
?> <i class="fas fa-star"></i> <?php
}
elseif( ($pg_rating_food - $star_full)<=0.2 ){
?> <i class="far fa-star"></i> <?php
}
//Empty coloured star loop
for( $i=1 ; $i<=$star_empty ; $i++ ){
?> <i class="far fa-star"></i> <?php
}
?>
</div>
</div>
<div class="rating-criteria row">
<div class="col-6">
<i class="rating-criteria-icon fa fa-lock"></i>
<span class="rating-criteria-text">Safety</span>
</div>
<div class="rating-criteria-star-container col-6" title="<?php echo $pg_rating_safety; ?>">
<?php
$star_full = floor($pg_rating_safety);
$star_empty = 5-1-$star_full;
//Full coloured star loop
for( $i=1 ; $i<=$star_full ; $i++ ){
?> <i class="fas fa-star"></i> <?php
}
// Half coloured star placeholder
if( ($pg_rating_safety - $star_full)>0.2 && ($pg_rating_safety - $star_full)<0.8 ){
?> <i class="fas fa-star-half-alt"></i> <?php
}
elseif( ($pg_rating_safety - $star_full)>=0.8 ){
?> <i class="fas fa-star"></i> <?php
}
elseif( ($pg_rating_safety - $star_full)<=0.2 ){
?> <i class="far fa-star"></i> <?php
}
//Empty coloured star loop
for( $i=1 ; $i<=$star_empty ; $i++ ){
?> <i class="far fa-star"></i> <?php
}
?>
</div>
</div>
</div>
<div class="col-md-4">
<div class="rating-circle">
<div class="total-rating"><?php echo $pg_rating_overall; ?></div>
<div class="rating-circle-star-container">
<?php
$star_full = floor($pg_rating_overall);
$star_empty = 5-1-$star_full;
//Full coloured star loop
for( $i=1 ; $i<=$star_full ; $i++ ){
?> <i class="fas fa-star"></i> <?php
}
// Half coloured star placeholder
if( ($pg_rating_overall - $star_full)>0.2 && ($pg_rating_overall - $star_full)<0.8 ){
?> <i class="fas fa-star-half-alt"></i> <?php
}
elseif( ($pg_rating_overall - $star_full)>=0.8 ){
?> <i class="fas fa-star"></i> <?php
}
elseif( ($pg_rating_overall - $star_full)<=0.2 ){
?> <i class="far fa-star"></i> <?php
}
//Empty coloured star loop
for( $i=1 ; $i<=$star_empty ; $i++ ){
?> <i class="far fa-star"></i> <?php
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="property-testimonials page-container">
<?php
$testimonial_query = "SELECT * FROM testimonials WHERE property_id=$pg_id; ";
$testimonial_result = mysqli_query($con,$testimonial_query);
if( !$testimonial_result )
{
//Code when testimonial_query failed to execute...
echo mysqli_error($con);
exit();
}
elseif( $testimonial_result && mysqli_num_rows($testimonial_result)>0 )
{
echo "<h1>What People Say</h1><hr />";
//Code to display the testimonials posted by different users
while( $testimonial_row = mysqli_fetch_assoc($testimonial_result) )
{
$testimonial_text = $testimonial_row["content"];
$testimonial_user = $testimonial_row["user_name"];
?>
<div class="testimonial-block">
<div class="testimonial-image-container">
<img class="testimonial-img" src="img/man.png">
</div>
<div class="testimonial-text">
<i class="fa fa-quote-left" aria-hidden="true"></i>
<p><?php echo $testimonial_text; ?></p>
</div>
<div class="testimonial-name">- <?php echo $testimonial_user; ?></div>
</div>
<?php
}
}
elseif( $testimonial_result && mysqli_num_rows($testimonial_result)==0 )
{
echo "<h1>Yet to be reviewed...</h1>";
}
?>
</div>
<?php
}
?>
<!-- Modal Pages -->
<?php require "./includes/signup_modal.php"; ?>
<?php require "./includes/login_modal.php" ?>
<!-- Footer -->
<?php require "./includes/footer.php" ?>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/property_detail.js"></script>
</body>
</html>
<?php mysqli_close($con); ?>