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