aboutsummaryrefslogtreecommitdiff
path: root/app/views/admin/autoinsert/manual.php
blob: d233ed697e581c3fb20cc3c72e0b818b6351d08c (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
<style type="text/css">
    .filter_selection select {
        width: 100%;
    }

    .filter_selection input[name=remove_filter] {
        float: right;
    }
</style>

<form class="default" action="<?= $controller->manual() ?>" method="post">
    <?= CSRFProtection::tokenTag() ?>
    <?= $this->render_partial("admin/autoinsert/_search.php", compact('semester_data', 'sem_search', 'sem_select')) ?>
</form>


<? if ($seminar_search > 0 && $sem_search && $sem_select): ?>
    <form class="default" action="<?= $controller->manual() ?>" method="post">
        <?= CSRFProtection::tokenTag() ?>
        <input type="hidden" name="sem_search" value="<?= htmlReady($sem_search) ?>">
        <input type="hidden" name="sem_select" value="<?= htmlReady($sem_select) ?>">
        <? foreach ($filtertype as $type): ?>
            <input type="hidden" name="filtertype[]" value="<?= $type ?>">
        <? endforeach; ?>

        <table class="default">
            <colgroup>
                <col width="17%">
                <col width="33%">
                <col width="50%">
            </colgroup>
            <thead>
            <tr>
                <th colspan="3"><?= _('Suchergebnisse') ?></th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>
                    <label for="sem_id"><?= _('Veranstaltung') ?></label>
                </td>
                <td colspan="2">
                    <select name="sem_id" id="sem_id" style="width: 100%;">
                        <? foreach ($seminar_search as $seminar): ?>
                            <option
                                value="<?= $seminar[0] ?>" <?= ($sem_id == $seminar[0]) ? 'selected="selected"' : '' ?>>
                                <?= htmlReady($seminar[1]) ?>
                            </option>
                        <? endforeach; ?>
                    </select>
                </td>
            </tr>
            <? if (count($filtertype) != count($available_filtertypes)): ?>
                <tr>
                    <td>
                        <legend for="add_filtertype"><?= _('Filterkriterien') ?></legend>
                    </td>
                    <td colspan="2">
                        <select name="add_filtertype">
                            <? foreach ($available_filtertypes as $key => $value): ?>
                                <? if (!in_array($key, $filtertype)): ?>
                                    <option value="<?= $key ?>"><?= $value ?></option>
                                <? endif ?>
                            <? endforeach; ?>
                        </select>
                        <?= Icon::create(
                            'add',
                            Icon::ROLE_CLICKABLE,
                            ['title' => _('Filter hinzufügen')]
                        )->asInput(["type" => "image", "class" => "middle", "name" => "add_filter"]) ?>
                    </td>
                </tr>
            <? endif ?>
            </tbody>

            <!-- #2 Auswahllisten anzeigen -->
            <? if (!empty($filtertype)): ?>
                <tbody class="default filter_selection" style="vertical-align: top;">
                <tr>
                    <th colspan="3"><?= _('Ausgewählte Filterkriterien') ?></th>
                </tr>
                <? $index = 0;
                foreach ($filtertype

                as $type): ?>
                <? if ($index % 2 == 0): ?>
                <? if ($index != 0): ?></tr><? endif ?>
                <tr>
                    <? endif ?>
                    <td colspan="<?= $index % 2 ? 1 : 2 ?>">
                        <label for="<?= $type ?>"><b><?= $available_filtertypes[$type] ?></b></label>
                        <?= Icon::create(
                            'remove',
                            Icon::ROLE_CLICKABLE,
                            ['title' => _('Filter entfernen')]
                        )->asInput(["type" => "image", "class" => "middle", "name" => "remove_filter[" . $type . "]"]) ?>
                        <br>

                        <select name="filter[<?= $type ?>][]" multiple size="5" class="nested-select">
                            <? foreach ($values[$type] as $key => $value): ?>
                                <? if (is_array($value)): ?>
                                    <option value="<?= $key ?>"
                                            class="nested-item-header" <?= in_array($key, (array)@$filter[$type]) ? 'selected="selected"' : '' ?>><?= htmlReady($value['name']) ?></option>
                                    <? foreach ($value['values'] as $k => $v): ?>
                                        <option value="<?= $k ?>"
                                                class="nested-item" <?= in_array($k, (array)@$filter[$type]) ? 'selected="selected"' : '' ?>><?= htmlReady($v) ?></option>
                                    <? endforeach; ?>
                                <? else: ?>
                                    <option
                                        value="<?= $key ?>" <?= in_array($key, (array)@$filter[$type]) ? 'selected="selected"' : '' ?>><?= htmlReady($value) ?></option>
                                <? endif ?>
                            <? endforeach; ?>
                        </select>
                    </td>
                    <? $index++;
                    endforeach; ?>
                    <? if ($index % 2 != 0): ?>
                        <td>&nbsp;</td>
                    <? endif ?>
                </tr>
                </tbody>
            <? endif ?>
            <tfoot>
            <tr>
                <td colspan="3">
                    <?= Studip\Button::create(_('Eintragen'), 'submit') ?>
                    <?= Icon::create(
                        'question-circle',
                        Icon::ROLE_CLICKABLE,
                        ['title' => _('Vorschau')]
                    )->asInput(["type" => "image", "style" => "vertical-align: middle;", "name" => "preview"]) ?>
                </td>
            </tr>
            </tfoot>
        </table>


    </form>

    <script type="text/javascript">
        jQuery(function ($) {
            $('input[name=preview]').show().click(function (event) {
                if (!$(this).next().length || !$(this).next().is('span')) {
                    $(this).after($('<span id="autoinsert_count" style="vertical-align: middle;"/>'));
                }
                $.getJSON('<?= $controller->manual_count() ?>',
                    $(this).closest('form').serializeArray(),
                    function (json) {
                        var result = "";
                        if (!json || json.error) {
                            result = "Fehler".toLocaleString() + ": ";
                            result += json.error
                                ? json.error.toLocaleString()
                                : "Fehler bei der Übertragung".toLocaleString();
                        } else {
                            result = "Gefundene Nutzer".toLocaleString() + ": ";
                            result += "<strong>" + json.users + "</strong>";
                        }
                        $('#autoinsert_count').html(result);
                    }
                );
                event.preventDefault();
            });
            $('input[name^=remove_filter]').click(function (event) {
                return confirm("Wollen Sie diesen Filter wirklich entfernen?".toLocaleString());
            });
        });
    </script>
<? endif ?>