aboutsummaryrefslogtreecommitdiff
path: root/app/views/calendar/single/edit.php
blob: f8a2371699a92fa553f9cae3b3a7e294a39e1f2d (plain)
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
<? use Studip\Button, Studip\LinkButton; ?>
<? if (Request::isXhr()) : ?>
    <? foreach (PageLayout::getMessages() as $messagebox) : ?>
        <?= $messagebox ?>
    <? endforeach ?>
<? endif; ?>
<form data-dialog="" method="post" action="<?= $controller->url_for($base . 'edit/' . $range_id . '/' . $event->event_id) ?>" class="default collapsable">
    <?= CSRFProtection::tokenTag() ?>

    <fieldset>
        <legend>
            <? if ($event->isNew()) : ?>
                <?= _('Neuen Termin anlegen') ?>
            <? else : ?>
                <?= _('Termin bearbeiten') ?>
            <? endif; ?>
        </legend>

        <label class="hidden-tiny-down">
            <input type="checkbox" name="isdayevent" value="1" <?= $event->isDayEvent() ? 'checked' : '' ?>
                onChange="jQuery(this).closest('fieldset').find('input[size=\'2\']').prop('disabled', function (i,val) { return !val; });">
            <?= _('Ganztägig') ?>
        </label>

        <section class="required">
            <?= _('Beginn') ?>
        </section>

        <label class="col-3">
            <?= _('Datum') ?>
            <input type="text" name="start_date" id="start-date" value="<?= strftime('%x', $event->getStart()) ?>" size="12" required>
        </label>

        <div class="col-3">
            <?= _('Uhrzeit') ?>

            <div class="hgroup">
                <input class="size-s no-hint"
                       type="text"
                       name="start_hour"
                       value="<?= date('G', $event->getStart()) ?>"
                       size="2"
                       maxlength="2"<?= $event->isDayEvent() ? ' disabled' : '' ?>
                       aria-label="Stunde">
                :
                <input class="size-s no-hint"
                       type="text"
                       name="start_minute"
                       value="<?= date('i', $event->getStart()) ?>"
                       size="2"
                       maxlength="2"<?= $event->isDayEvent() ? ' disabled' : '' ?>
                       aria-label="Minuten">
            </div>
        </div>

        <section class="required">
            <?= _('Ende') ?>
        </section>

        <label class="col-3">
            <?= _('Datum') ?>
            <input type="text" name="end_date" id="end-date" value="<?= strftime('%x', $event->getEnd()) ?>" size="12" required>
        </label>

        <div class="col-3">
            <?= _('Uhrzeit') ?>

            <div class="hgroup">
                <input class="size-s no-hint"
                       type="text"
                       name="end_hour"
                       value="<?= date('G', $event->getEnd()) ?>"
                       size="2"
                       aria-label="<?= _("Stunde") ?>"
                       maxlength="2"<?= $event->isDayEvent() ? ' disabled' : '' ?>>
                :
                <input class="size-s no-hint"
                       type="text"
                       name="end_minute"
                       value="<?= date('i', $event->getEnd()) ?>"
                       size="2"
                       aria-label="<?= _("Minuten") ?>"
                       maxlength="2"<?= $event->isDayEvent() ? ' disabled' : '' ?>>
            </div>
        </div>

        <label>
            <span class="required">
                <?= _('Zusammenfassung') ?>
            </span>

            <input type="text" size="50" name="summary" id="summary" value="<?= htmlReady($event->getTitle()) ?>">
        </label>

        <label>
            <?= _('Beschreibung') ?>
            <textarea rows="2" cols="40" id="description" name="description"><?= htmlReady($event->getDescription()) ?></textarea>
        </label>

        <label class="col-3">
            <?= _('Kategorie') ?>
            <select name="category_intern" id="category-intern" class="nested-select">
            <? foreach ($GLOBALS['PERS_TERMIN_KAT'] as $key => $category) : ?>
                <option value="<?= $key ?>" <?= $key == $event->getCategory() ? 'selected' : '' ?> class="calendar-category<?= $key ?>" data-color-class="calendar-category<?= $key ?>">
                    <?= htmlReady($category['name']) ?>
                </option>
            <? endforeach; ?>
            </select>
        </label>

        <label class="col-3">
            <?= tooltipicon(_('Sie können beliebige Kategorien in das Freitextfeld eingeben. Trennen Sie einzelne Kategorien bitte durch ein Komma.')) ?>
            <input type="text" name="categories" value="<?= htmlReady($event->getUserDefinedCategories()) ?>"
                placeholder="<?= _('Eigener Kategoriename') ?>">
        </label>

        <label>
            <?= _('Raum/Ort') ?>
            <input type="text" name="location" id="location" value="<?= htmlReady($event->getLocation()) ?>">
        </label>

        <? if ($calendar->getPermissionByUser($GLOBALS['user']->id) == Calendar::PERMISSION_OWN) : ?>
        <? $info = _('Private und vertrauliche Termine sind nur für Sie sichtbar.') ?>

        <? /* SEMBBS nur private und vertrauliche Termine
        <? $info = _('Private und vertrauliche Termine sind nur für Sie sichtbar. Öffentliche Termine werden auf ihrer internen Homepage auch anderen Nutzern bekanntgegeben.') ?>
         *
         */ ?>

        <? elseif ($calendar->getRange() == Calendar::RANGE_SEM) : ?>
        <? $info = _('In Veranstaltungskalendern können nur private Termine angelegt werden.') ?>
        <? elseif ($calendar->getRange() == Calendar::RANGE_INST) : ?>
        <? $info = _('In Einrichtungskalendern können nur private Termine angelegt werden.') ?>
        <? else : ?>
        <? $info = _('Im Kalender eines anderen Nutzers können Sie nur private oder vertrauliche Termine einstellen. Vertrauliche Termine sind nur für Sie und den Kalenderbesitzer sichtbar. Alle anderen sehen den Termin nur als Besetztzeit.') ?>
        <? endif; ?>

        <label for="accessibility">
            <?= _('Zugriff') ?>
            <?= tooltipicon($info) ?>

            <select name="accessibility" id="accessibility" size="1">
                <? foreach ($event->getAccessibilityOptions($calendar->getPermissionByUser($GLOBALS['user']->id)) as $key => $option) : ?>
                <option value="<?= $key ?>"<?= $event->getAccessibility() == $key ? ' selected' : '' ?>><?= $option ?></option>
                <? endforeach; ?>
            </select>
        </label>

        <label>
            <?= _('Priorität') ?>

            <? $priority_names = [_('Keine Angabe'), _('Hoch'), _('Mittel'), _('Niedrig')] ?>
            <select name="priority" id="priority" size="1">
                <? foreach ($priority_names as $key => $priority) : ?>
                <option value="<?= $key ?>"<?= $key == $event->getPriority() ? ' selected' : '' ?>><?= $priority ?></option>
                <? endforeach; ?>
            </select>
        </label>

        <? if (!$event->isNew() && Config::get()->CALENDAR_GROUP_ENABLE) : ?>
            <section>
                <? $author = $event->getAuthor() ?>
                <? if ($author) : ?>
                    <?= sprintf(_('Eingetragen am: %s von %s'),
                    strftime('%x, %X', $event->mkdate),
                        htmlReady($author->getFullName('no_title'))) ?>
                <? endif; ?>
            </section>
            <? if ($event->event->mkdate < $event->event->chdate) : ?>
                <? $editor = $event->getEditor() ?>
                <? if ($editor) : ?>
                <section>
                    <?= sprintf(_('Zuletzt bearbeitet am: %s von %s'),
                        strftime('%x, %X', $event->chdate),
                            htmlReady($editor->getFullName('no_title'))) ?>
                </section>
                <? endif; ?>
            <? endif; ?>
        <? endif; ?>
    </fieldset>


    <fieldset class="collapsed">
        <legend>
            <?= _('Wiederholung') ?>
            <? if ($event->getRecurrence('rtype') != 'SINGLE') : ?>
                (<?= $event->toStringRecurrence() ?>)
            <? endif ?>
        </legend>

        <h2><?= _('Wiederholungsart') ?></h2>

        <section>
            <? $linterval = $event->getRecurrence('linterval') ?: '1' ?>
            <? $rec_type = $event->toStringRecurrence(true) ?>
            <ul class="recurrences">
                <li>
                    <label class="rec-label">
                        <input type="radio" class="rec-select" id="rec-none" name="recurrence" value="single"<?= $event->getRecurrence('rtype') == 'SINGLE' ? ' checked' : '' ?>>
                        <?= _('Keine') ?>
                        <?= tooltipIcon(_('Der Termin wird nicht wiederholt.')) ?>
                    </label>
                </li>
                <li>
                    <label class="rec-label">
                        <input type="radio" class="rec-select" id="rec-daily" name="recurrence" value="daily"<?= $event->getRecurrence('rtype') == 'DAILY' ? ' checked' : '' ?>>
                        <?= _('Täglich') ?>
                    </label>

                    <div class="rec-content" id="rec-content-daily">
                        <div class="hgroup">
                            <label>
                                <input type="radio" name="type_daily" value="day"<?= in_array($rec_type, ['daily', 'xdaily']) ? ' checked' : '' ?>>
                                <?= sprintf(_('Jeden %s. Tag'), '<input type="text" size="3" name="linterval_d" value="' . $linterval . '">') ?>
                            </label>
                        </div>

                        <label>
                            <input type="radio" name="type_daily" value="workday"<?= $rec_type == 'workdaily' ? ' checked' : '' ?>>
                            <?= _('Jeden Werktag') ?>
                        </label>
                    </div>
                </li>
                <li>
                    <? $wdays = [
                        '1' => _('Montag'),
                        '2' => _('Dienstag'),
                        '3' => _('Mittwoch'),
                        '4' => _('Donnerstag'),
                        '5' => _('Freitag'),
                        '6' => _('Samstag'),
                        '7' => _('Sonntag')] ?>
                    <label class="rec-label" for="rec-weekly">
                        <input type="radio" class="rec-select" id="rec-weekly" name="recurrence" value="weekly"<?= $event->getRecurrence('rtype') == 'WEEKLY' ? ' checked' : '' ?>>
                        <?= _('Wöchentlich') ?>
                    </label>
                    <div class="rec-content" id="rec-content-weekly">
                        <div class="hgroup">
                            <label>
                                <?= sprintf(_('Jede %s. Woche am:'), '<input type="text" size="3" name="linterval_w" value="' . $linterval . '">') ?>
                            </label>
                        </div>
                        <div>
                            <? $aday = $event->getRecurrence('wdays') ?: date('N', $event->getStart()) ?>
                            <? foreach ($wdays as $key => $wday) : ?>
                            <label style="white-space: nowrap;">
                                <input type="checkbox" name="wdays[]" value="<?= $key ?>"<?= mb_strpos((string) $aday, (string) $key) !== false ? ' checked' : '' ?>>
                                <?= $wday ?>
                            </label>
                            <? endforeach; ?>
                        </div>
                    </div>
                </li>
                <li>
                    <? $mdays = [
                        '1' => _('Ersten'),
                        '2' => _('Zweiten'),
                        '3' => _('Dritten'),
                        '4' => _('Vierten'),
                        '5' => _('Letzten')] ?>
                    <? $mdays_options = '' ?>
                    <? $mday_selected = $event->getRecurrence('sinterval') ?>
                    <? foreach ($mdays as $key => $mday) :
                            $mdays_options .= '<option value="' . $key . '"';
                            if ($key == $mday_selected) {
                                $mdays_options .= ' selected';
                            }
                            $mdays_options .= '>' . $mday . '</option>';
                    endforeach; ?>
                    <? $wdays_options = '' ?>
                    <? $wday_selected = $event->getRecurrence('wdays') ?: date('N', $event->getStart()) ?>
                    <? foreach ($wdays as $key => $wday) :
                            $wdays_options .= '<option value="' . $key . '"';
                            if ($key == $wday_selected) {
                                $wdays_options .= ' selected';
                            }
                            $wdays_options .= '>' . $wday . '</option>';
                    endforeach; ?>

                    <label class="rec-label" for="rec-monthly">
                        <input type="radio" class="rec-select" id="rec-monthly" name="recurrence" value="monthly"<?= $event->getRecurrence('rtype') == 'MONTHLY' ? ' checked' : '' ?>>
                        <?= _('Monatlich') ?>
                    </label>
                    <div class="rec-content" id="rec-content-monthly">
                        <div class="hgroup">
                            <label>
                                <input type="radio" value="day" name="type_m"<?= in_array($rec_type, ['mday_monthly', 'mday_xmonthly']) ? ' checked' : '' ?>>
                                <? $mday = $event->getRecurrence('day') ?: date('j', $event->getStart()) ?>
                                <?= sprintf(_('Wiederholt am %s. jeden %s. Monat'),
                                    '<input type="text" name="day_m" size="2" value="'
                                    . $mday . '">',
                                    '<input type="text" name="linterval_m1" size="3" value="'
                                    . $linterval . '">') ?>
                            </label>
                        </div>
                        <div class="hgroup">
                            <label>
                                <input type="radio" value="wday" name="type_m"<?= in_array($rec_type, ['xwday_xmonthly', 'lastwday_xmonthly', 'xwday_monthly', 'lastwday_monthly']) ? ' checked' : '' ?>>
                                <?= sprintf(_('Jeden %s alle %s Monate'),
                                    '<select size="1" name="sinterval_m">' . $mdays_options . '</select>'
                                    . '<select size="1" name="wday_m">' . $wdays_options . '</select>',
                                    '<input type="text" class="no-hint" size="3" maxlength="3" name="linterval_m2" value="'
                                    . $linterval . '">')?>
                            </label>
                        </div>
                    </div>
                </li>
                <li>
                    <? $months = [
                        '1' => _('Januar'),
                        '2' => _('Februar'),
                        '3' => _('März'),
                        '4' => _('April'),
                        '5' => _('Mai'),
                        '6' => _('Juni'),
                        '7' => _('Juli'),
                        '8' => _('August'),
                        '9' => _('September'),
                        '10' => _('Oktober'),
                        '11' => _('November'),
                        '12' => _('Dezember')] ?>
                    <? $months_options = '' ?>
                    <? $month_selected = $event->getRecurrence('month') ?: date('n', $event->getStart()) ?>
                    <? foreach ($months as $key => $month) :
                            $months_options .= '<option value="' . $key . '"';
                            if ($key == $month_selected) {
                                $months_options .= ' selected';
                            }
                            $months_options .= '>' . $month . '</option>';
                    endforeach; ?>

                    <label class="rec-label" for="rec-yearly">
                        <input type="radio" class="rec-select" id="rec-yearly" name="recurrence" value="yearly"<?= $event->getRecurrence('rtype') == 'YEARLY' ? ' checked' : '' ?>>
                        <?= _('Jährlich') ?>
                    </label>
                    <div class="rec-content" id="rec-content-yearly">
                        <div class="hgroup">
                            <label>
                                <input type="radio" value="day" name="type_y"<?= $rec_type == 'mday_month_yearly' ? ' checked' : '' ?>>
                                <?= sprintf(_('Jeden %s. %s'),
                                    '<input type="text" size="2" maxlength="2" name="day_y" value="'
                                    . ($event->getRecurrence('day') ?: date('j', $event->getStart())) . '">',
                                    '<select size="1" name="month_y1">' . $months_options . '</select>') ?>
                            </label>
                        </div>

                        <div class="hgroup">
                            <label>
                                <input type="radio" value="wday" name="type_y"<?= in_array($rec_type, ['xwday_month_yearly', 'lastwday_month_yearly']) ? ' checked' : '' ?>>
                                <?= sprintf(_('Jeden %s im %s'),
                                    '<select size="1" name="sinterval_y">' . $mdays_options . '</select>'
                                    . '<select size="1" name="wday_y">' . $wdays_options . '</select>',
                                    '<select size="1" name="month_y2">' . $months_options . '</select>') ?>
                            </label>
                        </div>
                    </div>
                </li>
            </ul>
        </section>

        <h2><?= _('Wiederholung endet') ?></h2>

        <label>
            <? $checked = (!$event->getRecurrence('expire') || $event->getRecurrence('expire') >= Calendar::CALENDAR_END) && !$event->getRecurrence('count') ?>
            <input type="radio" name="exp_c" value="never"<?= $checked ? ' checked' : '' ?>>
            <?= _('Nie') ?>
        </label>

        <? $checked = $event->getRecurrence('expire') && $event->getRecurrence('expire') < Calendar::CALENDAR_END && !$event->getRecurrence('count') ?>

        <section class="hgroup">
            <label>
                <input type="radio" name="exp_c" value="date"<?= $checked ? ' checked' : '' ?>>
                <? $exp_date = $event->getRecurrence('expire') != Calendar::CALENDAR_END ? $event->getRecurrence('expire') : $event->getEnd() ?>
                <?= sprintf(_('Am %s'),
                        '<input type="text" class="size-s" name="exp_date" id="exp-date" value="'
                        . strftime('%x', $exp_date) . '">') ?>
            </label>
        </section>

        <section class="hgroup">
            <? $checked = $event->getRecurrence('count') ?>
            <label>
                <input type="radio" name="exp_c" value="count"<?= $checked ? ' checked' : '' ?>>
                <? $exp_count = $event->getRecurrence('count') ?: '10' ?>
                <?= sprintf(_('Nach %s Wiederholungen'),
                        '<input type="text" size="5" name="exp_count" value="'
                        . $exp_count . '">') ?>
            </label>
        </section>


        <label for="exc-dates">
            <?= _('Ausnahmen') ?>
        </label>

        <ul id="exc-dates">
            <? $exceptions = $event->getExceptions(); ?>
            <? sort($exceptions, SORT_NUMERIC); ?>
            <? foreach ($exceptions as $exception) : ?>
            <li>
                <label class="undecorated">
                    <input type="checkbox" name="del_exc_dates[]" value="<?= strftime('%d.%m.%Y', $exception) ?>" style="display: none;">
                    <span><?= strftime('%x', $exception) ?><?= Icon::create('trash', 'clickable', ['title' => _('Ausnahme löschen')])->asImg(16, ['style' => 'vertical-align: text-top;']) ?></span>
                </label>
                <input type="hidden" name="exc_dates[]" value="<?= strftime('%d.%m.%Y', $exception) ?>">
            </li>
            <? endforeach; ?>
        </ul>

        <div class="hgroup">
            <input style="vertical-align: top; opacity: 0.8;"
                   type="text" size="12" name="exc_date" id="exc-date" value=""
                   placeholder="<?= _("Datum eingeben") ?>">
            <span style="vertical-align: top;" onclick="STUDIP.CalendarDialog.addException(); return false;">
                <?= Icon::create('add', 'clickable', ['title' => _('Ausnahme hinzufügen')])->asInput(['class' => 'text-bottom']) ?>
            </span>
        </div>
    </fieldset>

    <? if (Config::get()->CALENDAR_GROUP_ENABLE && $calendar->getRange() == Calendar::RANGE_USER) : ?>
        <?= $this->render_partial('calendar/group/_attendees') ?>
    <? endif; ?>

    <footer data-dialog-button>
        <?= Button::create(_('Speichern'), 'store', ['title' => _('Termin speichern')]) ?>

        <? if (!$event->isNew()) : ?>
        <? if ($event->getRecurrence('rtype') != 'SINGLE') : ?>
        <?= LinkButton::create(_('Aus Serie löschen'), $controller->url_for('calendar/single/delete_recurrence/' . implode('/', $event->getId()) . '/' . $atime)) ?>
        <? endif; ?>
        <?= LinkButton::create(_('Löschen'), $controller->url_for('calendar/single/delete/' . implode('/', $event->getId()))) ?>
        <? endif; ?>
        <? if (!Request::isXhr()) : ?>
        <?= LinkButton::create(_('Abbrechen'), $controller->url_for('calendar/single/' . $last_view, [$event->getStart()])) ?>
        <? endif; ?>
    </footer>
</form>
<script>
    jQuery('#start-date').datepicker({
        altField: '#end-date'
    });
    jQuery('#end-date').datepicker();
    jQuery('#exp-date').datepicker();
    jQuery('#exc-date').datepicker();

    $('ul.recurrences input[type=radio][id^=rec]').bind('change', function() {
        $('.rec-content').hide();

        if ($(this).is(':checked')) {
            $(this).parent().siblings('.rec-content').show();
        }
    })
</script>