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