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