aboutsummaryrefslogtreecommitdiff
path: root/app/views/resources/admin/separable_rooms.php
blob: 5bd7ed56dcf60418cedf5283c881709a9b4c6cbd (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
<form class="default" method="post"
      action="<?= URLHelper::getLink('dispatch.php/resources/admin/separable_rooms') ?>">
    <?= CSRFProtection::tokenTag() ?>
    <? if ($building_id): ?>
        <input type="hidden" name="building_id"
               value="<?= htmlReady($building_id) ?>">
    <? else: ?>
        <select name="building_id">
            <? foreach ($buildings as $building): ?>
                <option value="<?= htmlReady($building->id) ?>"
                        <?= $building->id == $building_id
                          ? 'selected="selected"'
                          : '' ?>>
                <?= htmlReady($building->name) ?>
                </option>
            <? endforeach ?>
        </select>
        <?= \Studip\Button::create(_('Gebäude auswählen'), 'select_building') ?>
    <? endif ?>
    <? if ($building_id): ?>
        <? if ($separable_rooms): ?>
            <table class="default">
                <caption><?= sprintf(_('%s: Teilbare Räume'), htmlReady($building->name)) ?></caption>
                <colgroup>
                    <col class="checkbox">
                    <col>
                    <col>
                    <col>
                </colgroup>
                <thead>
                    <tr>
                        <th style="width: 2em;">
                            <input type="checkbox"
                                   data-proxyfor="<?= (
                                                  $separable_rooms
                                                  ? "input[name='selected_separable_rooms[]'"
                                                  : "input[name='selected_single_rooms[]'"
                                                  ) ?>]">
                        </th>
                        <th><?= _('Raumname') ?></th>
                        <th><?= _('Raumteile') ?></th>
                        <th class="actions"><?= _('Aktionen') ?></th>
                    </tr>
                </thead>
                <tfoot>
                    <tr>
                        <td colspan="5">
                            <? if ($separable_rooms): ?>
                                <?= \Studip\Button::create(
                                    _('Teilbare Räume löschen'),
                                    'bulk_delete_separable_rooms'
                                ) ?>
                                <?= \Studip\Button::create(
                                    _('Raumteile löschen'),
                                    'bulk_delete_room_parts'
                                ) ?>
                            <? endif ?>
                        </td>
                    </tr>
                </tfoot>
                <tbody>
                    <? foreach ($separable_rooms as $separable_room): ?>
                        <tr>
                            <td>
                                <input type="checkbox" name="selected_separable_rooms[]"
                                       value="<?= htmlReady($separable_room->id) ?>">
                            </td>
                            <td><?= htmlReady($separable_room->name) ?></td>
                            <td></td>
                            <td class="actions">
                                <a href="<?= $controller->link_for('resources/admin/edit_separable_room/' . $separable_room->id) ?>"
                                   data-dialog="size=auto">
                                    <?= Icon::create('edit')->asImg(['class' => 'text-bottom', 'aria-label' => _('Bearbeiten')]) ?>
                                </a>
                                <?= Icon::create('trash')->asInput(
                                    [
                                        'name' => 'delete_separable_room['
                                              . $separable_room->id . ']',
                                        'class' => 'text-bottom'
                                    ]
                                ) ?>
                            </td>
                        </tr>
                        <? foreach ($separable_room->parts as $room_part): ?>
                            <tr>
                                <td>
                                    <input type="checkbox" name="selected_room_parts[]"
                                           value="<?= htmlReady($room_part->id) ?>">
                                </td>
                                <td></td>
                                <td><?= htmlReady($room_part->getRoomName()) ?></td>
                                <td class="actions">
                                    <?= Icon::create('trash')->asInput(
                                        [
                                            'name' => 'delete_room_part['
                                                  . $room_part->id
                                                  . ']',
                                            'data-confirm' => _('Wollen Sie den Raum wirklich entfernen?'),
                                            'class' => 'text-bottom'
                                        ]
                                    ) ?>
                                </td>
                            </tr>
                        <? endforeach ?>
                    <? endforeach ?>
                </tbody>
            </table>
        <? endif ?>
        <? if ($single_rooms) : ?>
            <table class="default">
                <caption><?= sprintf(_('%s: Einzelne Räume'), htmlReady($building->name)) ?></caption>
                <colgroup>
                    <col class="checkbox">
                    <col>
                </colgroup>
                <thead>
                    <tr>
                        <th style="width: 2em;">
                            <input type="checkbox"
                                   data-proxyfor="input[name='selected_single_rooms[]']">
                        </th>
                        <th><?= _('Raumname') ?></th>
                    </tr>
                </thead>
                <tfoot>
                    <? if ($separable_rooms): ?>
                        <tr>
                            <td colspan="2">
                                <select name="separable_room_id">
                                    <? foreach ($separable_rooms as $separable_room): ?>
                                        <option value="<?= htmlReady($separable_room->id) ?>">
                                            <?= htmlReady($separable_room->name) ?>
                                        </option>
                                    <? endforeach ?>
                                </select>
                                <?= \Studip\Button::create(
                                    _('Raumteil(e) zu teilbarem Raum hinzufügen'),
                                    'add_room_part'
                                ) ?>
                            </td>
                        </tr>
                    <? endif ?>
                    <tr>
                        <td colspan="2">
                            <input type="text" name="separable_room_name"
                                   value="<?= htmlReady($separable_room_name) ?>"
                                   placeholder="<?= _('Name des neuen teilbaren Raumes') ?>">
                            <?= \Studip\Button::create(
                                _('Neuen teilbaren Raum erzeugen'),
                                'create_separable_room'
                            ) ?>
                        </td>
                    </tr>
                </tfoot>
                <tbody>
                    <? if (($single_rooms) && ($separable_rooms)): ?>
                        <tr>
                            <th colspan="3">
                                <input type="checkbox"
                                       data-proxyfor="input[name='selected_single_rooms[]']">
                            </th>
                        </tr>
                    <? endif ?>
                    <? foreach ($single_rooms as $room): ?>
                        <tr>
                            <td>
                                <input type="checkbox" name="selected_single_rooms[]"
                                       value="<?= htmlReady($room->id) ?>">
                            </td>
                            <td><?= htmlReady($room->name) ?></td>
                        </tr>
                    <? endforeach ?>
                </tbody>
            </table>
        <? endif ?>
    <? endif ?>
</form>