-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_reservation.php
executable file
·76 lines (50 loc) · 2.77 KB
/
add_reservation.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
<?php
@session_start();
class reservation{
public $id = "add_reservation.php";
public $res; public $room;
public function __construct($room_number, $residence_id){
if(@$_SESSION['l031n45'] == '' ){
include "redirect.php";
$go = new redirect('login.php');
die();
}
$this->room = @$room_number;
$this->res = @$residence_id;
$this->update_room();
}
public function update_room(){
$id = $this->id;
$connect = true;
include "main.php";
$isReg = $connection->num_rows(" SELECT * FROM reservants WHERE s_idnum='$_SESSION[l031n45]' AND reg=1 LIMIT 1",true);
if( $isReg > 0 ){
$connection->query("SELECT * FROM rooms WHERE r_number='$this->room' AND residence='$this->res' LIMIT 1", true);
$dets = $_SESSION['query'];
while($rmdets = mysqli_fetch_array($dets)){
$_SESSION['bk6m_maxcap'] = $rmdets['max_capacity'];
$_SESSION['bk6m_curcap'] = $rmdets['curr_capacity'];
}
$newcap = $_SESSION['bk6m_curcap'] + 1;
$resp = "";
$connection->query("UPDATE rooms SET curr_capacity='$newcap' WHERE residence='$this->res' AND r_number='$this->room'",true);
if($_SESSION['query']){$resp .= "Room capacity Updated! <br><br>";}
$connection->query("UPDATE reservants SET rnum='$this->room', res='$this->res', reg='0' WHERE s_idnum='$_SESSION[l031n45]' ",true);
if($_SESSION['query']){$resp .= "Room Details loged to personal account. <br>";}
$connection->query("INSERT INTO activity (rnum, trim, authby, residence, s_id) VALUES ('$this->room', '$_SESSION[trim_id]', '1','$this->res', '$_SESSION[l031n45]' )", true);
if($_SESSION['query']){$resp .= "Booking Lodged! .... <br />"; }
echo ('<div class="alert alert-success alert-bold-border fade in alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong><i class="fa fa-check-circle fa-2x" style="color:green;"></i></strong><br> '.$resp.' <a href="#" class="alert-link">Done!</a>.
</div>');
$iara = new redirect('panel.php');
exit;
}else{
echo('<div class="alert alert-danger alert-bold-border fade in alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong><i class="fa fa-times-circle fa-2x" style="color:red;"></i></strong><br>The Room reservation period is closed.
</div>');
}
}
}
?>