-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewLocation.php
More file actions
127 lines (126 loc) · 5.4 KB
/
viewLocation.php
File metadata and controls
127 lines (126 loc) · 5.4 KB
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
<?php
require_once 'classes/Location.php';
require_once 'classes/LocationTableGateway.php';
require_once 'classes/EventTableGateway.php';
require_once 'classes/Connection.php';
if (!isset($_GET['id'])) {
die("Illegal request");
}
$id = $_GET['id'];
$connection = Connection::getInstance();
$gateway = new LocationTableGateway($connection);
$eventGateway = new EventTableGateway($connection);
$statement = $gateway->getLocationsById($id);
$events = $eventGateway->getEventsByLocationId($id);
$row = $statement->fetch(PDO::FETCH_ASSOC);
if (!$row) {
die("Illegal request");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<?php require 'utils/styles.php'; ?>
<?php require 'utils/scripts.php'; ?>
</head>
<body>
<?php require 'utils/header.php'; ?>
<div class = "content">
<div class = "container">
<?php
if (isset($message)) {
echo '<p>' . $message . '</p>';
}
?>
<table class = "table table-hover">
<thead>
<!--table label-->
<!--this will only show the detail of a location with specific ID chosen by the user-->
<tr>
<th>Location ID</th>
<th>Location Name</th>
<th>Address</th>
<th>Manager First Name</th>
<th>Manager Last Name</th>
<th>Manager Email</th>
<th>Manager Number</th>
<th>Max Capacity</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<!--table contents-->
<?php
echo '<tr>';
echo '<td>' . $row['LocationID'] . '</td>';
echo '<td>' . $row['Name'] . '</td>';
echo '<td>' . $row['Address'] . '</td>';
echo '<td>' . $row['ManagerFName'] . '</td>';
echo '<td>' . $row['ManagerLName'] . '</td>';
echo '<td>' . $row['ManagerEmail'] . '</td>';
echo '<td>' . $row['ManagerNumber'] . '</td>';
echo '<td>' . $row['MaxCapacity'] . '</td>';
echo '<td>'
. '<a href="editLocationForm.php?id=' . $row['LocationID'] . '">Edit</a> '
. '<a class="delete" href="deleteLocation.php?id=' . $row['LocationID'] . '">Delete</a> '
. '</td>';
echo '</tr>';
?>
</tbody>
</table>
<?php
if ($events->rowCount() > 0) {
?>
<h2>Events at this location</h2>
<table class="table table-hover">
<thead>
<tr>
<th>Event ID</th>
<th>Title</th>
<th>Description</th>
<th>Start Date</th>
<th>End Date</th>
<th>Cost</th>
<th>Location</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
$row = $events->fetch(PDO::FETCH_ASSOC);
while ($row) {
echo '<tr>';
echo '<td>' . $row['EventID'] . '</td>';
echo '<td>' . $row['Title'] . '</td>';
echo '<td>' . $row['Description'] . '</td>';
echo '<td>' . $row['StartDate'] . '</td>';
echo '<td>' . $row['EndDate'] . '</td>';
echo '<td>' . $row['Cost'] . '</td>';
echo '<td>'
. '<a href="viewLocation.php?id='.$row['LocationID'].'">'.$row['name'].'</a> '
. '</td>';
echo '<td>'
. '<a href="viewEvent.php?id='.$row['EventID'].'">View</a> '
. '<a class="delete" href="deleteEvent.php?id='.$row['EventID'].'">Delete</a> '
. '</td>';
echo '</tr>';
$row = $events->fetch(PDO::FETCH_ASSOC);
}
?>
</tbody>
</table>
<?php
} else {
?>
<p>There are no events for this location.</p>
<?php
}
?>
<a class="btn btn-default" href="viewLocations.php"><span class="glyphicon glyphicon-circle-arrow-left"></span> Back</a>
</div>
</div>
<?php require 'utils/footer.php'; ?>
</body>
</html>