aboutsummaryrefslogtreecommitdiff
path: root/app/views/institute/basicdata/index.php
blob: 8e697c1e01143bbeec67e9f6273c702a3a2e7020 (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
<?= $question ?? '' ?>
<form method="post" name="edit" action="<?= $controller->url_for('institute/basicdata/store/' . $i_view) ?>" class="default">
    <?= CSRFProtection::tokenTag() ?>

    <fieldset>
        <legend><?= _('Verwaltung der Einrichtungsgrunddaten') ?></legend>

        <label class="col-6">
            <span class="required"><?= _('Name') ?></span>
            <?= I18N::input('Name', $institute->Name, LockRules::Check($institute->id, 'name') ? ['readonly' => true, 'disabled' => true] : ['required' => true]); ?>
        </label>

        <label class="col-3">
            <?= _('Fakultät') ?>

        <? if (count($institute->sub_institutes) > 0): ?>
            <br>
            <small style="font-weight: normal;">
                <?= _('Diese Einrichtung hat den Status einer Fakultät.') ?><br>
                <?= sprintf(_('Es wurden bereits %u andere Einrichtungen zugeordnet.'), count($institute->sub_institutes)) ?>
            </small>
            <input type="hidden" name="Fakultaet" id="Fakultaet" value="<?= $institute->id ?>">
        <? else: ?>
            <select <?= !$may_edit_faculty ? 'readonly disabled' : '' ?> name="Fakultaet" id="Fakultaet">
            <? if ($GLOBALS['perm']->have_perm('root')): ?>
                <option value="<?= $institute->id ?>" <?= ($institute->fakultaets_id == Request::option('Fakultaet', $institute->id)) ? 'selected' : '' ?>>
                    <?= _('Diese Einrichtung hat den Status einer Fakultät.') ?>
                </option>
            <? endif; ?>
            <? if ($may_edit_faculty): ?>
                <? foreach ($faculties as $faculty): ?>
                    <option value="<?= $faculty->id ?>"
                            <? if ($faculty->id === $institute->id): echo 'disabled'; ?>
                            <? elseif ($faculty->id == Request::option('Fakultaet', $institute->fakultaets_id)): echo 'selected'; ?>
                            <? endif; ?>>
                        <?= htmlReady($faculty->name) ?>
                    </option>
                <? endforeach; ?>
            <? else: ?>
                <option value="<?= $institute->fakultaets_id ?>">
                    <?= htmlReady($institute->faculty->name) ?>
                </option>
            <? endif; ?>
            </select>
        <? endif; ?>
        </label>

        <label class="col-3">
            <?= _('Bezeichnung') ?>

            <select name="type" id="type" <?= LockRules::Check($institute->id, 'type') ? 'readonly disabled' : '' ?> >
            <? foreach ($GLOBALS['INST_TYPE'] as $i => $inst_type): ?>
                <option value="<?= $i ?>" <?= (Request::int('type', $institute->type) == $i) ? 'selected' : '' ?>>
                    <?= htmlReady($inst_type['name']) ?>
                </option>
            <? endforeach; ?>
           </select>
        </label>

        <label class="col-3">
            <?= _('Straße') ?>
            <input type="text" <?= LockRules::Check($institute->id, 'strasse') ? 'readonly disabled' : '' ?> id="strasse" name="strasse"
                   value="<?= htmlReady(Request::get('strasse', $institute->strasse)) ?>">
        </label>

        <label class="col-3">
            <?= _('Ort') ?>
            <input type="text" <?= LockRules::Check($institute->id, 'plz') ? 'readonly disabled' : '' ?> id="plz" name="plz"
                   value="<?= htmlReady(Request::get('plz', $institute->plz)) ?>">
        </label>

        <label class="col-3">
            <?= _('Telefonnummer') ?>
            <input type="text" <?= LockRules::Check($institute->id, 'telefon') ? 'readonly disabled' : '' ?> id="telefon" name="telefon"
                   value="<?= htmlReady(Request::get('telefon', $institute->telefon)) ?>">
        </label>

        <label class="col-3">
            <?= _('Faxnummer') ?>
            <input type="text" <?= LockRules::Check($institute->id, 'fax') ? 'readonly disabled' : '' ?> id="fax" name="fax"
                   value="<?= htmlReady(Request::get('fax', $institute->fax)) ?>">
        </label>

        <label class="col-3">
            <?= _('E-Mail-Adresse') ?>
            <input type="text" <?= LockRules::Check($institute->id, 'email') ? 'readonly disabled' : '' ?> id="email" name="email"
                   value="<?= htmlReady(Request::get('email', $institute->email)) ?>">
        </label>

        <label class="col-3">
            <?= _('Homepage') ?>
            <input type="text" <?= LockRules::Check($institute->id, 'url') ? 'readonly disabled' : '' ?> id="home" name="home"
                   value="<?= htmlReady(Request::get('home', $institute->url)) ?>">
        </label>

    <? if ($GLOBALS['perm']->have_perm('root')): // Select lockrule to apply ?>
        <label class="col-3">
            <?= _('Sperrebene') ?>
            <select id="lock_rule" name="lock_rule">
                <option value="">&nbsp;</option>
            <? foreach (LockRule::findAllByType('inst') as $rule): ?>
                <option value="<?= $rule->getId() ?>" <?= ($rule->getId() == Request::option('lock_rule', $institute->lock_rule)) ? 'selected' : '' ?>>
                    <?= htmlReady($rule->name) ?>
                </option>
            <? endforeach;?>
            </select>
        </label>
    <? endif; ?>

    <? foreach ($datafields as $key => $datafield): ?>
        <div class="col-3" style="vertical-align: top">
            <?= $datafield['value'] ?>
        </div>
    <? endforeach; ?>
    </fieldset>

    <footer>
    <? if ($i_view != 'new' && !$institute->isNew()): ?>
        <input type="hidden" name="i_id" value="<?= $institute->id ?>">
        <?= Studip\Button::createAccept(_('Übernehmen'), 'i_edit') ?>
        <?= Studip\LinkButton::create(_('Löschen'),
                                      $controller->url_for('institute/basicdata/index/' . $i_view, ['i_trykill' => 1]),
                                      !$may_delete ? ['disabled' => ''] : []) ?>
        <? if (!$may_delete && mb_strlen($reason_txt) > 0): ?>
            <?= tooltipIcon($reason_txt, true) ?>
        <? endif; ?>
    <? else: ?>
        <?= Studip\Button::create(_('Anlegen'), 'create') ?>
    <? endif; ?>
       <input type="hidden" name="i_view" value="<?= $i_view ?>">
    </footer>
</form>

<?php
$sidebar = Sidebar::get();

if (!$institute->isNew()) {
    $widget = new ActionsWidget();
    $widget->addLink(
        _('Infobild ändern'),
        URLHelper::getURL('dispatch.php/avatar/update/institute/' . $institute->id),
        Icon::create('edit')
    )->asDialog();
    if (InstituteAvatar::getAvatar($institute->id)->is_customized()) {
        $widget->addLink(
            _('Infobild löschen'),
            URLHelper::getURL('dispatch.php/avatar/delete/institute/' . $institute->id),
            Icon::create('trash')
        );
    }
    $sidebar->addWidget($widget);
}