-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_load_rooms.php
executable file
·65 lines (48 loc) · 2.6 KB
/
_load_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
<?php
$id = "_load_rooms.php";
$connect = true;
include("main.php");
if( ( $_SESSION['u56_res'] == 0 && $_SESSION['u56_rnum'] == 0 ) || ( $_SESSION['u56_res'] == '' && $_SESSION['u56_rnum'] == '' )):
if(@$_REQUEST['resid'] != '' && @$_REQUEST['resid'] != 0 ){
$connection->query("SELECT r_number,max_capacity,curr_capacity FROM rooms WHERE residence='".$_REQUEST['resid']."' AND available=1", true);
$all_rooms = $_SESSION['query'];
$resp = "";
while( $r_data = mysqli_fetch_array($all_rooms) ){
if ($r_data['max_capacity'] == $r_data['curr_capacity'] ) {
$percent = 100;
}else if($r_data['curr_capacity'] == 0 ) {
$percent = 0;
}else{
$percent = ( ($r_data['curr_capacity']/$r_data['max_capacity']) * 100 );
}
if( $percent == 100 ){
$i = 2;
$data = 'onclick="javascript:book_room( 0, '.$_REQUEST['resid'].' )" class="btn btn-danger perspective col-lg-3"';
}else if($percent > 0 ){
$i = 2;
$data = 'onclick="javascript:book_room( ' .@htmlentities($r_data['r_number'].', '.$_REQUEST['resid']).')" class="btn btn-info perspective col-lg-3"';
}else{
$i = 1;
$data = 'onclick="javascript:book_room(' .@htmlentities($r_data['r_number'].','.$_REQUEST['resid']). ')" class=" btn btn-success perspective col-lg-3"';
}
//<button type="button" class="btn btn-success">Success</button>
$resp .= '<button type="button" style="margin: 5px;" '.$data.'> Room ' .@htmlentities($r_data['r_number']).' </button>';
}
die($resp);
}else{
die ('<div class="alert alert-danger alert-bold-border fade in alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<br><br>
<strong>Error!</strong><br> FAILED TO FETCH RESIDENCE DATA!<br> <br><br><a href="#" class="alert-link">That residence might be fully occupied!</a>.
<br><br><br>
</div>');
}
else:
die ('<div class="alert alert-danger alert-bold-border fade in alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<br><br>
<strong>Error!</strong><br> YOU ARE CURRENTLY ALLOCATED A ROOM!!<br> <br><br><a href="#" class="alert-link">See the residence administrator for further assistance</a>.
<br><br><br>
</div>');
endif;
?>