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