xref: /webtrees/resources/views/edit/edit-fact.phtml (revision 83615acfc72bfb50678c6481f2a00bab04041a87)
1<?php use Fisharebest\Webtrees\Auth; ?>
2<?php use Fisharebest\Webtrees\Config; ?>
3<?php use Fisharebest\Webtrees\Functions\FunctionsEdit; ?>
4<?php use Fisharebest\Webtrees\GedcomTag; ?>
5<?php use Fisharebest\Webtrees\I18N; ?>
6<?php use Ramsey\Uuid\Uuid; ?>
7
8<h2 class="wt-page-title"><?= $title ?></h2>
9
10<form method="post" action="<?= e(route('update-fact', ['ged' => $tree->name(), 'xref' => $record->xref(), 'fact_id' => $edit_fact->id()])) ?>" class="wt-page-content">
11    <?= csrf_field() ?>
12
13    <?php FunctionsEdit::createEditForm($edit_fact) ?>
14
15    <?php
16    $level1type = $edit_fact->getTag();
17    switch ($record::RECORD_TYPE) {
18        case 'SOUR':
19            if ($level1type === 'DATA') {
20                // SOUR:DATA facts may take a NOTE (but the SOUR record may not).
21                echo view('cards/add-note', [
22                    'level' => 2,
23                    'tree' => $tree,
24                ]);
25                echo view('cards/add-shared-note', [
26                    'level' => 2,
27                    'tree' => $tree,
28                ]);
29                // SOUR:DATA facts may also take multiple EVEN.
30                echo view('cards/add-sour-data-even', [
31                    'tree' => $tree,
32                ]);
33            }
34            break;
35        case 'FAM':
36        case 'INDI':
37            // FAM and INDI records have real facts. They can take NOTE/SOUR/OBJE/etc.
38            if ($level1type !== 'SEX' && $level1type !== 'NOTE' && $level1type !== 'ALIA') {
39                if ($level1type !== 'SOUR') {
40                    echo view('cards/add-source-citation', [
41                        'level'          => 2,
42                        'full_citations' => $tree->getPreference('FULL_SOURCES'),
43                        'tree'           => $tree,
44                    ]);
45                }
46                if ($level1type !== 'OBJE') {
47                    if ($tree->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($tree)) {
48                        echo view('cards/add-media-object', [
49                            'level' => 2,
50                            'tree'  => $tree,
51                        ]);
52                    }
53                }
54                echo view('cards/add-note', [
55                    'level' => 2,
56                    'tree' => $tree,
57                ]);
58                echo view('cards/add-shared-note', [
59                    'level' => 2,
60                    'tree' => $tree,
61                ]);
62                if ($level1type !== 'ASSO' && $level1type !== 'NOTE' && $level1type !== 'SOUR') {
63                    echo view('cards/add-associate', [
64                        'id'    => Uuid::uuid4()->toString(),
65                        'level' => 2,
66                        'tree' => $tree,
67                    ]);
68                }
69                // allow to add godfather and godmother for CHR fact or best man and bridesmaid  for MARR fact in one window
70                if (in_array($level1type, Config::twoAssociates(), true)) {
71                    echo view('cards/add-associate', [
72                        'id'    => Uuid::uuid4()->toString(),
73                        'level' => 2,
74                        'tree' => $tree,
75                    ]);
76                }
77                if ($level1type !== 'SOUR') {
78                    echo view('cards/add-restriction', [
79                        'level' => 2,
80                        'tree' => $tree,
81                    ]);
82                }
83            }
84            break;
85        default:
86            // Other types of record do not have these lower-level records
87            break;
88    }
89
90    ?>
91
92    <div class="form-group row">
93        <label class="col-sm-3 col-form-label" for="keep_chan">
94            <?= I18N::translate('Last change') ?>
95        </label>
96        <div class="col-sm-9">
97            <?= view('components/checkbox-inline', ['label' => I18N::translate('Keep the existing “last change” information'), 'name' => 'keep_chan', 'checked' => (bool) $tree->getPreference('NO_UPDATE_CHAN')]) ?>
98            <?= GedcomTag::getLabelValue('DATE', view('components/datetime', ['timestamp' => $record->lastChangeTimestamp()])) ?>
99            <?= GedcomTag::getLabelValue('_WT_USER', e($record->lastChangeUser())) ?>
100        </div>
101    </div>
102
103    <div class="form-group row">
104        <div class="col-sm-3 wt-page-options-label">
105        </div>
106        <div class="col-sm-9 wt-page-options-value">
107            <button class="btn btn-primary" type="submit">
108                <?= view('icons/save') ?>
109                <?= /* I18N: A button label. */
110                I18N::translate('save') ?>
111            </button>
112            <a class="btn btn-secondary" href="<?= e($record->url()) ?>">
113                <?= view('icons/cancel') ?>
114                <?= /* I18N: A button label. */
115                I18N::translate('cancel') ?>
116            </a>
117            <?php if ($can_edit_raw) : ?>
118                <a class="btn btn-link" href="<?= e(route('edit-raw-fact', ['xref' => $record->xref(), 'fact_id' => $edit_fact->id(), 'ged' => $tree->name()])) ?>">
119                    <?= I18N::translate('Edit the raw GEDCOM') ?>
120                </a>
121            <?php endif; ?>
122        </div>
123    </div>
124</form>
125
126<?= view('modals/on-screen-keyboard') ?>
127<?= view('modals/ajax') ?>
128<?= view('edit/initialize-calendar-popup') ?>
129