xref: /webtrees/resources/views/edit/edit-fact.phtml (revision a437889ddbe8028b0406cbe2795e8799756258d8)
1dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\Auth; ?>
2dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\Config; ?>
3dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\Functions\FunctionsEdit; ?>
4dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\GedcomTag; ?>
5dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\I18N; ?>
6dd6b2bfcSGreg Roach<?php use Ramsey\Uuid\Uuid; ?>
7dd6b2bfcSGreg Roach
8dd6b2bfcSGreg Roach<h2 class="wt-page-title"><?= $title ?></h2>
9dd6b2bfcSGreg Roach
10*a437889dSGreg Roach<form method="post" action="<?= e(route('update-fact', ['tree' => $tree->name()])) ?>" class="wt-page-content">
1183615acfSGreg Roach    <?= csrf_field() ?>
12d72b284aSGreg Roach    <input type="hidden" name="tree" value="<?= e($tree->name()) ?>">
130d5b9818SGreg Roach    <input type="hidden" name="xref" value="<?= e($record->xref()) ?>">
140d5b9818SGreg Roach    <input type="hidden" name="fact_id" value="<?= e($edit_fact->id()) ?>">
15dd6b2bfcSGreg Roach
16dd6b2bfcSGreg Roach    <?php FunctionsEdit::createEditForm($edit_fact) ?>
17dd6b2bfcSGreg Roach
18dd6b2bfcSGreg Roach    <?php
19dd6b2bfcSGreg Roach    $level1type = $edit_fact->getTag();
20dd6b2bfcSGreg Roach    switch ($record::RECORD_TYPE) {
215c73a356SRichard Cissée        case 'SOUR':
225c73a356SRichard Cissée            if ($level1type === 'DATA') {
23d0728097SGreg Roach                // SOUR:DATA facts may take a NOTE (but the SOUR record may not).
245c73a356SRichard Cissée                echo view('cards/add-note', [
255c73a356SRichard Cissée                    'level' => 2,
265c73a356SRichard Cissée                    'tree' => $tree,
275c73a356SRichard Cissée                ]);
285c73a356SRichard Cissée                echo view('cards/add-shared-note', [
295c73a356SRichard Cissée                    'level' => 2,
305c73a356SRichard Cissée                    'tree' => $tree,
315c73a356SRichard Cissée                ]);
325c73a356SRichard Cissée                // SOUR:DATA facts may also take multiple EVEN.
335c73a356SRichard Cissée                echo view('cards/add-sour-data-even', [
345c73a356SRichard Cissée                    'tree' => $tree,
355c73a356SRichard Cissée                ]);
365c73a356SRichard Cissée            }
375c73a356SRichard Cissée            break;
38dd6b2bfcSGreg Roach        case 'FAM':
39dd6b2bfcSGreg Roach        case 'INDI':
40dd6b2bfcSGreg Roach            // FAM and INDI records have real facts. They can take NOTE/SOUR/OBJE/etc.
41dd6b2bfcSGreg Roach            if ($level1type !== 'SEX' && $level1type !== 'NOTE' && $level1type !== 'ALIA') {
42dd6b2bfcSGreg Roach                if ($level1type !== 'SOUR') {
43dd6b2bfcSGreg Roach                    echo view('cards/add-source-citation', [
44dd6b2bfcSGreg Roach                        'level'          => 2,
45dd6b2bfcSGreg Roach                        'full_citations' => $tree->getPreference('FULL_SOURCES'),
46dd6b2bfcSGreg Roach                        'tree'           => $tree,
47dd6b2bfcSGreg Roach                    ]);
48dd6b2bfcSGreg Roach                }
49dd6b2bfcSGreg Roach                if ($level1type !== 'OBJE') {
50dd6b2bfcSGreg Roach                    if ($tree->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($tree)) {
51dd6b2bfcSGreg Roach                        echo view('cards/add-media-object', [
52dd6b2bfcSGreg Roach                            'level' => 2,
53dd6b2bfcSGreg Roach                            'tree'  => $tree,
54dd6b2bfcSGreg Roach                        ]);
55dd6b2bfcSGreg Roach                    }
56dd6b2bfcSGreg Roach                }
57dd6b2bfcSGreg Roach                echo view('cards/add-note', [
58dd6b2bfcSGreg Roach                    'level' => 2,
59dd6b2bfcSGreg Roach                    'tree' => $tree,
60dd6b2bfcSGreg Roach                ]);
61dd6b2bfcSGreg Roach                echo view('cards/add-shared-note', [
62dd6b2bfcSGreg Roach                    'level' => 2,
63dd6b2bfcSGreg Roach                    'tree' => $tree,
64dd6b2bfcSGreg Roach                ]);
65dd6b2bfcSGreg Roach                if ($level1type !== 'ASSO' && $level1type !== 'NOTE' && $level1type !== 'SOUR') {
66dd6b2bfcSGreg Roach                    echo view('cards/add-associate', [
67dd6b2bfcSGreg Roach                        'id'    => Uuid::uuid4()->toString(),
68dd6b2bfcSGreg Roach                        'level' => 2,
69dd6b2bfcSGreg Roach                        'tree' => $tree,
70dd6b2bfcSGreg Roach                    ]);
71dd6b2bfcSGreg Roach                }
72dd6b2bfcSGreg Roach                // allow to add godfather and godmother for CHR fact or best man and bridesmaid  for MARR fact in one window
7322d65e5aSGreg Roach                if (in_array($level1type, Config::twoAssociates(), true)) {
74dd6b2bfcSGreg Roach                    echo view('cards/add-associate', [
75dd6b2bfcSGreg Roach                        'id'    => Uuid::uuid4()->toString(),
76dd6b2bfcSGreg Roach                        'level' => 2,
77dd6b2bfcSGreg Roach                        'tree' => $tree,
78dd6b2bfcSGreg Roach                    ]);
79dd6b2bfcSGreg Roach                }
80dd6b2bfcSGreg Roach                if ($level1type !== 'SOUR') {
81dd6b2bfcSGreg Roach                    echo view('cards/add-restriction', [
82dd6b2bfcSGreg Roach                        'level' => 2,
83dd6b2bfcSGreg Roach                        'tree' => $tree,
84dd6b2bfcSGreg Roach                    ]);
85dd6b2bfcSGreg Roach                }
86dd6b2bfcSGreg Roach            }
87dd6b2bfcSGreg Roach            break;
88dd6b2bfcSGreg Roach        default:
89dd6b2bfcSGreg Roach            // Other types of record do not have these lower-level records
90dd6b2bfcSGreg Roach            break;
91dd6b2bfcSGreg Roach    }
92dd6b2bfcSGreg Roach
93dd6b2bfcSGreg Roach    ?>
94dd6b2bfcSGreg Roach
95dd6b2bfcSGreg Roach    <div class="form-group row">
96dd6b2bfcSGreg Roach        <label class="col-sm-3 col-form-label" for="keep_chan">
97dd6b2bfcSGreg Roach            <?= I18N::translate('Last change') ?>
98dd6b2bfcSGreg Roach        </label>
99dd6b2bfcSGreg Roach        <div class="col-sm-9">
100b6c326d8SGreg Roach            <?= view('components/checkbox-inline', ['label' => I18N::translate('Keep the existing “last change” information'), 'name' => 'keep_chan', 'checked' => (bool) $tree->getPreference('NO_UPDATE_CHAN')]) ?>
1014459dc9aSGreg Roach            <?= GedcomTag::getLabelValue('DATE', view('components/datetime', ['timestamp' => $record->lastChangeTimestamp()])) ?>
102dd6b2bfcSGreg Roach            <?= GedcomTag::getLabelValue('_WT_USER', e($record->lastChangeUser())) ?>
103dd6b2bfcSGreg Roach        </div>
104dd6b2bfcSGreg Roach    </div>
105dd6b2bfcSGreg Roach
106dd6b2bfcSGreg Roach    <div class="form-group row">
107dd6b2bfcSGreg Roach        <div class="col-sm-3 wt-page-options-label">
108dd6b2bfcSGreg Roach        </div>
109dd6b2bfcSGreg Roach        <div class="col-sm-9 wt-page-options-value">
110dd6b2bfcSGreg Roach            <button class="btn btn-primary" type="submit">
111d993d560SGreg Roach                <?= view('icons/save') ?>
112dd6b2bfcSGreg Roach                <?= /* I18N: A button label. */
113dd6b2bfcSGreg Roach                I18N::translate('save') ?>
114dd6b2bfcSGreg Roach            </button>
115dd6b2bfcSGreg Roach            <a class="btn btn-secondary" href="<?= e($record->url()) ?>">
116d993d560SGreg Roach                <?= view('icons/cancel') ?>
117dd6b2bfcSGreg Roach                <?= /* I18N: A button label. */
118dd6b2bfcSGreg Roach                I18N::translate('cancel') ?>
119dd6b2bfcSGreg Roach            </a>
120dd6b2bfcSGreg Roach            <?php if ($can_edit_raw) : ?>
121d72b284aSGreg Roach                <a class="btn btn-link" href="<?= e(route('edit-raw-fact', ['xref' => $record->xref(), 'fact_id' => $edit_fact->id(), 'tree' => $tree->name()])) ?>">
122dd6b2bfcSGreg Roach                    <?= I18N::translate('Edit the raw GEDCOM') ?>
123dd6b2bfcSGreg Roach                </a>
124dd6b2bfcSGreg Roach            <?php endif; ?>
125dd6b2bfcSGreg Roach        </div>
126dd6b2bfcSGreg Roach    </div>
127dd6b2bfcSGreg Roach</form>
128dd6b2bfcSGreg Roach
129dd6b2bfcSGreg Roach<?= view('modals/on-screen-keyboard') ?>
130dd6b2bfcSGreg Roach<?= view('modals/ajax') ?>
131dd6b2bfcSGreg Roach<?= view('edit/initialize-calendar-popup') ?>
132