-
Notifications
You must be signed in to change notification settings - Fork 2
/
showUnapprovedEvents.php
131 lines (103 loc) · 4.11 KB
/
showUnapprovedEvents.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
<?php
require_once('_php/config.php');
session_start();
$_SESSION['faveReturn'] = substr($_SERVER[REQUEST_URI], 1);
if (isset($_SESSION['dateFrom'])) {
$dateFrom = $_SESSION['dateFrom'];
} else {
$dateFrom = "2000-00-00 00:00:00";
}
if (isset($_SESSION['dateTo'])) {
$dateTo = $_SESSION['dateTo'];
} else {
$dateTo = "2020-12-31 23:59:59";
}
if (isset($_SESSION['selectedTags'])) {
// Query for events with selected tags
$selectedTags = implode(',', $_SESSION['selectedTags']);
$event_query = "
SELECT *
FROM event_tags
LEFT JOIN events ON events.EventID = event_tags.EventID
AND event_tags.TagID IN ( $selectedTags )
AND events.Approved IS NULL
ORDER BY Start ASC";
} else {
// Query for all events
$event_query = "
SELECT *
FROM events
WHERE Approved IS NULL
ORDER BY Start ASC";
}
$result = $connection->query($event_query);
if($result->connect_errno > 0){
die('Unable to connect to database [' . $result->connect_error . ']');
}
if(!$result){
echo "no result";
} else if(mysqli_num_rows($result) == 0) {
echo '<h4>No Events Pending Approval</h4>';
} else {
echo '<div class = "accordion">';
while ($row = $result->fetch_assoc()) {
// Format dates
$start = strtotime($row['Start']);
$startDate = date('l jS F Y', $start);
$startTime = date('H:i', $start);
$end = date_add($start, date_interval_create_from_date_string($row['Duration'] . " hours"));
$endDate = date('l jS F Y', $end);
$endTime = date('H:i', $end);
/* Event Summary Section */
echo '<section class = "eventSummarySection">';
// Event title
echo '<h3>' . $row['Name'] . '</h3>';
// Event image
echo '<img src=' . $row['ImageLink'] . ' alt = "Img1" class= "eventImage">';
// Add the approve button here to replace favourites
echo '<form id="approveForm" action="_php/handleApprove.php" method="post" class="approvalButtons">';
echo ' <input name="EventID" type="hidden" value="' . $row['EventID'] . '"></input>';
echo ' <button name="approvalBtn" type="submit" form="approveForm" value="approve" class="eventApprovalButton"><div class = "approvalButtonText">Approve</div></button>';
echo ' <button name="approvalBtn" type="submit" form="approveForm" value="reject" class="eventApprovalButton"><div class = "approvalButtonText">Reject</div></button>';
echo '</form>';
// Event summary details
echo '<ul class="eventSummaryDetails">';
echo ' <li>' . $row['Speaker'] . '</li>';
echo ' <li>' . $row['Location'] . '</li>';
echo ' <li><div class="address">' . $row['Postcode'] . '</div></li>';
echo ' <li>' . $startTime . '</li>';
echo ' <li>' . $startDate . '</li>';
echo '</ul>';
echo '</section>';
/* Further Details Section */
$price = ($row['Cost'] == 0) ? 'Free' : '£' . $row['Cost'];
echo '<div class="furtherDetails">';
// Price
echo '<p>' . $price . '</p>';
echo '<p>' . $row['Description'] . '</p>';
// Tags
$current_id = $row['EventID'];
$tag_query = "SELECT * FROM event_tags JOIN tags ON event_tags.TagID = tags.TagID
WHERE event_tags.EventID = " . $current_id;
$tag_result = $connection->query($tag_query);
$tag_names = array();
foreach ($tag_result as $res) {
array_push($tag_names, $res['TagName']);
}
if (!(sizeof($tag_names) == 0)) {
$tag_list = "Tags: " . implode(", ", $tag_names);
} else {
$tag_list = "No tags";
}
echo '<p>' . $tag_list . '</p>';
// Link
echo '<p>
<a href=' . $row['InfoLink'] . ' class="linkToEventSite">More information</a>
</p>';
// Map
echo '<div class="map"></div>';
echo '</div>';
}
echo '</div>';
}
?>