xref: /webtrees/resources/views/edit/edit-fact.phtml (revision c531f071488bc57ed33d9fb17f4e1257010b6e40)
13b3db8adSGreg Roach<?php
23b3db8adSGreg Roach
33b3db8adSGreg Roachuse Fisharebest\Webtrees\Auth;
43b3db8adSGreg Roachuse Fisharebest\Webtrees\Config;
59db6d3cbSGreg Roachuse Fisharebest\Webtrees\Fact;
63b3db8adSGreg Roachuse Fisharebest\Webtrees\Functions\FunctionsEdit;
755749c76SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\EditFactAction;
89db6d3cbSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\EditRawFactPage;
93b3db8adSGreg Roachuse Fisharebest\Webtrees\I18N;
1049a2c9dcSGreg Roachuse Fisharebest\Webtrees\Tree;
113b3db8adSGreg Roachuse Ramsey\Uuid\Uuid;
123b3db8adSGreg Roach
139db6d3cbSGreg Roach/**
149db6d3cbSGreg Roach * @var bool   $can_edit_raw
159db6d3cbSGreg Roach * @var Fact   $fact
169db6d3cbSGreg Roach * @var string $title
1749a2c9dcSGreg Roach * @var Tree   $tree
189db6d3cbSGreg Roach */
199db6d3cbSGreg Roach
203b3db8adSGreg Roach?>
21dd6b2bfcSGreg Roach
22dd6b2bfcSGreg Roach<h2 class="wt-page-title"><?= $title ?></h2>
23dd6b2bfcSGreg Roach
2449a2c9dcSGreg Roach<form method="post" action="<?= e(route(EditFactAction::class, ['tree' => $tree->name(), 'xref' => $fact->record()->xref(), 'fact_id' => $fact->id()])) ?>" class="wt-page-content">
2583615acfSGreg Roach    <?= csrf_field() ?>
26*c531f071SGreg Roach    <input type="hidden" name="url" value="<?= e($url) ?>">
27dd6b2bfcSGreg Roach
289db6d3cbSGreg Roach    <?php FunctionsEdit::createEditForm($fact) ?>
29dd6b2bfcSGreg Roach
30dd6b2bfcSGreg Roach    <?php
319db6d3cbSGreg Roach    $level1type = $fact->getTag();
3249a2c9dcSGreg Roach    switch ($fact->record()->tag()) {
335c73a356SRichard Cissée        case 'SOUR':
345c73a356SRichard Cissée            if ($level1type === 'DATA') {
35d0728097SGreg Roach                // SOUR:DATA facts may take a NOTE (but the SOUR record may not).
365c73a356SRichard Cissée                echo view('cards/add-note', [
375c73a356SRichard Cissée                    'level' => 2,
385c73a356SRichard Cissée                    'tree' => $tree,
395c73a356SRichard Cissée                ]);
405c73a356SRichard Cissée                echo view('cards/add-shared-note', [
415c73a356SRichard Cissée                    'level' => 2,
425c73a356SRichard Cissée                    'tree' => $tree,
435c73a356SRichard Cissée                ]);
445c73a356SRichard Cissée                // SOUR:DATA facts may also take multiple EVEN.
455c73a356SRichard Cissée                echo view('cards/add-sour-data-even', [
465c73a356SRichard Cissée                    'tree' => $tree,
475c73a356SRichard Cissée                ]);
485c73a356SRichard Cissée            }
495c73a356SRichard Cissée            break;
50dd6b2bfcSGreg Roach        case 'FAM':
51dd6b2bfcSGreg Roach        case 'INDI':
52dd6b2bfcSGreg Roach            // FAM and INDI records have real facts. They can take NOTE/SOUR/OBJE/etc.
53dd6b2bfcSGreg Roach            if ($level1type !== 'SEX' && $level1type !== 'NOTE' && $level1type !== 'ALIA') {
54dd6b2bfcSGreg Roach                if ($level1type !== 'SOUR') {
55dd6b2bfcSGreg Roach                    echo view('cards/add-source-citation', [
56dd6b2bfcSGreg Roach                        'level'          => 2,
57dd6b2bfcSGreg Roach                        'full_citations' => $tree->getPreference('FULL_SOURCES'),
58dd6b2bfcSGreg Roach                        'tree'           => $tree,
59dd6b2bfcSGreg Roach                    ]);
60dd6b2bfcSGreg Roach                }
61dd6b2bfcSGreg Roach                if ($level1type !== 'OBJE') {
62dd6b2bfcSGreg Roach                    if ($tree->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($tree)) {
63dd6b2bfcSGreg Roach                        echo view('cards/add-media-object', [
64dd6b2bfcSGreg Roach                            'level' => 2,
65dd6b2bfcSGreg Roach                            'tree'  => $tree,
66dd6b2bfcSGreg Roach                        ]);
67dd6b2bfcSGreg Roach                    }
68dd6b2bfcSGreg Roach                }
69dd6b2bfcSGreg Roach                echo view('cards/add-note', [
70dd6b2bfcSGreg Roach                    'level' => 2,
71dd6b2bfcSGreg Roach                    'tree' => $tree,
72dd6b2bfcSGreg Roach                ]);
73dd6b2bfcSGreg Roach                echo view('cards/add-shared-note', [
74dd6b2bfcSGreg Roach                    'level' => 2,
75dd6b2bfcSGreg Roach                    'tree' => $tree,
76dd6b2bfcSGreg Roach                ]);
77dd6b2bfcSGreg Roach                if ($level1type !== 'ASSO' && $level1type !== 'NOTE' && $level1type !== 'SOUR') {
78dd6b2bfcSGreg Roach                    echo view('cards/add-associate', [
79dd6b2bfcSGreg Roach                        'id'    => Uuid::uuid4()->toString(),
80dd6b2bfcSGreg Roach                        'level' => 2,
81dd6b2bfcSGreg Roach                        'tree' => $tree,
82dd6b2bfcSGreg Roach                    ]);
83dd6b2bfcSGreg Roach                }
84dd6b2bfcSGreg Roach                // allow to add godfather and godmother for CHR fact or best man and bridesmaid  for MARR fact in one window
8522d65e5aSGreg Roach                if (in_array($level1type, Config::twoAssociates(), true)) {
86dd6b2bfcSGreg Roach                    echo view('cards/add-associate', [
87dd6b2bfcSGreg Roach                        'id'    => Uuid::uuid4()->toString(),
88dd6b2bfcSGreg Roach                        'level' => 2,
89dd6b2bfcSGreg Roach                        'tree' => $tree,
90dd6b2bfcSGreg Roach                    ]);
91dd6b2bfcSGreg Roach                }
92dd6b2bfcSGreg Roach                if ($level1type !== 'SOUR') {
93dd6b2bfcSGreg Roach                    echo view('cards/add-restriction', [
94dd6b2bfcSGreg Roach                        'level' => 2,
95dd6b2bfcSGreg Roach                        'tree' => $tree,
96dd6b2bfcSGreg Roach                    ]);
97dd6b2bfcSGreg Roach                }
98dd6b2bfcSGreg Roach            }
99dd6b2bfcSGreg Roach            break;
100dd6b2bfcSGreg Roach        default:
101dd6b2bfcSGreg Roach            // Other types of record do not have these lower-level records
102dd6b2bfcSGreg Roach            break;
103dd6b2bfcSGreg Roach    }
104dd6b2bfcSGreg Roach
105dd6b2bfcSGreg Roach    ?>
106dd6b2bfcSGreg Roach
107dd6b2bfcSGreg Roach    <div class="form-group row">
108dd6b2bfcSGreg Roach        <label class="col-sm-3 col-form-label" for="keep_chan">
109dd6b2bfcSGreg Roach            <?= I18N::translate('Last change') ?>
110dd6b2bfcSGreg Roach        </label>
111dd6b2bfcSGreg Roach        <div class="col-sm-9">
112b6c326d8SGreg Roach            <?= view('components/checkbox-inline', ['label' => I18N::translate('Keep the existing “last change” information'), 'name' => 'keep_chan', 'checked' => (bool) $tree->getPreference('NO_UPDATE_CHAN')]) ?>
11349a2c9dcSGreg Roach            <div>
11449a2c9dcSGreg Roach                <?= I18N::translate('%1$s: %2$s', I18N::translate('Timestamp'), view('components/datetime', ['timestamp' => $fact->record()->lastChangeTimestamp()])) ?>
11549a2c9dcSGreg Roach            </div>
11649a2c9dcSGreg Roach            <div>
11749a2c9dcSGreg Roach                <?= I18N::translate('%1$s: %2$s', I18N::translate('Author of last change'), e($fact->record()->lastChangeUser())) ?>
11849a2c9dcSGreg Roach            </div>
119dd6b2bfcSGreg Roach        </div>
120dd6b2bfcSGreg Roach    </div>
121dd6b2bfcSGreg Roach
122dd6b2bfcSGreg Roach    <div class="form-group row">
123dd6b2bfcSGreg Roach        <div class="col-sm-3 wt-page-options-label">
124dd6b2bfcSGreg Roach        </div>
125dd6b2bfcSGreg Roach        <div class="col-sm-9 wt-page-options-value">
126dd6b2bfcSGreg Roach            <button class="btn btn-primary" type="submit">
127d993d560SGreg Roach                <?= view('icons/save') ?>
128dd6b2bfcSGreg Roach                <?= /* I18N: A button label. */
129dd6b2bfcSGreg Roach                I18N::translate('save') ?>
130dd6b2bfcSGreg Roach            </button>
131fbab8125SGreg Roach            <a class="btn btn-secondary" href="<?= e($url) ?>">
132d993d560SGreg Roach                <?= view('icons/cancel') ?>
133dd6b2bfcSGreg Roach                <?= /* I18N: A button label. */
134dd6b2bfcSGreg Roach                I18N::translate('cancel') ?>
135dd6b2bfcSGreg Roach            </a>
136dd6b2bfcSGreg Roach            <?php if ($can_edit_raw) : ?>
137*c531f071SGreg Roach                <a class="btn btn-link" href="<?= e(route(EditRawFactPage::class, ['xref' => $fact->record()->xref(), 'fact_id' => $fact->id(), 'tree' => $tree->name(), 'url' => $url])) ?>">
138dd6b2bfcSGreg Roach                    <?= I18N::translate('Edit the raw GEDCOM') ?>
139dd6b2bfcSGreg Roach                </a>
140dd6b2bfcSGreg Roach            <?php endif; ?>
141dd6b2bfcSGreg Roach        </div>
142dd6b2bfcSGreg Roach    </div>
143dd6b2bfcSGreg Roach</form>
144dd6b2bfcSGreg Roach
145dd6b2bfcSGreg Roach<?= view('modals/on-screen-keyboard') ?>
146dd6b2bfcSGreg Roach<?= view('modals/ajax') ?>
147dd6b2bfcSGreg Roach<?= view('edit/initialize-calendar-popup') ?>
148