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