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