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