-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrooms.php
More file actions
255 lines (221 loc) · 10.9 KB
/
Copy pathrooms.php
File metadata and controls
255 lines (221 loc) · 10.9 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>GrandStay - ROOMS</title>
<link rel="icon" href="images/logo/hotel-logo.avif">
<?php require('inc/links.php'); ?>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body class="bg-light">
<?php require('inc/header.php'); ?>
<div class="my-5 px-4">
<h2 class="fw-bold h-font text-center">OUR ROOMS</h2>
<div class="h-line bg-dark "></div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-lg-3 col-md-12 mb-lg-0 mb-4 ps-4">
<nav class="navbar navbar-expand-lg navbar-light bg-white rounded shadow">
<div class="container-fluid flex-lg-column align-items-stretch">
<h4 class="mt-2">FILTERS</h4>
<button class="navbar-toggler shadow-none" type="button" data-bs-toggle="collapse" data-bs-target="#filterDropdown" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse flex-column align-items-stretch mt-2" id="filterDropdown">
<div class="border bg-light p-3 rounded mb-2">
<h5 class="mb-3" style="font-size: 18px;">CHECK AVAILABILITY</h5>
<label class="form-label">Check In</label>
<input type="date" id="check_in" class="form-control shadow-none">
<label class="form-label">Check Out</label>
<input type="date" id="check_out" class="form-control shadow-none">
</div>
<div class="border bg-light p-3 rounded mb-2">
<h5 class="mb-3" style="font-size: 18px;">FACILITIES</h5>
<div class="mb-2">
<input type="checkbox" id="facility1" class="form-check-input shadow-none me-1">
<label class="form-check-label" for="facility1">Facility one</label>
</div>
<div class="mb-2">
<input type="checkbox" id="facility2" class="form-check-input shadow-none me-1">
<label class="form-check-label" for="facility2">Facility two</label>
</div>
<div class="mb-2">
<input type="checkbox" id="facility3" class="form-check-input shadow-none me-1">
<label class="form-check-label" for="facility3">Facility three</label>
</div>
</div>
<div class="border bg-light p-3 rounded mb-2">
<h5 class="mb-3" style="font-size: 18px;">GUESTS</h5>
<div class="d-flex">
<div class="me-3">
<label class="form-label">Adults</label>
<input type="number" id="adults" class="form-control shadow-none">
</div>
<div>
<label class="form-label">Children</label>
<input type="number" id="children" class="form-control shadow-none">
</div>
</div>
</div>
<button class="btn btn-primary mt-3" id="filterButton">Apply Filters</button>
</div>
</div>
</nav>
</div>
<div class="col-lg-9 col-mb-12 px-4" id="rooms-data">
<div id="room-list" class="row mt-3">
<!-- Filtered rooms will be displayed here -->
</div>
<?php
$room_res = select("SELECT * FROM `rooms` WHERE `status`=? AND `remove`=? ORDER BY id DESC", [1, 0], 'ii');
while($room_data = mysqli_fetch_assoc($room_res))
{
// get feature of rooms
$fea_q = mysqli_query($con,"SELECT f.name FROM `features` f
INNER JOIN `room_features` rfea ON f.id = rfea.features_id
WHERE rfea.room_id = '$room_data[id]'");
$features_data = "";
while($fea_row = mysqli_fetch_assoc($fea_q)){
$features_data .="<span class='badge rounded-pill text-bg-light text-wrap me-1 mb-1'>
$fea_row[name]
</span>";
}
// get facilities of rooms
$fac_q = mysqli_query($con,"SELECT f.name FROM `facilities` f
INNER JOIN `room_facilities` rfac ON f.id = rfac.facilities_id
WHERE rfac.room_id = '$room_data[id]'");
$facilities_data = "";
while($fac_row = mysqli_fetch_assoc($fac_q)){
$facilities_data .="<span class='badge rounded-pill text-bg-light text-wrap me-1 mb-1'>
$fac_row[name]
</span>";
}
// Get thumbnail of the image
$room_thumb = ROOMS_IMG_PATH . "thumbnail.jpg"; // Default thumbnail
$thumb_q = mysqli_query($con, "SELECT `image` FROM `room_image`
WHERE `room_id` = '$room_data[id]' AND `thumb` = '1'");
if ($thumb_q && mysqli_num_rows($thumb_q) > 0) {
$thumb_res = mysqli_fetch_assoc($thumb_q);
if (!empty($thumb_res['image'])) {
$room_thumb = ROOMS_IMG_PATH . $thumb_res['image']; // Update with the actual thumbnail
}
}
$book_btn = "";
if(!$row['shutdown']){
$login=0;
if(isset($_SESSION['login']) && $_SESSION['login'] === true){
$login=1;
}
$book_btn = "<button onclick='checkLoginToBook($login,$room_data[id])' class='btn btn-sm w-100 text-white custom-bg shadow-none mb-2'>Book Now</button>";
}
// print room card
echo <<<data
<div class="card mb-4 border-0 shadow">
<div class="row g-0 p-3 align-items-center">
<div class="col-md-5 mb-lg-0 mb-md-0 mb-3">
<div id="roomCarousel" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item">
<img src="images/rooms/1.jpg" class="d-block w-100" >
</div>
<div class="carousel-item">
<img src="images/rooms/2.png" class="d-block w-100">
</div>
<div class="carousel-item">
<img src="images/rooms/3.png" class="d-block w-100" >
</div>
<div class="carousel-item">
<img src="images/rooms/4.png" class="d-block w-100" >
</div>
<div class="carousel-item">
<img src="images/rooms/5.png" class="d-block w-100" >
</div>
<div class="carousel-item active">
<img src="images/rooms/6.png" class="d-block w-100" >
</div>
<div class="carousel-item">
<img src="images/rooms/7.png" class="d-block w-100" >
</div>
<div class="carousel-item">
<img src="images/rooms/8.png" class="d-block w-100" >
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#roomCarousel" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#roomCarousel" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</div>
<div class="col-md-5 px-lg-3 px-mb-3 px-0">
<h5 class="mb-3">$room_data[name]</h5>
<div class="features mb-3">
<h6 class="mb-1">Features</h6>
$features_data
</div>
<div class="facilities mb-3">
<h6 class="mb-1">Facilities</h6>
$facilities_data
</div>
<div class="guest">
<h6 class="mb-1">Guest</h6>
<span class="badge rounded-pill text-bg-light text-wrap">
$room_data[adult] Adult
</span>
<span class="badge rounded-pill text-bg-light text-wrap">
$room_data[children] Children
</span>
</div>
</div>
<div class="col-md-2 mt-lg-0 mt-md-0 mt-4 text-center">
<h6 class="mb-4">₹$room_data[price] /- per night</h6>
$book_btn
<a href="room_details.php?id=$room_data[id]" class="btn btn-sm w-100 btn-outline-dark shadow-none">More details</a>
</div>
</div>
</div>
data;
}
?>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$('#filterButton').click(function() {
// Get filter values
var check_in = $('#check_in').val();
var check_out = $('#check_out').val();
var facilities = [];
if ($('#facility1').prop('checked')) facilities.push('Facility one');
if ($('#facility2').prop('checked')) facilities.push('Facility two');
if ($('#facility3').prop('checked')) facilities.push('Facility three');
var adults = $('#adults').val();
var children = $('#children').val();
// AJAX request to filter rooms
$.ajax({
type: 'POST',
url: 'filter_rooms.php',
data: {
check_in: check_in,
check_out: check_out,
facilities: facilities,
adults: adults,
children: children
},
success: function(response) {
// Show the filtered rooms in a specific div
$('#room-list').html(response);
}
});
});
});
</script>
<?php require('inc/footer.php');?>
</body>
</html>