-
Notifications
You must be signed in to change notification settings - Fork 115
/
vacate_rooms.php
297 lines (266 loc) · 9.55 KB
/
vacate_rooms.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
<?php
require 'includes/config.inc.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title> Intrend Interior Category Flat Bootstrap Responsive Website Template | Services : W3layouts</title>
<!-- Meta tag Keywords -->
<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>
<!--bootsrap -->
<!--// Meta tag Keywords -->
<!-- css files -->
<link rel="stylesheet" href="web_home/css_home/bootstrap.css"> <!-- Bootstrap-Core-CSS -->
<link rel="stylesheet" href="web_home/css_home/style.css" type="text/css" media="all" /> <!-- Style-CSS -->
<link rel="stylesheet" href="web_home/css_home/fontawesome-all.css"> <!-- Font-Awesome-Icons-CSS -->
<!-- //css files -->
<!-- web-fonts -->
<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">
<!-- //web-fonts -->
</head>
<body>
<!-- banner -->
<div class="inner-page-banner" id="home">
<!--Header-->
<header>
<div class="container agile-banner_nav">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<h1><a class="navbar-brand" href="home.php">In <span class="display"> Trend</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">
<a class="nav-link" href="about_manager.php">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="allocate_room.php">Allocate Room</a>
<li class="dropdown nav-item">
<li class="nav-item">
<a class="nav-link" href="message_hostel_manager.php">Messages Received</a>
</li>
<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="vacate_rooms.php">Vacate Rooms</a>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.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="profile.php">My Profile</a>
</li>
<li>
<a href="includes/logout.inc.php">Logout</a>
</li>
</ul>
</li>
</ul>
</div>
</nav>
</div>
</header>
<!--Header-->
</div>
<br><br><br>
<?php
$hostel_id = $_SESSION['hostel_id'];
$query1 = "SELECT * FROM Hostel WHERE Hostel_id = '$hostel_id'";
$result1 = mysqli_query($conn,$query1);
$row1 = mysqli_fetch_assoc($result1);
$hostel_name = $row1['Hostel_name'];
?>
<section class="contact py-5">
<div class="container">
<h2 class="heading text-capitalize mb-sm-5 mb-4"> Vacate Form </h2>
<div class="mail_grid_w3l">
<form action="vacate_rooms.php" method="post">
<div class="row">
<div class="col-md-6 contact_left_grid" data-aos="fade-right">
<div class="contact-fields-w3ls">
<input type="text" name="roll_no" placeholder="Roll Number" required >
</div>
<div class="contact-fields-w3ls">
<input type="text" name="hostel" placeholder="Hostel" value="<?php echo $hostel_name;?>" required="" disabled="disabled">
</div>
<div class="contact-fields-w3ls">
<input type="number" name="room_no" placeholder="Room Number" required="">
</div>
</div>
<div class="col-md-6 contact_left_grid" data-aos="fade-left">
<input type="submit" name="submit" value="Click to Vacate">
</div>
</div>
</form>
</div>
</div>
</section>
<?php
if(isset($_POST['submit'])){
$roll = $_POST['roll_no'];
$hostel = $_POST['hostel'];
$room_number =(int)$_POST['room_no'];
$query2 = "SELECT * FROM Room WHERE Hostel_id = '$hostel_id' and Room_No = '$room_number'";
$result2 = mysqli_query($conn,$query2);
if(mysqli_num_rows($result2)==0){
echo "<script type='text/javascript'>alert('Incorrect Details')</script>";
exit();
}
$row2 = mysqli_fetch_assoc($result2);
if($row2['Allocated']=='0'){
echo "<script type='text/javascript'>alert('Room Not Allocated')</script>";
exit();
}
$room_id = (int)$row2['Room_id'];
/*echo "<script type='text/javascript'>alert('<?php echo $room_id ?>')</script>";*/
$query3 = "SELECT * FROM Student WHERE Student_id = '$roll' and Hostel_id = '$hostel_id' and Room_id = '$room_id'";
$result3 = mysqli_query($conn,$query3);
if(mysqli_num_rows($result3)==0){
echo "<script type='text/javascript'>alert('Incorrect Details 2')</script>";
exit();
}
$row3 = mysqli_fetch_assoc($result3);
if($result3){
$query4 = "UPDATE Student SET Hostel_id = NULL, Room_id = NULL WHERE Student_id = '$roll'";
$result4 = mysqli_query($conn,$query4);
if($result4){
$query5 = "UPDATE Room SET Allocated = '0' WHERE Room_id = '$room_id'";
$result5 = mysqli_query($conn,$query5);
if($result5){
$query6 = "DELETE FROM Application WHERE Student_id = '$roll'";
$result6 = mysqli_query($conn,$query6);
if($result6){
echo "<script type='text/javascript'>alert('Vacated Successfully')</script>";
}
}
}
}
}
?>
<br><br><br>
<!-- footer -->
<footer class="py-5">
<div class="container py-md-5">
<div class="footer-logo mb-5 text-center">
<a class="navbar-brand" href="index.html">In <span class="display"> Trend</span></a>
</div>
<div class="footer-grid">
<div class="social mb-4 text-center">
<ul class="d-flex justify-content-center">
<li class="mx-2"><a href="#"><span class="fab fa-facebook-f"></span></a></li>
<li class="mx-2"><a href="#"><span class="fab fa-twitter"></span></a></li>
<li class="mx-2"><a href="#"><span class="fas fa-rss"></span></a></li>
<li class="mx-2"><a href="#"><span class="fab fa-linkedin-in"></span></a></li>
<li class="mx-2"><a href="#"><span class="fab fa-google-plus"></span></a></li>
</ul>
</div>
<div class="list-footer">
<ul class="footer-nav text-center">
<li>
<a href="home_manager.php">Home</a>
</li>
<li>
<a href="about_manager.php">About</a>
</li>
<li>
<a href="services.php">Services</a>
</li>
<li>
<a href="projects.php">Gallery</a>
</li>
<li>
<a href="contact.php">Contact</a>
</li>
</ul>
</div>
<div class="agileits_w3layouts-copyright mt-4 text-center">
<p>© 2018 Intrend. All Rights Reserved | Design by <a href="http://w3layouts.com/" target="=_blank"> W3layouts </a></p>
</div>
</div>
</div>
</footer>
<!-- 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>