-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate_room.php
40 lines (32 loc) · 1.02 KB
/
update_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
<?php
include('bookings_db.php');
$db = new bookings_db();
$action = $_GET['action'];
$postdata = json_decode(file_get_contents('php://input'), true);
if ($action == 'add') {
$id = $db->add_room($postdata['Name'], $postdata['Color'], $postdata['ColorProv']);
$room['Id_Room'] = $id;
$room['Name'] = $postdata['Name'];
$room['Color'] = $postdata['Color'];
$room['ColorProv'] = $postdata['ColorProv'];
$facs = $db->get_roomfacilities($id);
while ($fac = $facs->fetch_assoc()) {
$facilities[] = $fac;
}
$room['facilities'] = $facilities;
echo json_encode($room);
} else if ($action == 'update') {
$db->rename_room($postdata['id'], $postdata['Name'], $postdata['Color'], $postdata['ColorProv']);
} else if ($action == 'delete') {
$db->delete_room($postdata['id']);
} else if ($action == 'updatefac') {
$roomid = $postdata['roomid'];
$facid = $postdata['facid'];
if ($postdata['available'] == 'true') {
$db->add_room_facility($roomid, $facid);
} else {
$db->remove_room_facility($roomid, $facid);
}
}
$db->close();
?>