aboutsummaryrefslogtreecommitdiff
path: root/app/views/multipersonsearch/js_form.php
blob: f07fd92cc617837ee7cb244e4c9eae9830f170cc (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
<div class="mpscontainer" data-dialogname="<?= $name ?>">
<form method="post" class="default" action="<?= URLHelper::getLink('dispatch.php/multipersonsearch/js_form_exec/?name=' . $name); ?>" id="<?= $name ?>" <?= $data_dialog_status ? 'data-dialog' : ''?>
      data-secure="li.ms-selected:gt(0)">
    <fieldset>
        <legend>
            <?= htmlReady($title ?? _('Nach Personen suchen')) ?>
        </legend>

        <label class="with-action">
            <span><?= htmlReady($description); ?></span>
            <div class="search-wrapper">
                <input id="<?= $name . '_searchinput'; ?>" type="text" placeholder="<?= _("Suchen"); ?>" value="" name="<?= $name . '_searchinput'; ?>" aria-label="<?= _("Suchen"); ?>" spellcheck="false">
                <button id="<?= $name . '_resetsearch'; ?>" class="icon-button enter-accessible reset-search" onclick='STUDIP.MultiPersonSearch.resetSearch(); return false' title="<?= _('Suche zurücksetzen') ?>">
                    <?= Icon::create('decline')->asImg(['class' => 'text-bottom']) ?>
                </button>
                <button class="icon-button enter-accessible search" onclick='STUDIP.MultiPersonSearch.search();return false' title="<?= _('Suche starten') ?>">
                    <?= Icon::create('search')->asImg(['class' => 'text-bottom']) ?>
                </button>
            </div>
        </label>
        <p><? foreach($quickfilter as $title => $users) : ?>
            <a href="#" class="quickfilter" data-quickfilter="<?= md5($title); ?>"><?= htmlReady($title); ?> (<?= count($users); ?>)</a>
            <select multiple="multiple" id="<?= $name . '_quickfilter_' . md5($title); ?>" style="display: none;">
            <? foreach($users as $user) : ?>
                <option value="<?= $user->id ?>" data-avatar="<?= htmlReady(Avatar::getAvatar($user->id)->getURL(Avatar::MEDIUM)) ?>"><?= htmlReady($user->getFullName('full_rev')) ?> -- <?= htmlReady($user->perms) ?> (<?= htmlReady($user->username)?>)</option>
            <? endforeach; ?>
             </select>
        <? endforeach; ?></p>
        <select multiple="multiple" id="<?= $name . '_selectbox'; ?>" name="<?= $name . '_selectbox'; ?>[]" data-init-js="true">
            <? foreach ($defaultSelectableUsers as $person): ?>
                <option value="<?= $person->id ?>"
                        data-avatar="<?= htmlReady(Avatar::getAvatar($person->id)->getURL(Avatar::MEDIUM)) ?>"
                        <? if ($allowRemoval && in_array($person->id, $defaultSelectedUsers)) echo 'selected'; ?>
                ><?= htmlReady($person->getFullName('full_rev')) ?> -- <?= htmlReady($person->perms) ?> (<?= htmlReady($person->username)?>)</option>
            <? endforeach; ?>
        </select>
        <select multiple="multiple" id="<?= $name . '_selectbox_default'; ?>" style="display: none;">
            <? foreach ($defaultSelectedUsers as $person): ?>
                <option value="<?= $person->id ?>" data-avatar="<?= htmlReady(Avatar::getAvatar($person->id)->getURL(Avatar::MEDIUM)) ?>"><?= htmlReady($person->getFullName('full_rev')) ?> -- <?= htmlReady($person->perms) ?> (<?= htmlReady($person->username)?>)</option>
            <? endforeach; ?>
        </select>

        <?= $additionHTML; ?>
    </fieldset>

    <footer data-dialog-button>
        <? if ($ajax): ?>
            <?= \Studip\Button::create(_('Speichern'), 'confirm', ['data-dialog-button' => true]) ?>
        <? else: ?>
            <?= \Studip\Button::create(_('Speichern'), 'confirm') ?>
            <?= \Studip\Button::create(_('Abbrechen'), $name . '_button_abort') ?>
        <? endif; ?>
        <?= CSRFProtection::tokenTag() ?>
    </footer>
</form>
</div>

<? if ($jsFunction): ?>
<script>
jQuery(document).off('submit.mps-<?= md5($name) ?>').on('submit.mps-<?= md5($name) ?>', '#<?= $name ?>', function () {
    return <?= $jsFunction ?><?= preg_match('/;$/', $jsFunction) ? '' : '(this);'; ?>
});
</script>
<? endif; ?>