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