-
Notifications
You must be signed in to change notification settings - Fork 0
/
houseDetails.php
283 lines (250 loc) · 10.6 KB
/
houseDetails.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
<?php
require("session.php");
require "connect.php";
$house = "";
if (isset($_POST["delete"])) {
$id_to_delete = mysqli_real_escape_string($conn, $_POST['id_to_delete']);
$sql = "DELETE FROM house WHERE house_id='$id_to_delete'";
if (mysqli_query($conn, $sql)) {
//successfullt deleted
header("Location: index.php");
} else {
//failure
echo 'query error:' . mysqli_error($conn);
}
}
if (isset($_GET["id"])) {
$id = mysqli_real_escape_string($conn, $_GET['id']);
$sql = "SELECT
house.house_id,
house_no,
house.type,
rent,
house.deposit_amt,
house.placement_fee,
house.description,
apartment.town,
apartment.type AS 'apartment_type',
apartment.location,
apartment.apartment_id,
apartment.name AS 'apartment_name',
owner.owner_id,
owner.name AS 'owner_name',
owner.phone AS 'owner_phone',
tenant.tenant_id,
tenant.name AS 'tenant_name',
tenant.phone AS 'tenant_phone'
FROM
house
JOIN apartment ON apartment.apartment_id = house.apartment_id
JOIN owner ON apartment.owner_id = owner.owner_id
LEFT JOIN assigned ON assigned.house_id = house.house_id
LEFT JOIN tenant ON tenant.tenant_id = assigned.tenant_id
WHERE
house.house_id = '$id';";
$result = mysqli_query($conn, $sql);
$house = mysqli_fetch_assoc($result);
}
?>
<?php include "header.php" ?>
<div class="banner_blur">
<div class="flex-1 min-w-0 p-5">
<div class=" flex items-center ">
<div class=" bg-yellow-100 rounded-full p-3 text-yellow-600 mr-4">
<svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" />
</svg>
</div>
<h1 class="text-4xl text-gray-900 sm:truncate">
House Information
</h1>
</div>
</div>
<div class="p-5">
<?php if (!isset($house["tenant_id"])) { ?>
<a href="/rms/asignHouse.php?house_id=<?php echo $id; ?>&apartment_id=<?php echo $house["apartment_id"]; ?>" class="btn primary">Place Tenant</a>
<?php } else { ?>
<a href="/rms/vacateHouse.php?house_id=<?php echo $house["house_id"]; ?>" class="btn primary">Vacate House</a>
<?php } ?>
</div>
</div>
<div class="bg-white shadow overflow-hidden sm:rounded-lg m-5 max-w-6xl">
<?php if ($house) { ?>
<div class="p-6 bg-gray-900">
<h3 class="text-3xl font-medium text-gray-300 overflow-hidden overflow-ellipsis">
<?php echo htmlspecialchars($house["house_no"]); ?>
</h3>
</div>
<div class="border-t border-gray-200 px-6 py-4 flex gap-4 ">
<div class="flex-1">
<h4 class=" font-medium text-base text-gray-900 uppercase mb-2 ">House Detail</h4>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
House no.
</dt>
<dd class="mt-1 text-base font-medium text-gray-900 sm:mt-0 sm:col-span-2">
<?php echo htmlspecialchars($house["house_no"]); ?>
</dd>
</div>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
Vacancy Status
</dt>
<dd class="mt-1 text-base font-medium text-gray-900 sm:mt-0 sm:col-span-2">
<?php if (!isset($house["tenant_id"])) { ?>
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800 ">vacant
</span>
<?php } else { ?>
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-yellow-100 text-red-800">
occupied
</span>
<?php } ?>
</dd>
</div>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
Description
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2 max-w-xs break-words">
<?php echo htmlspecialchars($house["description"]); ?>
</dd>
</div>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
House Type
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<?php echo htmlspecialchars($house["type"]); ?>
</dd>
</div>
<h4 class=" font-medium text-base text-gray-900 uppercase pt-4 mt-4 mb-2 ">Apartment Detail</h4>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
Apartment
</dt>
<dd class="mt-1 text-sm text-gray-900 hover:underline sm:mt-0 sm:col-span-2">
<a href="/rms/apartmentDetails.php?id=<?php echo $house["apartment_id"]; ?>" class="link">
<?php echo htmlspecialchars($house["apartment_name"]); ?>
</a>
</dd>
</div>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
Apartment Type
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<?php echo htmlspecialchars($house["apartment_type"]); ?>
</dd>
</div>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
Town
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<?php echo htmlspecialchars($house["town"]); ?>
</dd>
</div>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
Location
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2 max-w-xs break-words">
<?php echo htmlspecialchars($house["location"]); ?>
</dd>
</div>
</div>
<div class="flex-1">
<h4 class=" font-medium text-base text-gray-900 uppercase mb-2">Rent Detail</h4>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
Rent
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
Rs. <?php echo number_format(htmlspecialchars($house["rent"])); ?> /month
</dd>
</div>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
Deposit
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
Rs. <?php echo number_format(htmlspecialchars($house["deposit_amt"])); ?> refundable
</dd>
</div>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
Placement Fee
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
Rs. <?php echo number_format(htmlspecialchars($house["placement_fee"])); ?> one-time fee
</dd>
</div>
<?php if (isset($house["tenant_id"])) { ?>
<h4 class=" font-medium text-base text-gray-900 uppercase pt-4 mt-4 mb-2">Tenant Detail</h4>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
Name
</dt>
<dd class="mt-1 text-sm text-gray-900 hover:underline sm:mt-0 sm:col-span-2">
<a href="/rms/tenantDetails.php?id=<?php echo $house["tenant_id"]; ?>" class="link">
<?php echo htmlspecialchars($house["tenant_name"]); ?>
</a>
</dd>
</div>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
Contact
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<div>
<?php echo htmlspecialchars($house["tenant_phone"]); ?>
</div>
</dd>
</div>
<?php } ?>
<h4 class=" font-medium text-base text-gray-900 uppercase pt-4 mt-4 mb-2">Owner Detail</h4>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
Name
</dt>
<dd class="mt-1 text-sm text-gray-900 hover:underline sm:mt-0 sm:col-span-2">
<a href="/rms/ownerDetails.php?id=<?php echo $house["owner_id"]; ?>" class="link">
<?php echo htmlspecialchars($house["owner_name"]); ?>
</a>
</dd>
</div>
<div class=" px-4 py-1.5 sm:grid sm:grid-cols-3 sm:gap-2 sm:px-6">
<dt class="text-sm font-medium text-gray-500">
Contact
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<div>
<?php echo htmlspecialchars($house["owner_phone"]); ?>
</div>
</dd>
</div>
</div>
</div>
<div class="flex justify-end gap-4 pb-6 pr-6">
<form action="houseDetails.php" method="POST" onsubmit="return confirm('Are you really want to delete the House Data and its Payment History as well?')">
<input type="hidden" name="id_to_delete" value="<?php echo htmlspecialchars($house["house_id"]); ?>">
<input type="submit" name="delete" value="DELETE" class="btn secondary danger small w-auto">
</form>
<form action="editHouse.php" method="POST">
<input type="hidden" name="house_id" value="<?php echo htmlspecialchars($house["house_id"]); ?>">
<input type="submit" name="submit" value="Edit Details" class="btn primary small">
</form>
</div>
<?php } else { ?>
<div class="px-4 py-5 sm:px-6">
<h3 class="text-lg leading-6 font-medium text-gray-900">
House Information missing
</h3>
<p class="mt-1 max-w-2xl text-sm text-gray-500">
House do not exist
</p>
</div>
<?php } ?>
</div>
<?php include "footer.php" ?>
</html>