1
|
|
|
<?php |
2
|
|
|
require_once('class.VolunteerPage.php'); |
3
|
|
|
require_once('api/v1/class.Processor.php'); |
4
|
|
|
require_once('app/VolunteerAutoload.php'); |
5
|
|
|
|
6
|
|
|
class ProcessorUser |
7
|
|
|
{ |
8
|
|
|
use Processor; |
|
|
|
|
9
|
|
|
|
10
|
|
|
protected $isAdmin; |
11
|
|
|
|
12
|
|
|
public function __construct($isAdmin) |
13
|
|
|
{ |
14
|
|
|
$this->isAdmin = $isAdmin; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
protected function isVolunteerAdmin() |
18
|
|
|
{ |
19
|
|
|
return $this->isAdmin; |
20
|
|
|
} |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
$page = new VolunteerPage('Burning Flipside - Flipside Volunteer System'); |
24
|
|
|
$page->addJS('js/signup.js'); |
25
|
|
|
$page->addJS('js/dialog.js'); |
26
|
|
|
$page->addWellKnownJS(JS_BOOTBOX); |
27
|
|
|
$admin = false; |
28
|
|
|
if($page->user !== null) |
29
|
|
|
{ |
30
|
|
|
$admin = $page->user->isInGroupNamed('VolunteerAdmins'); |
31
|
|
|
} |
32
|
|
|
$processor = new ProcessorUser($admin); |
33
|
|
|
|
34
|
|
|
$page->body = '<div class="row"><h1>Shift Signup</h1></div>'; |
35
|
|
|
|
36
|
|
|
if(!isset($_GET['shiftID'])) |
37
|
|
|
{ |
38
|
|
|
$page->body .= 'Error! Missing Shift ID. You must have followed a bad link!'; |
39
|
|
|
$page->printPage(); |
40
|
|
|
return; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$shiftID = $_GET['shiftID']; |
44
|
|
|
$dataTable = DataSetFactory::getDataTableByNames('fvs', 'shifts'); |
45
|
|
|
$filter = new \Data\Filter('_id eq '.$shiftID); |
46
|
|
|
$shifts = $dataTable->read($filter); |
47
|
|
|
if(empty($shifts)) |
48
|
|
|
{ |
49
|
|
|
$page->body .= 'Error! Could not locate shift. You must have followed an old link!'; |
50
|
|
|
$page->printPage(); |
51
|
|
|
return; |
52
|
|
|
} |
53
|
|
|
$shift = $shifts[0]; |
54
|
|
|
$myShift = new \VolunteerShift(false, $shift); |
55
|
|
|
|
56
|
|
|
$profile = new \VolunteerProfile($page->user->uid); |
57
|
|
|
|
58
|
|
|
if($processor->isAdminForShift($shift, $page->user)) |
59
|
|
|
{ |
60
|
|
|
if(isset($shift['groupID']) && strlen($shift['groupID'] > 0)) |
61
|
|
|
{ |
62
|
|
|
$page->body .= ' |
63
|
|
|
<div class="alert alert-info" role="alert"> |
64
|
|
|
You are an administrator for this shift. You can edit the shift <a href="_admin/shifts.php?shiftID='.$shiftID.'" class="alert-link">here</a>. |
65
|
|
|
Or you can edit the shift group <a href="_admin/shifts.php?groupID='.$shift['groupID'].'" class="alert-link">here</a>. |
66
|
|
|
</div> |
67
|
|
|
'; |
68
|
|
|
} |
69
|
|
|
else |
70
|
|
|
{ |
71
|
|
|
$page->body .= ' |
72
|
|
|
<div class="alert alert-info" role="alert"> |
73
|
|
|
You are an administrator for this shift. You can edit the shift <a href="_admin/shifts.php?shiftID='.$shiftID.'" class="alert-link">here</a>. |
74
|
|
|
</div> |
75
|
|
|
'; |
76
|
|
|
} |
77
|
|
|
if(!isset($shift['participant']) || strlen($shift['participant']) === 0) |
78
|
|
|
{ |
79
|
|
|
$page->body .= ' |
80
|
|
|
<div class="alert alert-info" role="alert"> |
81
|
|
|
You are an administrator for this shift. You can assign someone to the shift, but it is highly recommended to let the users sign up. But if you are sure click <a href="#" onClick="showAdminSignup()" class="alert-link">here</a>. |
82
|
|
|
</div> |
83
|
|
|
'; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
//Is shift already taken? |
88
|
|
|
if($myShift->isFilled()) |
89
|
|
|
{ |
90
|
|
|
if(isset($shift['participant']) && $shift['participant'] === $page->user->uid) |
91
|
|
|
{ |
92
|
|
|
$page->body .= '<div class="alert alert-success" role="alert"> |
93
|
|
|
You already have this shift! |
94
|
|
|
</div> |
95
|
|
|
<div class="row"> |
96
|
|
|
<button type="button" class="btn btn-secondary mr-auto" onClick="window.history.back();">Cancel</button> |
97
|
|
|
<button type="button" class="btn btn-primary" onclick="abandon();">Abandon Shift</button> |
98
|
|
|
</div>'; |
99
|
|
|
} |
100
|
|
|
else |
101
|
|
|
{ |
102
|
|
|
$page->body .= '<div class="alert alert-danger" role="alert"> |
103
|
|
|
Someone else took this shift! |
104
|
|
|
</div>'; |
105
|
|
|
} |
106
|
|
|
$page->printPage(); |
107
|
|
|
return; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
$overlap = false; |
111
|
|
|
if($myShift->findOverlaps($page->user->uid, true)) |
112
|
|
|
{ |
113
|
|
|
$page->body .= '<div class="alert alert-warning" role="alert"> |
114
|
|
|
You already have a shift during this time. If you choose to signup for this shift the lead(s) for the departments will be notified and must approve. |
115
|
|
|
</div> |
116
|
|
|
<div class="row"> |
117
|
|
|
<label for="department" class="col-sm-10 col-form-label">I understand I am signing up for multiple shifts at the same time.</label> |
118
|
|
|
<div class="col-sm-2"> |
119
|
|
|
<input type="checkbox" class="form-control" onChange="revealPage();"> |
120
|
|
|
</div> |
121
|
|
|
</div>'; |
122
|
|
|
$overlap = true; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
$deptName = $shift['departmentID']; |
126
|
|
|
$roleName = $shift['roleID']; |
127
|
|
|
|
128
|
|
|
$dataTable = DataSetFactory::getDataTableByNames('fvs', 'departments'); |
129
|
|
|
$depts = $dataTable->read(new \Data\Filter('departmentID eq '.$shift['departmentID'])); |
130
|
|
|
if(!empty($depts)) |
131
|
|
|
{ |
132
|
|
|
$deptName = $depts[0]['departmentName']; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
$dataTable = DataSetFactory::getDataTableByNames('fvs', 'events'); |
136
|
|
|
$events = $dataTable->read(new \Data\Filter('_id eq '.$shift['eventID'])); |
137
|
|
|
if(!empty($events)) |
138
|
|
|
{ |
139
|
|
|
if($events[0]['tickets']) |
140
|
|
|
{ |
141
|
|
|
//TODO... Event requires tickets. Does this account have tickets? |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
$dataTable = DataSetFactory::getDataTableByNames('fvs', 'roles'); |
146
|
|
|
$roles = $dataTable->read(new \Data\Filter('short_name eq '.$shift['roleID'])); |
147
|
|
|
if(!empty($roles)) |
148
|
|
|
{ |
149
|
|
|
$roleName = $roles[0]['display_name']; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
//Is user eligible for shift? |
153
|
|
|
$canDo = $processor->canUserDoRole($profile, $roles[0]); |
154
|
|
|
if(is_array($canDo) && $processor->isAdminForShift($shift, $page->user)) |
155
|
|
|
{ |
156
|
|
|
$canDo = true; |
157
|
|
|
} |
158
|
|
|
if($canDo !== true) |
159
|
|
|
{ |
160
|
|
|
$page->body .= '<div class="alert alert-danger" role="alert">'; |
161
|
|
|
switch($canDo['whyClass']) |
162
|
|
|
{ |
163
|
|
|
case 'INVITE': |
164
|
|
|
$page->body .= 'This shift requires an invite from the department lead. If you think you should have recieved such an invite please <a href="https://www.burningflipside.com/contact" class="alert-link">contact the lead</a>.'; |
165
|
|
|
break; |
166
|
|
|
case 'CERT': |
167
|
|
|
$page->body .= $canDo['whyMsg'].' If you have this certification it is not recorded in your profile. You can <a href="certiciation.php" class="alert-link">record that certification</a> to sign up.'; |
168
|
|
|
break; |
169
|
|
|
default: |
170
|
|
|
$page->body .= 'You are not eligible for this shift because: '.$canDo['whyMsg']; |
171
|
|
|
break; |
172
|
|
|
} |
173
|
|
|
$page->body .= '</div>'; |
174
|
|
|
$page->printPage(); |
175
|
|
|
return; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
if(isset($shift['approvalNeeded']) && $shift['approvalNeeded']) |
179
|
|
|
{ |
180
|
|
|
$page->body .= '<div class="alert alert-warning" role="alert">This shift requires explicit permission from the lead in order to sign up. The lead may decline your signup for this shift.</div>'; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
$start = new \DateTime($shift['startTime']); |
184
|
|
|
$end = new \DateTime($shift['endTime']); |
185
|
|
|
$diff = $end->diff($start); |
186
|
|
|
$shiftLength = $diff->h + ($diff->i / 60.0); |
187
|
|
|
|
188
|
|
|
$page->body .= '<div id="signupContent" '; |
189
|
|
|
if($overlap) |
190
|
|
|
{ |
191
|
|
|
$page->body .= 'class="d-none" '; |
192
|
|
|
} |
193
|
|
|
$page->body .= '/>'; |
194
|
|
|
$page->body .= ' |
195
|
|
|
<div class="row"> |
196
|
|
|
<input type="hidden" id="shiftID" name="shiftID" value="'.$shiftID.'"/> |
197
|
|
|
<label for="department" class="col-sm-2 col-form-label">Department:</label> |
198
|
|
|
<div class="col-sm-10"> |
199
|
|
|
<input type="text" name="department" id="department" class="form-control" readonly="readonly" value="'.$deptName.'"> |
200
|
|
|
</div> |
201
|
|
|
<label for="role" class="col-sm-2 col-form-label">Role:</label> |
202
|
|
|
<div class="col-sm-10"> |
203
|
|
|
<input type="text" name="role" id="role" class="form-control" readonly="readonly" value="'.$roleName.'"> |
204
|
|
|
</div> |
205
|
|
|
<label for="startTime" class="col-sm-2 col-form-label">Start Time:</label> |
206
|
|
|
<div class="col-sm-10"> |
207
|
|
|
<input type="datetime-local" name="startTime" id="startTime" class="form-control" readonly="readonly" value="'.$start->format('Y-m-d\Th:i').'"> |
208
|
|
|
</div> |
209
|
|
|
<label for="endTime" class="col-sm-2 col-form-label">End Time:</label> |
210
|
|
|
<div class="col-sm-10"> |
211
|
|
|
<input type="datetime-local" name="endTime" id="endTime" class="form-control" readonly="readonly" value="'.$end->format('Y-m-d\Th:i').'"> |
212
|
|
|
</div> |
213
|
|
|
<label for="length" class="col-sm-2 col-form-label">Length:</label> |
214
|
|
|
<div class="col-sm-10"> |
215
|
|
|
<input type="text" name="length" id="length" class="form-control" readonly="readonly" value="'.$shiftLength.' hours"> |
216
|
|
|
</div> |
217
|
|
|
</div> |
218
|
|
|
<div class="row"> |
219
|
|
|
<div class="alert alert-info" role="alert"> |
220
|
|
|
By signing up for a Burning Flipside shift you are commiting to showing up on time for your shift prepared to work. Please make sure you are prepared to make this commitment before clicking signup below. |
221
|
|
|
</div> |
222
|
|
|
</div> |
223
|
|
|
<div class="row"> |
224
|
|
|
<button type="button" class="btn btn-secondary mr-auto" onClick="window.history.back();">Cancel</button> |
225
|
|
|
<button type="button" class="btn btn-primary" onclick="signup();">Signup</button> |
226
|
|
|
</div></div> |
227
|
|
|
'; |
228
|
|
|
|
229
|
|
|
if($processor->isAdminForShift($shift, $page->user) && (!isset($shift['participant']) || strlen($shift['participant']) === 0)) |
230
|
|
|
{ |
231
|
|
|
$page->body .= ' |
232
|
|
|
<div class="row d-none" id="adminSignup"> |
233
|
|
|
<div class="alert alert-danger" role="alert"> |
234
|
|
|
First off, make sure you understand what this will do. While it will let you fill out the details for a shift, it will prevent the user from seeing the shift on their list when the log it, it will not be correctly reported for t-shirts or for rock star volunteers, their camp will not be listed on the shift schedule, and the ability to contact past volunteers will not work for anyone signed up in this manner. Basically, doing this removes about 90% of the advantage of using this system. So please only do this if participant in question is unable to sign up on their own. |
235
|
|
|
</div> |
236
|
|
|
<label for="participantOverride" class="col-sm-2 col-form-label">Participant Name:</label> |
237
|
|
|
<div class="col-sm-10"> |
238
|
|
|
<input type="text" name="participantOverride" id="participantOverride" class="form-control"/> |
239
|
|
|
</div> |
240
|
|
|
<button type="button" class="btn btn-primary" onclick="override();">Admin Override</button> |
241
|
|
|
</div> |
242
|
|
|
'; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
//Is group eligible? |
246
|
|
|
if(isset($shift['groupID']) && isset($roles[0]['groups_allowed']) && $roles[0]['groups_allowed']) |
247
|
|
|
{ |
248
|
|
|
$page->body .= '<div id="groupContent" '; |
249
|
|
|
if($overlap) |
250
|
|
|
{ |
251
|
|
|
$page->body .= 'class="d-none" '; |
252
|
|
|
} |
253
|
|
|
$page->body .= '> |
254
|
|
|
<div class="row"> |
255
|
|
|
<div class="alert alert-primary" role="alert"> |
256
|
|
|
You have selected a group eligible shift. This means you can generate a link for your friends to sign up on the shift with you. Would you like to sign up for the shift and generate that link now? |
257
|
|
|
</div> |
258
|
|
|
</div> |
259
|
|
|
<div class="row"> |
260
|
|
|
<button type="button" class="btn btn-secondary" onclick="groupSignup();">Signup and Generate Group Link</button> |
261
|
|
|
</div> |
262
|
|
|
</div> |
263
|
|
|
'; |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
$page->printPage(); |
267
|
|
|
/* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
268
|
|
|
|