-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathallocate_room.php
446 lines (384 loc) · 14.3 KB
/
allocate_room.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
<?php
require 'includes/config.inc.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title> HMS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<meta name="keywords" content="Intrend Responsive web template, Bootstrap Web Templates, Flat Web Templates, Android Compatible web template,
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyEricsson, Motorola web design" />
<script type="application/x-javascript">
addEventListener("load", function () {
setTimeout(hideURLbar, 0);
}, false);
function hideURLbar() {
window.scrollTo(0, 1);
}
</script>
<link rel="stylesheet" href="web_home/css_home/bootstrap.css">
<link rel="stylesheet" href="web_home/css_home/style.css" type="text/css" media="all" />
<link rel="stylesheet" href="web_home/css_home/fontawesome-all.css">
<link href="//fonts.googleapis.com/css?family=Poiret+One&subset=cyrillic,latin-ext" rel="stylesheet">
<link href="//fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i&subset=cyrillic,cyrillic-ext,greek,greek-ext,latin-ext,vietnamese" rel="stylesheet">
</head>
<body style="font-family: 'Times New Roman', serif;">
<div class="inner-page-banner" id="home">
<br>
<div class="container">
<div class="row">
<div class="col-md-7 col-12">
<img src="https://www.iiests.ac.in/assets/images/iiest.png" style="width: 40%" >
</div>
<div class="col-md-5 col-12">
<img src="https://www.iiests.ac.in/assets/images/banner2.png" style="height: 60px;">
</div>
</div>
</div>
<br>
<header style="background-color: rgb(25, 25, 112)">
<div class="container agile-banner_nav">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<h1><a class="navbar-brand" href="home_manager.php">HMS<span class="display"></span></a></h1>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-center" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="home_manager.php">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="allocate_room.php">Allocate Room</a>
<li class="dropdown nav-item">
<a href="#" class="dropdown-toggle nav-link" data-toggle="dropdown">Rooms
<b class="caret"></b>
</a>
<ul class="dropdown-menu agile_short_dropdown">
<li>
<a href="allocated_rooms.php">Allocated Rooms</a>
</li>
<li>
<a href="empty_rooms.php">Empty Rooms</a>
</li>
<li>
<a href="add_room.php">Add Rooms</a>
</li>
<li>
<a href="vacate_rooms.php">Vacate Rooms</a>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="message_hostel_manager.php">Messages Received</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact_manager.php">Contact</a>
</li>
<li class="dropdown nav-item">
<a href="#" class="dropdown-toggle nav-link" data-toggle="dropdown"><?php echo $_SESSION['username']; ?>
<b class="caret"></b>
</a>
<ul class="dropdown-menu agile_short_dropdown">
<li>
<a href="admin/manager_profile.php">My Profile</a>
</li>
<li>
<a href="includes/logout.inc.php">Logout</a>
</li>
</ul>
</li>
</ul>
</div>
</nav>
</div>
</header>
</div>
<br><br><br>
<section class="contact py-5">
<div class="container">
<div class="mail_grid_w3l">
<form action="allocate_room.php" method="post">
<div class="row">
<div class="col-md-9">
<input type="text" placeholder="Search by Roll Number" name="search_box">
</div>
<div class="col-md-3">
<input type="submit" value="Search" name="search"></input>
</div>
</div>
</form>
</div>
</div>
</section>
<?php
if (isset($_POST['search'])) {
$search_box = $_POST['search_box'];
$hostel_id = $_SESSION['hostel_id'];
$query_search = "SELECT * FROM Application WHERE Student_id like '$search_box%' and Hostel_id = '$hostel_id' and Application_status = '1'";
$result_search = mysqli_query($conn,$query_search);
$query6 = "SELECT * FROM Hostel WHERE Hostel_id = '$hostel_id'";
$result6 = mysqli_query($conn,$query6);
$row6 = mysqli_fetch_assoc($result6);
$hostel_name = $row6['Hostel_name'];
?>
<div class="container">
<table class="table table-hover">
<thead>
<tr>
<th>Student Name</th>
<th>Student ID</th>
<th>Hostel</th>
<th>Address</th>
<th>Distance</th>
<th>Income</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<?php
if(mysqli_num_rows($result_search)==0){
echo '<tr><td colspan="4">No Rows Returned</td></tr>';
}
else{
while($row_search = mysqli_fetch_assoc($result_search)){
$student_id = $row_search['Student_id'];
$query7 = "SELECT * FROM Student WHERE Student_id = '$student_id'";
$result7 = mysqli_query($conn,$query7);
$row7 = mysqli_fetch_assoc($result7);
$student_name = $row7['Fname']." ".$row7['Lname'];
$distance=$row7['Distance'];
echo "<tr><td>{$student_name}</td><td>{$row_search['Student_id']}</td><td>{$hostel_name}</td><td>{$row7['Address']}</td><td>{$distance}</td><td>{$row7['Income']}</td><td>{$row_search['Message']}</td></tr>\n";
}
}
?>
</tbody>
</table>
</div>
<?php
}
?>
<div class="container">
<h2 class="heading text-capitalize mb-sm-5 mb-4"> Applications Received </h2>
<?php
$hostel_id = $_SESSION['hostel_id'];
$query1 = "SELECT * FROM Application where Hostel_id = '$hostel_id' and Application_status = '1' ORDER BY Date, Time ASC";
$result1 = mysqli_query($conn,$query1);
$query6 = "SELECT * FROM Hostel WHERE Hostel_id = '$hostel_id'";
$result6 = mysqli_query($conn,$query6);
$row6 = mysqli_fetch_assoc($result6);
$hostel_name = $row6['Hostel_name'];
?>
<table class="table table-hover">
<thead>
<tr>
<th>Date</th>
<th>Time</th>
<th>Student Name</th>
<th>Student ID</th>
<th>Hostel</th>
<th>Address</th>
<th>Distance</th>
<th>Income</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<?php
if(mysqli_num_rows($result1)==0){
echo '<tr><td colspan="7">No Rows Returned</td></tr>';
}
else{
while($row1 = mysqli_fetch_assoc($result1)){
$student_id = $row1['Student_id'];
$query7 = "SELECT * FROM Student WHERE Student_id = '$student_id'";
$result7 = mysqli_query($conn,$query7);
$row7 = mysqli_fetch_assoc($result7);
$student_name = $row7['Fname']." ".$row7['Lname'];
echo "<tr><td>{$row1['Date']}</td><td>{$row1['Time']}</td><td>{$student_name}</td><td>{$row1['Student_id']}</td><td>{$hostel_name}</td><td>{$row7['Address']}</td><td>{$row7['Distance']}</td><td>{$row1['Income']}</td><td>{$row1['Message']}</td>";
echo "</tr>\n";
}
}
?>
</tbody>
</table>
</div>
<section class="contact py-5">
<div class="container">
<div class="mail_grid_w3l">
<form action="allocate_room.php" method="post">
<div class="row">
<input type="submit" value="Allocate" name="submit">
</div>
</form>
</div>
</div>
</section>
<br>
<br>
<br>
<footer class="py-5" style="background: rgb(25, 25, 112)">
<div class="container py-md-3">
<div class="footer" style="background: rgb(25, 25, 112)">
<div class="row" >
<div class="col-12 col-sm-7 ">
<div class="footer-logo mb-5 text-center">
<a class="navbar-brand mb-2" href="https://www.iiests.ac.in/" target="_blank">IIEST <span class="display"> SHIBPUR</span></a>
</div>
<div class="row">
<div class="col-4 col-sm-1">
<ul class="footer-nav text-center">
<li>
<a href="home_manager.php">Home</a>
</li>
<li>
<a href="allocate_room.php">Allocate</a>
</li>
<li>
<a href="contact_manager.php">Contact</a>
</li>
<li>
<a href="admin/manager_profile.php">Profile</a>
</li>
</ul>
</div>
<div class="col-7 offset-2 col-sm-6">
<div style="color:white;">
<h3>Our Address</h3>
<address>
Shibpur, Howrah<br>
<i class="fa fa-phone fa-lg"></i>:(+91) 62967 86304<br>
<i class="fa fa-envelope fa-lg"></i> :
<a href="mailto:[email protected]" style="color: white">[email protected]</a>
</address>
</div>
</div>
</div>
<div class="row">
<div class="col-12 col-sm-7 align-self-center">
<div style="color:white;">
<div class="text-center">
<a class="btn btn-social-icon btn-google" href="http://google.com/"><image src="web_home/images/google.png" height="30px" width="30px"></image></a>
<a class="btn btn-social-icon btn-facebook" href="https://www.facebook.com/"><image src="web_home/images/fb.png" height="30px" width="30px"></a>
<a class="btn btn-social-icon btn-linkedin" href="http://www.linkedin.com/"><image src="web_home/images/ln.png" height="30px" width="30px"></a>
<a class="btn btn-social-icon btn-twitter" href="http://twitter.com/"><image src="web_home/images/twitter.png" height="30px" width="30px"></i></a>
<a class="btn btn-social-icon btn-google" href="http://youtube.com/"><image src="web_home/images/yt.png" height="30px" width="30px"></i></a>
<a class="btn btn-social-icon" href="mailto:"><image src="web_home/images/gmail.png" height="30px" width="30px"></i></a>
</div>
</div>
</div>
</div>
</div>
<div class="col-12 col-sm-5" height="20px">
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3684.638303979906!2d88.3049791142734!3d22.555218039294207!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3a0279c91a8d2d49%3A0xc6ee508c74cf031d!2sIndian%20Institute%20of%20Engineering%20Science%20and%20Technology%2C%20Shibpur!5e0!3m2!1sen!2sin!4v1635442222559!5m2!1sen!2sin" width="600" height="50" style="border:0;" allowfullscreen="" loading="lazy"></iframe>
</div>
</div>
<div class="row justify-content-center">
<div class="col-auto" style="color:white;">
<p>© Copyright 2021</p>
</div>
</div>
</div>
</div>
</footer>
<?php
if(isset($_POST['submit'])){
$result1 = mysqli_query($conn,$query1);
while($row1 = mysqli_fetch_assoc($result1)){
$student_id = $row1['Student_id'];
$distance = $row1['Distance'];
$income = $row1['Income'];
if($distance < 90 OR $income > 250000)
{
echo "<script type='text/javascript'>alert('Distance is less than 90 kms or income greater than 2.5 lacs')</script> ";
}
else
{
$query2 = "SELECT * FROM Room where Room_No = (SELECT MIN(Room_No) FROM Room where Allocated = '0' and Hostel_id = '$hostel_id') and Hostel_id = '$hostel_id'";
$result2 = mysqli_query($conn,$query2);
if(mysqli_num_rows($result2) == 0){
echo "<script type='text/javascript'>alert('Rooms not available')</script>";
exit();
}
$row2 = mysqli_fetch_assoc($result2);
$room_no = $row2['Room_No'];
$student_id = $row1['Student_id'];
$query3 = "UPDATE Application SET Application_status = '0',Room_No = '$room_no' WHERE Student_id = '$student_id'";
$result3 = mysqli_query($conn,$query3);
if($result3){
$room_id = $row2['Room_id'];
$query4 = "UPDATE Student SET Hostel_id = '$hostel_id',Room_id = '$room_id' WHERE Student_id = '$student_id'";
$result4 = mysqli_query($conn,$query4);
if($result4){
$query5 = "UPDATE Room SET Allocated = '1' where Room_id = '$room_id'";
$result5 = mysqli_query($conn,$query5);
if($result5){
echo "<script type='text/javascript'>alert('Rooms Allocated Successfully')</script>";
}
}
else{
echo "<script type='text/javascript'>alert('Failed to allocate Rooms')</script>";
}
}
else{
echo "<script type='text/javascript'>alert('Failed to allocate Rooms2')</script>";
}
}
}
}
?>
<!-- footer -->
<!-- js-scripts -->
<!-- js -->
<script type="text/javascript" src="web_home/js/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="web_home/js/bootstrap.js"></script> <!-- Necessary-JavaScript-File-For-Bootstrap -->
<!-- //js -->
<!-- banner js -->
<script src="web_home/js/snap.svg-min.js"></script>
<script src="web_home/js/main.js"></script> <!-- Resource jQuery -->
<!-- //banner js -->
<!-- flexSlider --><!-- for testimonials -->
<script defer src="web_home/js/jquery.flexslider.js"></script>
<script type="text/javascript">
$(window).load(function(){
$('.flexslider').flexslider({
animation: "slide",
start: function(slider){
$('body').removeClass('loading');
}
});
});
</script>
<!-- //flexSlider --><!-- for testimonials -->
<!-- start-smoth-scrolling -->
<script src="web_home/js/SmoothScroll.min.js"></script>
<script type="text/javascript" src="web_home/js/move-top.js"></script>
<script type="text/javascript" src="web_home/js/easing.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".scroll").click(function(event){
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
});
});
</script>
<!-- here stars scrolling icon -->
<script type="text/javascript">
$(document).ready(function() {
/*
var defaults = {
containerID: 'toTop', // fading element id
containerHoverID: 'toTopHover', // fading element hover id
scrollSpeed: 1200,
easingType: 'linear'
};
*/
$().UItoTop({ easingType: 'easeOutQuart' });
});
</script>
<!-- //here ends scrolling icon -->
<!-- start-smoth-scrolling -->
<!-- //js-scripts -->
</body>
</html>