This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oneslotform.html
240 lines (234 loc) · 10.1 KB
/
oneslotform.html
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
<!-- This page defines the form to move an appointment slot -->
<!-- it is used from view.php -->
<?php $usehtmleditor = can_use_html_editor(); ?>
<form name="add" method="post" action="view.php">
<input type="hidden" name="what" value="<?php p($form->what) ?>" />
<input type="hidden" name="id" value="<?php p($cm->id) ?>" />
<input type="hidden" name="page" value="<?php p($page) ?>" />
<input type="hidden" name="subaction" value="" />
<input type="hidden" name="offset" value="<?php p($offset) ?>" />
<input type="hidden" name="studentid" value="" /><!-- for appointments managment, and scheduling only -->
<input type="hidden" name="groupid" value="" /><!-- for group scheduling only -->
<input type="hidden" name="appointments" value="<?php p(serialize($form->appointments)) ?>" />
<?php
if (!has_capability('mod/scheduler:canscheduletootherteachers', $context)){
?>
<input type="hidden" name="teacherid" value="<?php p($form->teacherid) ?>" />
<?php
}
if ($action == 'updateslot'){
?>
<input type="hidden" name="slotid" value="<?php p($slotid) ?>" />
<?php
}
elseif ($action == 'schedule'){
?>
<input type="hidden" name="seen" value="<?php p($form->seen) ?>" />
<?php
}
?>
<center>
<table cellpadding="5">
<?php
if($action == 'schedule' or $action == 'schedulegroup'){
if ($form->availableslots){
?>
<tr valign="top">
<td align="right"><b><?php print_string('chooseexisting', 'scheduler') ?>:</b></td>
<td align="left">
<script type="text/javascript">
function reloadandchoose(){
document.forms['add'].what.value = '<?php p($action) ?>';
document.forms['add'].subaction.value = 'dochooseslot';
document.forms['add'].studentid.value = '<?php p(@$form->studentid) ?>';
document.forms['add'].groupid.value = '<?php p(@$form->groupid) ?>';
document.forms['add'].submit();
}
</script>
<?php
$startdatemem = '';
$starttimemem = '';
foreach($form->availableslots as $aSlot){
$startdatecnv = scheduler_userdate($aSlot->starttime,1);
$starttimecnv = scheduler_usertime($aSlot->starttime,1);
$startdatestr = ($startdatemem != '' and $startdatemem == $startdatecnv) ? "-----------------" : $startdatecnv ;
$starttimestr = ($starttimemem != '' and $starttimemem == $starttimecnv) ? '' : $starttimecnv ;
$startdatemem = $startdatecnv;
$starttimemem = $starttimecnv;
$form->availableslotsmenu[$aSlot->id] = "$startdatestr $starttimestr";
}
choose_from_menu($form->availableslotsmenu, 'slotid', $form->slotid, 'choose', 'reloadandchoose();');
?>
</td>
</tr>
<?php
}
}
?>
<tr valign="top">
<td align="right"><b><?php print_string('date', 'scheduler') ?>:</b></td>
<td align="left" <?php scheduler_print_error_class(@$errors, 'rangestart') ?> >
<?php print_date_selector('day', 'month', 'year', $form->starttime); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('starttime', 'scheduler') ?>:</b></td>
<td align="left">
<?php
print_time_selector('hour', 'minute', $form->starttime, 5);
helpbutton('choosingslotstart', get_string('moveslot', 'scheduler'), 'scheduler');
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('duration', 'scheduler') ?>:</b></td>
<td align="left">
<input type="text" size="3" maxlength="3" name="duration" value="<?php echo $form->duration?>" />
<?php print_string('minutes', 'scheduler') ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('multiplestudents', 'scheduler') ?>:</b></td>
<td align="left" <?php scheduler_print_error_class(@$errors, 'exclusivity') ?> >
<script type="text/javascript">
function allowmoreappointments(selectobj){
var addlink = document.getElementById('addappointment');
if (selectobj.options[selectobj.selectedIndex].value > <?php echo count($form->appointments) ?> ){
addlink.style.visibility = 'visible';
} else {
addlink.style.visibility = 'hidden';
}
}
</script>
<?php
$exclusivemenu['0'] = get_string('unlimited', 'scheduler');
$knownslots = count($form->appointments);
if ($knownslots == 0) $knownslots++;
for($i = $knownslots ; $i < 10 ; $i++){
$exclusivemenu[(string)$i] = $i;
}
choose_from_menu($exclusivemenu, 'exclusivity', $form->exclusivity, '', 'allowmoreappointments(this);');
helpbutton('exclusivity', get_string('groupsession', 'scheduler'), 'scheduler');
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('reuse', 'scheduler') ?>:</b></td>
<td align="left">
<?php
$reusemenu[0] = get_string('no');
$reusemenu[1] = get_string('yes');
choose_from_menu($reusemenu, 'reuse', $form->reuse, '');
helpbutton('reuse', get_string('reuse', 'scheduler'), 'scheduler');
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('location', 'scheduler') ?>:</b></td>
<td align="left">
<input type="text" size="30" maxlength="50" name="appointmentlocation" value="<?php echo $form->appointmentlocation?>" />
<?php helpbutton('location', get_string('location', 'scheduler'), 'scheduler'); ?>
</td>
</tr>
<?php
if (has_capability('mod/scheduler:canscheduletootherteachers', $context)){
?>
<tr valign="top">
<td align="right"><b><?php echo $scheduler->staffrolename ?>:</b></td>
<td align="left" <?php scheduler_print_error_class(@$errors, 'teacherid') ?> >
<?php
$attendants = scheduler_get_attendants($cm->id);
$attendantsmenu = array();
if ($attendants){
foreach($attendants as $attendant){
$attendantsmenu[$attendant->id] = fullname($attendant);
}
choose_from_menu($attendantsmenu, 'teacherid', $form->teacherid);
} else {
print_string('noteachershere', 'scheduler', format_string($scheduler->staffrolename));
}
helpbutton('bookwithteacher', get_string('bookwithteacher', 'scheduler'), 'scheduler');
?>
</td>
</tr>
<?php
}
?>
<tr valign="top">
<td align="right"><b><?php print_string('displayfrom', 'scheduler') ?>:</b></td>
<td align="left">
<?php print_date_selector('displayday', 'displaymonth', 'displayyear', $form->hideuntil); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('comments', 'scheduler') ?>:</b></td>
<td align="left">
<?php
if (!isset($form->notes)) {
$form->notes = '';
}
print_textarea($usehtmleditor, 20, 60, 680, 400, 'notes', $form->notes);
if ($usehtmleditor) {
echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
} else {
echo '<p align="right">';
helpbutton('textformat', get_string('formattexttype'));
print_string('formattexttype');
echo ': ';
if (!$form->format) {
$form->format = 'MOODLE';
}
choose_from_menu(format_text_menu(), 'format', $form->format, '');
echo '</p>';
}
?>
</td>
</tr>
<tr>
<td colspan="2">
<?php
print_simple_box_start(get_string('appointments', 'scheduler'), 'center');
if (!empty($form->appointments) && count($form->appointments)){
echo "
<script type=\"text/javascript\">
function deleteAppointment(studentid){
document.forms['add'].subaction.value = 'doremoveappointed';
document.forms['add'].studentid.value = studentid;
document.forms['add'].what.value = '{$action}';
document.forms['add'].submit();
}
function updateAppointment(studentid){
document.forms['add'].subaction.value = 'updateappointed';
document.forms['add'].studentid.value = studentid;
document.forms['add'].what.value = '{$action}';
document.forms['add'].submit();
}
</script>
";
$table->head = array ('', get_string('students'), $strseen, $strnote, $strgrade, $straction);
$table->align = array ('LEFT', 'LEFT', 'CENTER', 'LEFT', 'CENTER', 'RIGHT');
$table->width = '';
foreach($form->appointments as $anAppointment){
$user = get_record('user', 'id', $anAppointment->studentid);
$gradetext = scheduler_format_grade($scheduler,$anAppointment->grade);
$attended = $anAppointment->attended ? '<img src="pix/ticked.gif" border="0">' : '<img src="pix/unticked.gif" border="0">' ;
$cmds = "<a href=\"javascript:updateAppointment('{$anAppointment->studentid}')\" title=\"".get_string('edit')."\"><img src=\"{$CFG->pixpath}/t/edit.gif\"></a> ";
$cmds .= "<a href=\"javascript:deleteAppointment('{$anAppointment->studentid}')\" title=\"".get_string('remove')."\"><img src=\"{$CFG->pixpath}/t/delete.gif\"></a>";
$table->data[] = array('', fullname($user), $attended, stripslashes($anAppointment->appointmentnote), $gradetext, $cmds);
}
print_table($table);
} else {
print_string('noappointments', 'scheduler');
}
echo '<br />';
$hiddenstate = ((count($form->appointments) < $form->exclusivity and $form->exclusivity > 0) || !$form->exclusivity) ? "style=\"visibility:visible\"" : "style=\"visibility:hidden\"" ;
echo "<div id=\"addappointment\" $hiddenstate ><a href=\"javascript:document.forms['add'].what.value = '{$action}' ;document.forms['add'].subaction.value = 'addappointed' ;document.forms['add'].submit();\">".get_string('appointsomeone','scheduler').'</a></div>';
print_simple_box_end();
?>
</td>
</tr>
</table>
<input type="submit" value="<?php print_string('save', 'scheduler') ?>" />
<input type="button" value="<?php print_string('cancel') ?>" onclick="self.location.href='view.php?id=<?php echo $cm->id?>'" />
</center>
</form>