/
delete_room.php
55 lines (41 loc) · 1.44 KB
/
delete_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
session_start();
require_once("config/config.inc.php");
require_once("config/strings.inc.php");
require_once("includes/Database.php");
require_once("load.php");
require_once("includes/verify_access.php");
restrict_access($db,array("admin"));
require_once("includes/header.php");
$room_id = $_GET['room_id'];
print("<div id='PageTitle'>Delete Room</div>\n");
print("<div class='breadcrumb'><a href='http://library.pdx.edu'>Home</a> » <a href='index.php'>Reserve a Study Room</a> » Delete Room</div>\n");
print("<br>\n");
$rooms = load_rooms(array($room_id));
if(count($rooms) == 0)
{
display_error("Room could not be found.",array("room_id"=>$room_id));
}
else if(count($rooms) > 1)
{
display_error("Multiple rooms with the same id.",$rooms);
}
else
{
foreach($rooms as $room)
break;
// make sure there are no reservations set for this room
$active_reservations = load_reservations(array('room_id'=>$room->id,'status'=>array('Scheduled','Checked Out')));
if(count($active_reservations) > 0)
{
display_error("This room has active reservations that must be completed, cancelled or rescheduled before the room can be deleted.",$active_reservations);
}
else
{
$db->update("study_rooms","active","0","id like '$room_id'",$room_id,"Room deleted");
// TODO: check result to make sure the update was successful
print("<h3>Room $room->room_number has been successfully deleted.</h3>\n");
}
}
require_once("includes/footer.php");
?>