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