aboutsummaryrefslogtreecommitdiff
path: root/app/views/consultation/admin/block-responsibilities.php
blob: ebdb37b9c204ee518528f1975e417b32fb33a413 (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
<?php
/**
 * @var ConsultationBlock|null $block
 */

$block = $block ?? null;
$selected = function ($type, $id) use ($block) {
    if (!$block ) {
        return '';
    }
    $matched = $block->responsibilities->filter(function ($responsibility) use ($type, $id) {
        return $responsibility->range_type === $type && $responsibility->range_id === $id;
    });
    return count($matched) > 0 ? 'selected' : '';
}
?>
<? if (!empty($responsible['users'])): ?>
    <label>
        <?= _('Durchführende Personen') ?>
        <select name="responsibilities[user][]" multiple class="nested-select">
            <? foreach ($responsible['users'] as $user): ?>
                <option value="<?= htmlReady($user->id) ?>" <?= $selected('user', $user->id) ?>>
                    <?= htmlReady($user->getFullName()) ?>
                </option>
            <? endforeach; ?>
        </select>
    </label>
<? endif; ?>

<? if (!empty($responsible['groups'])): ?>
    <label>
        <?= _('Durchführende Gruppen') ?>
        <select name="responsibilities[statusgroup][]" multiple class="nested-select">
            <? foreach ($responsible['groups'] as $group): ?>
                <option value="<?= htmlReady($group->id) ?>" <?= $selected('statusgroup', $group->id) ?>>
                    <?= htmlReady($group->getName()) ?>
                </option>
            <? endforeach; ?>
        </select>
    </label>
<? endif; ?>

<? if (!empty($responsible['institutes'])): ?>
    <label>
        <?= _('Durchführende Einrichtungen') ?>
        <select name="responsibilities[institute][]" multiple class="nested-select">
            <? foreach ($responsible['institutes'] as $institute): ?>
                <option value="<?= htmlReady($institute->id) ?>" <?= $selected('institute', $institute->id) ?>>
                    <?= htmlReady($institute->getFullName()) ?>
                </option>
            <? endforeach; ?>
        </select>
    </label>
<? endif; ?>