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