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