-
Notifications
You must be signed in to change notification settings - Fork 0
/
modules_bookings_accomodations.php
228 lines (206 loc) · 10.6 KB
/
modules_bookings_accomodations.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
<?php
session_start();
require_once('config/config.php');
require_once('config/checklogin.php');
require_once('config/codeGen.php');
checklogin();
/* Add Room Reservation */
if (isset($_POST['Add_Reservation'])) {
$accomodation_id = $sys_gen_id;
$accomodation_user_id = $_POST['accomodation_user_id'];
$accomodation_check_indate = $_POST['accomodation_check_indate'];
$accomodation_room_id = $_POST['accomodation_room_id'];
$accomodation_payment_status = 'Pending';
$accomodation_check_out_date = $_POST['accomodation_check_out_date'];
$room_status = 'Occupied';
$query = "INSERT INTO accomodations (accomodation_id, accomodation_user_id, accomodation_check_indate, accomodation_room_id, accomodation_payment_status, accomodation_check_out_date) VALUES(?,?,?,?,?,?)";
$status = "UPDATE rooms SET room_status =? WHERE room_id = ?";
$stmt = $mysqli->prepare($query);
$status_stmt = $mysqli->prepare($status);
$rc = $stmt->bind_param('ssssss', $accomodation_id, $accomodation_user_id, $accomodation_check_indate, $accomodation_room_id, $accomodation_payment_status, $accomodation_check_out_date);
$rc = $status_stmt->bind_param('ss', $room_status, $accomodation_room_id);
$stmt->execute();
$status_stmt->execute();
if ($stmt && $status_stmt) {
$success = "Reservation Posted";
} else {
$info = "Please Try Again Or Try Later";
}
}
/* Delete Reservations */
if (isset($_GET['delete'])) {
$delete = $_GET['delete'];
$room = $_GET['room'];
$adn = "DELETE FROM accomodations WHERE accomodation_id =?";
$adn1 = "UPDATE rooms SET room_status = 'Vacant' WHERE room_id = ?";
$stmt = $mysqli->prepare($adn);
$stmt_1 = $mysqli->prepare($adn1);
$stmt->bind_param('s', $delete);
$stmt_1->bind_param('s', $room);
$stmt->execute();
$stmt_1->execute();
$stmt->close();
$stmt_1->close();
if ($stmt && $stmt_1) {
$success = "Deleted" && header("refresh:1; url=modules_bookings_accomodations");
} else {
$err = "Please Try Again Later";
}
}
require_once('partials/head.php');
?>
<body class="theme-red">
<!-- Page Loader -->
<div class="page-loader-wrapper">
<?php require_once('partials/loader.php'); ?>
</div>
<!-- Overlay For Sidebars -->
<div class="overlay"></div>
<!-- Top Bar -->
<?php require_once('partials/navigation.php'); ?>
<!-- Left Sidebar -->
<?php require_once('partials/sidebar.php'); ?>
<!-- Add Staff Modal -->
<section class="content">
<div class="container-fluid">
<div class="block-header">
<div class="row">
<div class="col-lg-12 col-md-6 col-sm-7">
<h2>Museum Guest Rooms Accomodation Reservations</h2>
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="dashboard">Dashboard</a></li>
<li class="breadcrumb-item"><a href="">Bookings</a></li>
<li class="breadcrumb-item active">Accomodations</li>
</ul>
<div class="text-right">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#add_modal">Add Guest Room Reservation</button>
</div>
</div>
</div>
</div>
<hr>
<div class="row clearfix">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover js-basic-example dataTable">
<thead>
<tr>
<th>Member Details</th>
<th>Room Details</th>
<th>Dates</th>
<th>Payment Status</th>
</tr>
</thead>
<tbody>
<?php
$ret = "SELECT * FROM accomodations a INNER JOIN
users u ON u.user_id = a.accomodation_user_id
INNER JOIN rooms r ON r.room_id = a.accomodation_room_id";
$stmt = $mysqli->prepare($ret);
$stmt->execute(); //ok
$res = $stmt->get_result();
while ($reservations = $res->fetch_object()) {
?>
<tr>
<td>
<a href="modules_bookings_accomodation?view=<?php echo $reservations->accomodation_id; ?>">
Name: <?php echo $reservations->user_name; ?><br>
Email: <?php echo $reservations->user_email; ?><br>
Contact: <?php echo $reservations->user_phone; ?>
</a>
</td>
<td>
No : <?php echo $reservations->room_number; ?><br>
Type : <?php echo $reservations->room_type; ?>
</td>
<td>
Check In : <?php echo date('d, M Y', strtotime($reservations->accomodation_check_indate)); ?><br>
Check Out : <?php echo date('d, M Y', strtotime($reservations->accomodation_check_out_date)); ?>
</td>
<td><?php echo $reservations->accomodation_payment_status; ?></td>
</tr>
<?php
} ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
<!-- Add Modal -->
<div class="modal fade" id="add_modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="largeModalLabel">Add Guest Room Reservation</h4>
</div>
<form method="POST">
<div class="modal-body">
<div class="row clearfix">
<div class="col-sm-6">
<div class="form-group">
<label>Member Name</label>
<div class="form-line">
<select type="text" name="accomodation_user_id" required class="form-control show-tick">
<?php
$ret = "SELECT * FROM users WHERE user_access_level = 'Member' ";
$stmt = $mysqli->prepare($ret);
$stmt->execute(); //ok
$res = $stmt->get_result();
while ($users = $res->fetch_object()) {
?>
<option value="<?php echo $users->user_id; ?>"><?php echo $users->user_name; ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label>Room Number</label>
<div class="form-line">
<select type="text" name="accomodation_room_id" required class="form-control show-tick">
<?php
$ret = "SELECT * FROM rooms WHERE room_status = 'Vacant' ";
$stmt = $mysqli->prepare($ret);
$stmt->execute(); //ok
$res = $stmt->get_result();
while ($rooms = $res->fetch_object()) {
?>
<option value="<?php echo $rooms->room_id; ?>"><?php echo $rooms->room_number; ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label>Check In Date</label>
<div class="form-line">
<input type="date" name="accomodation_check_indate" required class="form-control" />
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label>Check In Out</label>
<div class="form-line">
<input type="date" name="accomodation_check_out_date" required class="form-control" />
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="Add_Reservation" class="btn btn-link waves-effect">SAVE </button>
<button type="button" class="btn btn-link waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</form>
</div>
</div>
</div>
<!-- Scripts -->
<?php require_once('partials/scripts.php'); ?>
</body>
</html>