aboutsummaryrefslogtreecommitdiff
path: root/app/views/resources/building/_add_edit_form.php
blob: 5871227755c34853937c1d5d101ece824ede6ed1 (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
<?php
/**
 * @var Resources_BuildingController $controller
 * @var bool $show_form
 * @var string $mode
 * @var string $name
 * @var string $category_id
 * @var string $description
 * @var string $parent_id
 * @var string $number
 * @var string $address
 * @var int $sort_position
 * @var Building $building
 * @var Building[] $possible_parents
 * @var array $grouped_defined_properties
 * @var array $property_data
 */
?>
<? if ($show_form): ?>
    <? $url = $mode === 'add'
        ? $controller->add(['category_id' => $category_id])
        : $controller->edit($building->id) ?>
    <form class="default" method="post" action="<?= $url ?>"
          data-dialog="reload-on-close">

        <?= CSRFProtection::tokenTag() ?>
        <fieldset>
            <legend><?= _('Grunddaten') ?></legend>
            <label>
                <?= _('Name des Gebäudes') ?>
                <input type="text" name="name" value="<?= htmlReady($name ?? '') ?>">
            </label>
            <label>
                <?= _('Beschreibungstext') ?>
                <input type="text" name="description" value="<?= htmlReady($description ?? '') ?>">
            </label>
            <label>
                <?= _('Standort / Hierarchie') ?>
                <select name="parent_id">
                    <option value=""><?= _('Bitte wählen') ?></option>
                    <? foreach ($possible_parents as $resource): ?>
                        <option value="<?= htmlReady($resource->id) ?>"
                            <?= $parent_id === $resource->id ? 'selected' : '' ?>>
                            <?= htmlReady('/' . implode('/', ResourceManager::getHierarchyNames($resource))) ?>
                        </option>
                    <? endforeach ?>
                </select>
            </label>
            <label>
                <?= _('Gebäudenummer') ?>
                <input type="text" name="number" value="<?= htmlReady($number ?? '') ?>">
            </label>
            <label>
                <?= _('Adresse') ?>
                <input type="text" name="address" value="<?= htmlReady($address ?? '') ?>">
            </label>
            <? if ($GLOBALS['perm']->have_perm('root')): ?>
                <label>
                    <?= _('Sortierposition') ?>
                    <input type="text" name="sort_position" value="<?= htmlReady($sort_position ?? '') ?>">
                </label>
            <? endif ?>

            <?= $this->render_partial(
                '../../templates/resources/position_attribute_form_part.php',
                [
                    'property_name' => 'geo_coordinates',
                    'latitude'      => $latitude ?? null,
                    'longitude'     => $longitude ?? null,
                    'altitude'      => $altitude ?? null
                ]
            ) ?>
        </fieldset>
        <? if (!empty($grouped_defined_properties)): ?>
            <?= $this->render_partial(
                'resources/resource/_standard_properties_form_part.php',
                [
                    'grouped_defined_properties' => $grouped_defined_properties,
                    'property_data'              => $property_data ?? []
                ]
            ) ?>
        <? endif ?>
        <div data-dialog-button>
            <?= \Studip\Button::create(_('Speichern'), 'confirmed') ?>
        </div>
    </form>
<? endif ?>