-
Notifications
You must be signed in to change notification settings - Fork 4
/
masterEvents.php
243 lines (192 loc) · 5.97 KB
/
masterEvents.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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?php
/*******************************************************************************
Manage System Events
Administrator page to add/edit/remove events
LOGIN
- SUPER ADMIN can access, no others can
*******************************************************************************/
// INITIALIZATION //////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
$pageName = "Manage System Events";
include('includes/header.php');
if(USER_TYPE < USER_SUPER_ADMIN){
pageError('user');
} else {
$eventList = getEventListFull();
echo "<div class='grid-x'>";
if(isset($_SESSION['editEventID'])){
$eventID = $_SESSION['editEventID'];
unset($_SESSION['editEventID']);
editEventMenu($eventID,$eventList[$eventID]);
} else {
addNewEventMenu();
}
displayAdminEventList($eventList);
echo "</div>";
include('includes/footer.php');
}
// FUNCTIONS ///////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
function displayAdminEventList($eventList){
// These are the fields displayed
$fieldsToDisplay = ['eventID',
'eventName',
'eventStartDate',
'eventCity',
'eventProvince',
'eventCountry',
'eventStatus'];
?>
<div class='cell'>
<form method='POST'>
<input type='hidden' name='formName' value='editEvent'>
<table class='stack'>
<!-- Headers -->
<tr class='hide-for-small-only'>
<?php foreach($fieldsToDisplay as $fieldName): ?>
<th><?=$fieldName?></th>
<?php endforeach ?>
</tr>
<!-- Events -->
<?php foreach($eventList as $eventID => $info): ?>
<tr>
<td>
<button class='button tiny hollow no-bottom expanded' name='eventToEdit' value='<?=$eventID?>'>
Edit #<?=$eventID?>
</button>
</td>
<?php foreach($fieldsToDisplay as $fieldName):
if($fieldName == 'eventID'){continue;}
$fieldValue = $info[$fieldName];
?>
<td><?=$fieldValue?></td>
<?php endforeach ?>
</tr>
<?php endforeach ?>
</table>
</form>
</div>
<?php }
/******************************************************************************/
function addNewEventMenu(){
?>
<fieldset class='fieldset cell large-6'>
<legend><h4>Add New Event</h4></legend>
<form method='POST'>
<input type='hidden' name='formName' value='addNewEvent'>
<table class='stack'>
<?php entryFields(); ?>
<tr>
<td>Event Status:</td>
<td>
<select name='eventStatus'>
<option value='active'>Active</option>
<option value='upcoming'>Upcoming</option>
<option value='hidden'>Hidden</option>
<option value='default'>Default</option>
<option value='archived'>Archived</option>
</select>
</td>
</tr>
</table>
<button class='button'>Add Event</button>
</form>
</fieldset>
<?php }
/******************************************************************************/
function editEventMenu($eventID,$eventInfo){
$num = rand(0,999); // random number acting as a delete confirmation
$eventStatus = getEventStatus($eventID);
$statusType = array('active','upcoming','hidden','default','archived');
?>
<fieldset class='fieldset cell large-6'>
<legend><h4>Edit Event</h4></legend>
<form method='POST'>
<input type='hidden' name='eventID' value='<?=$eventID?>'>
<input type='hidden' name='formName' value='editEvent'>
<!-- Data fields -->
<table>
<?php entryFields($eventInfo); ?>
<!-- Event status -->
<tr>
<td>Event Status:</td>
<td>
<select name='eventStatus'>
<?php foreach($statusType as $type):
$selected = isSelected($type == $eventStatus);
?>
<option value='<?=$type?>' <?=$selected?>>
<?=$type?>
</option>
<?php endforeach ?>
</select>
</td>
</tr>
</table>
<!-- Submit buttons -->
<button class='button success' name='editEvent' value=1 >Update Event</button>
<button class='button secondary' name='formName'>Cancel</button>
<!-- Delete event & confirmation -->
<BR><?=$num?>
<input type='hidden' value='<?=$num?>' name='confirmDelete'>
<button class='button alert hollow small' name='deleteEvent' value='Delete Event'>Delete Event</button>
<input type='text' name='deleteCode' size='1'>
</form>
</fieldset>
<?php }
/******************************************************************************/
function entryFields($eventInfo = null){
?>
<tr>
<td>Event Name</td>
<td>
<input class='no-bottom' type='text' required
name='eventName' value='<?=$eventInfo['eventName']?>'>
</td>
</tr>
<tr>
<td>Abreviation</td>
<td>
<input class='no-bottom' type='text'
name='eventAbreviation' value='<?=$eventInfo['eventAbreviation']?>'>
</td>
</tr>
<tr>
<td>Start Date</td>
<td>
<input class='no-bottom' type='date' required
name='eventStartDate' value='<?=$eventInfo['eventStartDate']?>'>
</td>
</tr>
<tr>
<td>End Date</td>
<td>
<input class='no-bottom' type='date'
name='eventEndDate' value='<?=$eventInfo['eventEndDate']?>'>
</td>
</tr>
<tr>
<td>Country</td>
<td>
<input class='no-bottom' type='text'
name='eventCountry' value='<?=$eventInfo['eventCountry']?>'>
</td>
</tr>
<tr>
<td>Province/State</td>
<td>
<input class='no-bottom' type='text'
name='eventProvince' value='<?=$eventInfo['eventProvince']?>'>
</td>
</tr>
<tr>
<td>City</td>
<td>
<input class='no-bottom' type='text'
name='eventCity' value='<?=$eventInfo['eventCity']?>'>
</td>
</tr>
<?php }
/******************************************************************************/
// END OF DOCUMENT /////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////