-
Notifications
You must be signed in to change notification settings - Fork 5
/
housedetails.php
258 lines (230 loc) · 9.68 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
<?php
include 'inc/header.php';
include 'inc/navbar.php';
include 'Controller/Homecontroller.php';
?>
<div class="housedetails_area">
<div class="housedetails_main container">
<div class="housedetails_inner row">
<?php
$home = new Homecontroller();
if(isset($_GET['house_id'])){
$id = $_GET['house_id'];
}
$house = $home->gethomeDetails_obj($id);
$houseid = $house['id'];
$ownerid = $house['owner_id'];
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['free_home'])){
$req = $home->freeHome($houseid);
echo "<meta http-equiv='refresh' content='0'>";
}
?>
<?php
if(($_SERVER["REQUEST_METHOD"] === "POST") && isset($_POST['delhouse'])){
$home->deletehouse($houseid,Session::get('user_id'));
}
?>
<div class="house_slider col-sm-6">
<div class="house_slider_inner">
<div class="all_house_slider">
<?php if($house['img_1'] != ''){?>
<div class="single_house_slider">
<img src="<?php echo $house['img_1']; ?>" alt="">
</div>
<?php } ?>
<?php if($house['img_2'] != ''){?>
<div class="single_house_slider">
<img src="<?php echo $house['img_2']; ?>" alt="">
</div>
<?php } ?>
<?php if($house['img_3'] != ''){?>
<div class="single_house_slider">
<img src="<?php echo $house['img_3']; ?>" alt="">
</div>
<?php } ?>
</div>
<div class="house_description text-center" style="border: thin solid black;padding: 10px;">
<p class="text-wrap"><?php echo $house['description']; ?></p>
</div>
</div>
</div>
<div class="house_details col-sm-4">
<div class="house_details_inner">
<table>
<tr>
<td> <strong>Type:</strong> </td>
<td> <?php echo $house['house_type']; ?> </td>
</tr>
<tr>
<td> <strong>Rental value:</strong> </td>
<td>Ksh. <?php echo $house['rental_value']; ?> </td>
</tr>
<tr>
<td> <strong>Address:</strong> </td>
<td><?php echo $house['address']; ?></td>
</tr>
<tr>
<td> <strong>Road no:</strong> </td>
<td> <?php echo $house['road_no']; ?> </td>
</tr>
<tr>
<td> <strong>House no:</strong> </td>
<td> <?php echo $house['house_no']; ?> </td>
</tr>
<tr>
<td> <strong>Floor:</strong> </td>
<td> <?php echo $house['floor']; ?> </td>
</tr>
<tr>
<td> <strong>Bedroom:</strong> </td>
<td> <?php echo $house['bedroom']; ?> </td>
</tr>
<tr>
<td> <strong>Bathroom:</strong> </td>
<td> <?php echo $house['bathroom']; ?> </td>
</tr>
<tr>
<td> <strong>Dinning room:</strong> </td>
<td> <?php echo $house['dinning_room']; ?> </td>
</tr>
<tr>
<td> <strong>Kitchen:</strong> </td>
<td> <?php echo $house['kitchen']; ?> </td>
</tr>
<tr>
<td> <strong>balconies:</strong> </td>
<td> <?php echo $house['balconies']; ?> </td>
</tr>
</table>
</div>
</div>
<div class="action_area col-sm-2">
<div class="action_main">
<?php
$total_req = $home->totalRequest($houseid);
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['accept'])) {
$tenants_id = $_POST['tenant_id'];
$req = $home->acceptrequest($houseid,$tenants_id);
echo "<meta http-equiv='refresh' content='0'>";
}
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['reject'])) {
$tenants_id = $_POST['tenant_id'];
$req = $home->rejectrequest($houseid,$tenants_id);
echo "<meta http-equiv='refresh' content='0'>";
}
?>
<?php if($house['owner_id'] == Session::get('user_id')){ ?>
<div class="single_action">
<?php
if( $house['tenant_id'] != 0) {
$tenant = $home->getUser($house['tenant_id']);
?>
<div class="dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Booked by <a href="tenant_profile.php?tenant_id=<?php echo $tenant->id; ?>" target="_blank" ><?php echo $tenant->fname.' '.$tenant->lname; ?></a>
</button>
<div style="left:45px !important;" class="dropdown-menu">
<form class="dropdown-item" action="<?php echo $_SERVER['PHP_SELF'].'?house_id='.$house['id'];?>" method="post">
<input style="cursor:pointer;" type="submit" class="btn btn-default" name="free_home" value="Free">
</form>
</div>
</div>
<?php }else{?>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
Booked request<span style="margin-left:5px;" class="badge badge-light"><?php if(is_array($total_req)){echo count($total_req);} ?></span>
</button>
<?php } ?>
<form action="<?php echo $_SERVER['PHP_SELF'].'?house_id='.$houseid; ?>" method="post" style="margin-top:10px;">
<input type="submit" class="btn btn-danger" onclick="return confirm('Are you Sure to Delete?');" name="delhouse" value="Delete This House">
</form>
<!-- The Modal -->
<div style="top:200px;z-index:9999999999;" class="modal fade" id="myModal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">All requested for this home.</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<?php
if (count($total_req)>0) {
foreach ($total_req as $request) {
$tenant = $home->getUser($request['tenant_id']);
?>
<form class="" action="<?php echo $_SERVER['PHP_SELF'].'?house_id='.$house['id'];?>" method="post">
<div class="row">
<p style="padding-top:5px;" class="col-sm-6"> <a href="tenant_profile.php?tenant_id=<?php echo $tenant->id; ?>" target="_blank" > <?php echo $tenant->fname.' '.$tenant->lname; ?></a></p>
<input type="hidden" name="tenant_id" value="<?php echo $tenant->id; ?>">
<!-- <div class="profile_btn col-sm-2 ">
<a style="width:90%;color:#fff;cursor:pointer;" class="btn btn-info">Profile</a>
</div> -->
<div class="accept_btn col-sm-2 ">
<input style="width:90%;" class="btn btn-success" type="submit" name="accept" value="Accept">
</div>
<div class="reject_btn col-sm-2">
<input style="width:90%;" class="btn btn-danger" type="submit" name="reject" value="reject">
</div>
</div>
</form>
<?php
} }
?>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['request'])) {
$req = $home->sendrequest($houseid,$ownerid);
}
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['cancel'])) {
$cancel = $home->cancelrequest($houseid,$ownerid);
}
$check = $home->checkrequest($houseid);
?>
<?php if(Session::get('user') == 'tenant'){ ?>
<div class="single_action">
<form class="" action="<?php echo $_SERVER['PHP_SELF'].'?house_id='.$house['id'];?>" method="post">
<?php
if ($check=='no') {
?>
<input type="submit" class="btn btn-primary" name="request" value="Request for rent">
<?php }else if($check=='yes'){ ?>
<input type="submit" class="btn btn-danger" name="cancel" value="Cancel Booked">
<?php }else if($check=='booked'){ ?>
<p class="btn btn-primary">Booked by You</p>
<?php } ?>
</form>
</div>
<div class="single_action">
<a class="btn btn-info" href="owner_profile.php?owner_id=<?php echo $house['owner_id']; ?>">Contact to owner</a>
</div>
<?php } else if(!Session::get('user') == 'owner'){ ?>
<div class="single_action">
<a class="btn btn-info" onclick="loginpage(<?php echo $house['id']; ?>);">Contact to owner</a>
</div>
<?php } ?>
<script>
function loginpage($id){
<?php
Session::set('path',"housedetails.php?house_id=".$id);
?>
window.location = "user_login.php";
}
</script>
</div>
</div>
</div>
</div>
</div>
<?php
include 'inc/footer.php';
?>