-
Notifications
You must be signed in to change notification settings - Fork 0
/
property_list.php
237 lines (216 loc) · 8.63 KB
/
property_list.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
<?php
session_start();
require "includes/database_connect.php";
$user_id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : NULL;
$city_name = $_GET["city"];
$sql_1 = "SELECT * FROM cities WHERE name = '$city_name'";
$result_1 = mysqli_query($conn, $sql_1);
if (!$result_1) {
echo "Something went wrong!";
return;
}
$city = mysqli_fetch_assoc($result_1);
if (!$city) {
echo "Sorry! We do not have any PG listed in this city.";
return;
}
$city_id = $city['id'];
$sql_2 = "SELECT * FROM properties WHERE city_id = $city_id";
$result_2 = mysqli_query($conn, $sql_2);
if (!$result_2) {
echo "Something went wrong!";
return;
}
$properties = mysqli_fetch_all($result_2, MYSQLI_ASSOC);
$sql_3 = "SELECT *
FROM interested_users_properties iup
INNER JOIN properties p ON iup.property_id = p.id
WHERE p.city_id = $city_id";
$result_3 = mysqli_query($conn, $sql_3);
if (!$result_3) {
echo "Something went wrong!";
return;
}
$interested_users_properties = mysqli_fetch_all($result_3, MYSQLI_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Best PG's in <?php echo $city_name ?> | PG Life</title>
<?php
include "includes/head_links.php";
?>
<link href="css/property_list.css" rel="stylesheet" />
</head>
<body>
<?php
include "includes/header.php";
?>
<nav aria-label="breadcrumb">
<ol class="breadcrumb py-2">
<li class="breadcrumb-item">
<a href="index.php">Home</a>
</li>
<li class="breadcrumb-item active" aria-current="page">
<?php echo $city_name; ?>
</li>
</ol>
</nav>
<div class="page-container">
<div class="filter-bar row justify-content-around">
<div class="col-auto" data-toggle="modal" data-target="#filter-modal">
<img src="img/filter.png" alt="filter" />
<span>Filter</span>
</div>
<div class="col-auto">
<img src="img/desc.png" alt="sort-desc" />
<span>Highest rent first</span>
</div>
<div class="col-auto">
<img src="img/asc.png" alt="sort-asc" />
<span>Lowest rent first</span>
</div>
</div>
<?php
foreach ($properties as $property) {
$property_images = glob("img/properties/" . $property['id'] . "/*");
?>
<div class="property-card row">
<div class="image-container col-md-4">
<img src="<?= $property_images[0] ?>" />
</div>
<div class="content-container col-md-8">
<div class="row no-gutters justify-content-between">
<?php
$total_rating = ($property['rating_clean'] + $property['rating_food'] + $property['rating_safety']) / 3;
$total_rating = round($total_rating, 1);
?>
<div class="star-container" title="<?= $total_rating ?>">
<?php
$rating = $total_rating;
for ($i = 0; $i < 5; $i++) {
if ($rating >= $i + 0.8) {
?>
<i class="fas fa-star"></i>
<?php
} elseif ($rating >= $i + 0.3) {
?>
<i class="fas fa-star-half-alt"></i>
<?php
} else {
?>
<i class="far fa-star"></i>
<?php
}
}
?>
</div>
<div class="interested-container">
<?php
$interested_users_count = 0;
$is_interested = false;
foreach ($interested_users_properties as $interested_user_property) {
if ($interested_user_property['property_id'] == $property['id']) {
$interested_users_count++;
if ($interested_user_property['user_id'] == $user_id) {
$is_interested = true;
}
}
}
if ($is_interested) {
?>
<i class="fas fa-heart"></i>
<?php
} else {
?>
<i class="far fa-heart"></i>
<?php
}
?>
<div class="interested-text"><?= $interested_users_count ?> interested</div>
</div>
</div>
<div class="detail-container">
<div class="property-name"><?= $property['name'] ?></div>
<div class="property-address"><?= $property['address'] ?></div>
<div class="property-gender">
<?php
if ($property['gender'] == "male") {
?>
<img src="img/male.png" />
<?php
} elseif ($property['gender'] == "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">₹ <?= number_format($property['rent']) ?>/-</div>
<div class="rent-unit">per month</div>
</div>
<div class="button-container col-6">
<a href="property_detail.php?property_id=<?= $property['id'] ?>" class="btn btn-primary">View</a>
</div>
</div>
</div>
</div>
<?php
}
if (count($properties) == 0) {
?>
<div class="no-property-container">
<p>No PG to list</p>
</div>
<?php
}
?>
</div>
<div class="modal fade" id="filter-modal" tabindex="-1" role="dialog" aria-labelledby="filter-heading" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="filter-heading">Filters</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<h5>Gender</h5>
<hr />
<div>
<button class="btn btn-outline-dark btn-active">
No Filter
</button>
<button class="btn btn-outline-dark">
<i class="fas fa-venus-mars"></i>Unisex
</button>
<button class="btn btn-outline-dark">
<i class="fas fa-mars"></i>Male
</button>
<button class="btn btn-outline-dark">
<i class="fas fa-venus"></i>Female
</button>
</div>
</div>
<div class="modal-footer">
<button data-dismiss="modal" class="btn btn-success">Okay</button>
</div>
</div>
</div>
</div>
<?php
include "includes/signup_modal.php";
include "includes/login_modal.php";
include "includes/footer.php";
?>
</body>
</html>