This repository has been archived by the owner on Oct 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
equipment_group_per_se.frag.php
executable file
·305 lines (272 loc) · 14.6 KB
/
equipment_group_per_se.frag.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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<?php
# admin or manager: is allowed to edit fields
if ($USER->flag_is_system_admin || $is_group_manager) {
$manager_permission_data = array();
$consumer_permission_data = array();
foreach ($Requested_EqGroup->permissions as $p) {
$display_text = '';
if ($p->entity_type == 'user') {
$u = User::getOneFromDb(['user_id' => $p->entity_id], $DB);
if ($u->matchesDb) {
$display_text = $u->fname . ' ' . $u->lname . ' (' . $u->email . ')';
}
}
else {
$g = InstGroup::getOneFromDb(['inst_group_id' => $p->entity_id], $DB);
if ($g->matchesDb) {
//echo "group ". $g->name;
$display_text = '[users in ' . $g->name . ']';
}
}
if ($display_text) {
//echo "display text is $display_text";
if ($p->role_id == 1) {
array_push($manager_permission_data, ['perm_id' => $p->permission_id, 'ent_type' => $p->entity_type, 'ent_id' => $p->entity_id, 'display_text' => $display_text]);
}
else {
array_push($consumer_permission_data, ['perm_id' => $p->permission_id, 'ent_type' => $p->entity_type, 'ent_id' => $p->entity_id, 'display_text' => $display_text]);
}
}
}
?>
<legend class="pull-left row-fluid">
<?php echo $Requested_EqGroup->name; ?>
<a href="#" id="toggleGroupSettings" class="btn btn-medium btn-primary"><i class="icon-white icon-pencil"></i> Edit Equipment Group</a></legend>
<div id="managerEdit" class="hide">
<form action="ajax_actions/ajax_eq_group.php" class="form-horizontal" id="frmAjaxGroup" name="frmAjaxGroup" method="post">
<input type="hidden" id="groupID" value="<?php echo $Requested_EqGroup->eq_group_id; ?>" />
<div class="control-group">
<label class="control-label" for="groupName">Name</label>
<div class="controls">
<input type="text" id="groupName" class="input-large" name="groupName" value="<?php echo $Requested_EqGroup->name; ?>" placeholder="Name of group" maxlength="200" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="groupDescription">Description</label>
<div class="controls">
<textarea rows="3" id="groupDescription" class="input-large" name="groupDescription" placeholder="Description of group"><?php echo $Requested_EqGroup->descr; ?></textarea>
</div>
</div>
<div class="control-group">
<label class="control-label" for="referenceLink">Reference Link</label>
<div class="controls">
<input type = "url" id="referenceLink" class="input-large" name="referenceLink" placeholder="ex: http://www.williams.edu" maxlength="200" <?php
if ($Requested_EqGroup->reference_link) {
echo ' value="'.$Requested_EqGroup->reference_link.'"';
}
?>/>
</div>
</div>
<!-- <legend>Reservation Rules</legend> -->
<div class="control-group">
<label class="control-label" for="goStartMinute">Restrict start time</label>
<div class="controls">
<?php
$defaultStartMinute = [
"" => "Select or Edit",
"00" => "hourly (00)",
"0,30" => "half hours (00,30)",
"0,15,30,45" => "quarter hours (00,15,30,45)"
];
?>
<select id="goStartMinute" class="span2">
<?php
foreach ($defaultStartMinute as $key => $val) {
echo "<option value=\"$key\">$val</option>\n";
}
?>
</select>
<i class="icon-arrow-right"></i>
<input type="text" id="startMinute" class="input-medium" name="startMinute" value="<?php echo $Requested_EqGroup->start_minute; ?>" placeholder="Minutes (with commas)" maxlength="200" />
Reservations must start on one of these minutes of the hour.
</div>
</div>
<?php
$defaultDuration = [
"" => "Select or Edit",
5 => "5 minutes",
15 => "15 minutes",
30 => "30 minutes",
45 => "45 minutes",
60 => "1 hour",
120 => "2 hours",
240 => "4 hours",
480 => "8 hours",
540 => "9 hours",
600 => "10 hours",
720 => "12 hours",
960 => "16 hours",
1440 => "24 hours"
];
// 2880 => "2 days",
// 10080 => "1 week",
// 20160 => "2 weeks",
// 40320 => "4 weeks",
// 80640 => "8 weeks"
?>
<div class="control-group">
<label class="control-label" for="goMinDurationMinutes">Restrict min duration</label>
<div class="controls">
<select id="goMinDurationMinutes" class="span2">
<?php
foreach ($defaultDuration as $key => $val) {
echo "<option value=\"$key\">$val</option>\n";
}
?>
</select>
<i class="icon-arrow-right"></i>
<input type="text" id="minDurationMinutes" class="input-mini" name="minDurationMinutes" value="<?php echo $Requested_EqGroup->min_duration_minutes; ?>" placeholder="Duration" maxlength="6" />
The minimum length of time (in minutes) that can be reserved.
</div>
</div>
<div class="control-group">
<label class="control-label" for="goMaxDurationMinutes">Restrict max duration</label>
<div class="controls">
<select id="goMaxDurationMinutes" class="span2">
<?php
foreach ($defaultDuration as $key => $val) {
echo "<option value=\"$key\">$val</option>\n";
}
?>
</select>
<i class="icon-arrow-right"></i>
<input type="text" id="maxDurationMinutes" class="input-mini" name="maxDurationMinutes" value="<?php echo $Requested_EqGroup->max_duration_minutes; ?>" placeholder="Duration" maxlength="6" />
The maximum length of time (in minutes) that can be reserved.
</div>
</div>
<!--
<div class="control-group">
<label class="control-label" for="goDurationIntervalMinutes">Restrict time quanta</label>
<div class="controls">
<select id="goDurationIntervalMinutes" class="span2">
<?php
foreach ($defaultDuration as $key => $val) {
echo "<option value=\"$key\">$val</option>\n";
}
?>
</select>
<i class="icon-arrow-right"></i>
<input type="text" id="durationIntervalMinutes" class="input-mini" name="durationIntervalMinutes" value="<?php echo $Requested_EqGroup->duration_chunk_minutes; ?>" placeholder="Duration" maxlength="6" />
The duration of each reservation (in minutes) must be a multiple of this.
</div>
</div>
-->
<div class="control-group">
<label class="control-label" for="groupManagers">Managed by</label>
<div class="controls" id="managersControlSet">
<button id="eq-group-add-manager-btn" type="button" class="btn btn-success btn-small" title="Add Manager">
<i class="icon-plus-sign icon-white"></i> Add
Manager <i class="icon-plus-sign icon-white"></i></button>
<?php
// TODO: sort appropriately
echo join(" ",
array_map(function ($pd) {
return "<button type=\"button\" id=\"remove-manager-btn-" . $pd['perm_id'] . "\" class=\"btn btn-inverse btn-small eq-group-remove-manager-btn\" title=\"" . $pd['display_text'] . "\" data-ent-type=\"" . $pd['ent_type'] . "\" data-ent-id=\"" . $pd['ent_id'] . "\" data-for-id=\"" . $pd['perm_id'] . "\">" . (($pd['ent_type'] == 'user') ? '<i class="icon-user icon-white"></i> ' : '') . $pd['display_text'] . " <i class=\"icon-remove icon-white\"></i></button>";
}, $manager_permission_data)
);
?>
</div>
</div>
<div class="control-group">
<label class="control-label" for="groupManagers">Reservable by</label>
<div class="controls">
<i>use CTRL and/or SHIFT to select more than one</i></i><br />
<select name="consumers-select" id="consumers-select" class="user-select" size="12" multiple="multiple">
<?php
// TODO: sort appropriately
echo join(" ",
array_map(function ($pd) {
// icon does not show in options return "<option id=\"consumer-perm-option-" . $pd['perm_id'] . "\" title=\"" . $pd['display_text'] . "\" data-ent-type=\"" . $pd['ent_type'] . "\" data-ent-id=\"" . $pd['ent_id'] . "\" data-for-id=\"" . $pd['perm_id'] . "\">" . (($pd['ent_type'] == 'user') ? '<i class="icon-user icon-white"></i> ' : '') . $pd['display_text'] . "</option>\n";
return "<option id=\"consumer-perm-option-" . $pd['perm_id'] . "\" title=\"" . $pd['display_text'] . "\" data-ent-type=\"" . $pd['ent_type'] . "\" data-ent-id=\"" . $pd['ent_id'] . "\" data-for-id=\"" . $pd['perm_id'] . "\">" . $pd['display_text'] . "</option>\n";
}, $consumer_permission_data)
);
?>
</select><br /><br />
<button type="button" id="eq-group-add-consumer-btn" class="btn btn-success btn-small" title="Add Group User">
<i class="icon-plus-sign icon-white"></i> Add <i class="icon-plus-sign icon-white"></i></button>
<button type="button" id="eq-group-remove-consumers-btn" class="btn btn-danger btn-small" title="Remove Selected" disabled="disabled">
<i class="icon-minus-sign icon-white"></i> Remove Selected <i class="icon-minus-sign icon-white"></i></button>
</div>
</div>
<div class="control-group">
<!-- <label class="control-label" for="btnSubmitEditGroup"></label> -->
<!-- <div class="controls"> -->
<button type="submit" id="btnSubmitEditGroup" class="btn btn-success" data-loading-text="Saving...">Save</button>
<button type="button" id="btnCancelEditGroup" class="btn btn-link btn-cancel">Cancel</button>
<!-- </div> -->
</div>
</form>
</div>
<div id="modalAddUserUI" class="modal hide" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="modalAddUserUILabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3 id="modalFindUserUILabel">Add User or Group</h3>
</div>
<div class="modal-body">
<form>
<input type="hidden" id="addUserType" value="" />
<div class="control-group">
<p>Find user or group</p>
<input type="text" id="addUserSearchData" name="addUserSearchData" class="input-large" value="" placeholder="search" maxlength="200" title="search by name, user name, course name, or course id" />
<i class="muted">searches as you type after 3+ characters</i>
</div>
<div id="addUserSearchResultsPreview" class="control-group addUserSearchResultsPreview">
<ul class="unstyled userGroupSearchResultList">
<li class="text-info"><i>type above to start a search</i></li>
</ul>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" id="btnAjaxCancelAddUser" class="btn btn-link btn-cancel pull-left" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
<?php
} else {
# Show this to ordinary consumers (not-admin, not-manager)
echo "<legend class=\"pull-left row-fluid\">".$Requested_EqGroup->name."</legend>";
}
# start_minute comes as a string (eg: 0,20,40) so convert it to a duration (eg: 20) for the timepicker to use
# this only makes sense if the start minutes have uniform intervals
$start_minute_step = $Requested_EqGroup->start_minute;
if($start_minute_step == '0'){
$start_minute_step = '60';
}else{
$start_minute_step = substr($start_minute_step,strlen($start_minute_step)-2);
$start_minute_step = 60 - intval($start_minute_step);
$start_minute_step = strval($start_minute_step);
}
# Show this to all authenticated users
echo "<div id=\"managerView\" data-show-del-isadmin =\"$USER->flag_is_system_admin\" data-show-del-ismanager=\"$is_group_manager\" data-eid =\"$Requested_EqGroup->eq_group_id\" data-duration-start=\"$start_minute_step\">\n";
// echo "<strong>Name:</strong> <span id=\"print_groupName\">" . $Requested_EqGroup->name . "</span><br />\n";
// echo "<strong>Description:</strong> <span id=\"print_groupDescription\">" . $Requested_EqGroup->descr . "</span><br /><br />\n";
echo "<span id=\"print_groupDescription\">" . $Requested_EqGroup->descr . "</span><br /><br />\n";
if ($Requested_EqGroup->reference_link) {
echo "<strong>Reference:</strong> <span id=\"print_referenceLink\"><a href = " . $Requested_EqGroup->reference_link . ">" . $Requested_EqGroup->reference_link . "</a></span><br /><br/>\n";
}
# convert the minutes into prettier form
$min = util_minutesToWords($Requested_EqGroup->min_duration_minutes);
$max = util_minutesToWords($Requested_EqGroup->max_duration_minutes);
$dur = util_minutesToWords($Requested_EqGroup->duration_chunk_minutes);
$dur = substr($dur, 0, -2);
// echo "<strong>Reservation Restrictions:</strong> <span id=\"print_reservationTimeRestrictions\">" . "Can be reserved for ". $min . " min, " . $max . " max, starting on the ". $Requested_EqGroup->start_minute . " of each hour, with duration adjustable by " . $dur . " increments." . "</span><br /><br/>\n";
echo "<strong>Reservation Restrictions:</strong> <span id=\"print_reservationTimeRestrictions\">" . "Can be reserved for ". $min . " min, " . $max . " max, starting on the ". $Requested_EqGroup->start_minute . " of each hour.</span><br /><br/>\n";
echo "<strong>Managed by:</strong> <ul id=\"displayListOfManagers\" class=\"inline\">";
echo join("\n",
array_map(function ($m) {
if (get_class($m) == 'User') {
return "<li id=\"display-manager-user-" . $m->user_id . "\"><i class=\"icon-user\"></i> $m->fname $m->lname</li>";
}
return "<li id=\"display-manager-inst_group-" . $m->inst_group_id . "\">[users in $m->name]</li>";
},
$Requested_EqGroup->managers)
);
echo "</ul>\n";
// echo "<br />\n";
// echo "<legend>Reservation Rules</legend>\n";
// echo "Start times <span class=\"label label-inverse\" title=\"Reservations must start and end on one of these minutes of the hour\"><span id=\"print_startMinute\">" . $Requested_EqGroup->start_minute . "</span> minutes</span><br />\n";
// echo "Min duration <span class=\"label label-inverse\" title=\"The minimum length of time that can be reserved\"><span id=\"print_minDurationMinutes\">" . $Requested_EqGroup->min_duration_minutes . "</span></span><br />\n";
// echo "Max duration <span class=\"label label-inverse\" title=\"The maximum length of time that can be reserved\"><span id=\"print_maxDurationMinutes\">" . $Requested_EqGroup->max_duration_minutes . "</span></span><br />\n";
// echo "Duration unit <span class=\"label label-inverse\" title=\"The time reserved must be an even multiple of this - this is the smallest about by which a reservation duration may be altered\"><span id=\"print_durationIntervalMinutes\">" . $Requested_EqGroup->duration_chunk_minutes . "</span></span><br />\n";
echo "</div>";
?>