xref: /webtrees/resources/views/modules/relatives/tab.phtml (revision b11cdcd45131b1585d66693fab363cfeb18c51a4)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Family;
6use Fisharebest\Webtrees\Http\RequestHandlers\AddChildToIndividualPage;
7use Fisharebest\Webtrees\Http\RequestHandlers\AddParentToIndividualPage;
8use Fisharebest\Webtrees\Http\RequestHandlers\AddSpouseToIndividualPage;
9use Fisharebest\Webtrees\Http\RequestHandlers\LinkChildToFamilyPage;
10use Fisharebest\Webtrees\Http\RequestHandlers\LinkSpouseToIndividualPage;
11use Fisharebest\Webtrees\Http\RequestHandlers\ReorderFamiliesPage;
12use Fisharebest\Webtrees\I18N;
13use Fisharebest\Webtrees\Individual;
14use Illuminate\Support\Collection;
15
16/**
17 * @var bool                   $can_edit
18 * @var int                    $fam_access_level
19 * @var Individual             $individual
20 * @var Collection<int,Family> $parent_families
21 * @var Collection<int,Family> $spouse_families
22 * @var Collection<int,Family> $step_child_families
23 * @var Collection<int,Family> $step_parent_families
24 */
25
26?>
27<?php
28?>
29
30<div class="wt-tab-relatives py-4">
31    <table class="table table-sm wt-facts-table" role="presentation">
32    <tbody>
33        <tr>
34            <td>
35                <label>
36                    <input id="show-date-differences" type="checkbox" data-bs-toggle="collapse" data-bs-target=".wt-date-difference" data-wt-persist="date-differences" autocomplete="off">
37                    <?= I18N::translate('Date differences') ?>
38                </label>
39            </td>
40        </tr>
41    </tbody>
42</table>
43
44<!-- Parents -->
45<?php foreach ($parent_families as $family) : ?>
46    <?= view('modules/relatives/family', [
47        'individual'       => $individual,
48        'family'           => $family,
49        'type'             => 'FAMC',
50        'label'            => $individual->getChildFamilyLabel($family),
51        'fam_access_level' => $fam_access_level,
52    ]) ?>
53<?php endforeach ?>
54
55<!-- step-parents -->
56<?php foreach ($step_parent_families as $family) : ?>
57    <?= view('modules/relatives/family', [
58        'individual'       => $individual,
59        'family'           => $family,
60        'type'             => 'FAMC',
61        'label'            => $individual->getStepFamilyLabel($family),
62        'fam_access_level' => $fam_access_level,
63    ]) ?>
64<?php endforeach ?>
65
66<!-- spouses -->
67<?php foreach ($spouse_families as $family) : ?>
68    <?= view('modules/relatives/family', [
69        'individual'       => $individual,
70        'family'           => $family,
71        'type'             => 'FAMS',
72        'label'            => $individual->getSpouseFamilyLabel($family),
73        'fam_access_level' => $fam_access_level,
74    ]) ?>
75<?php endforeach ?>
76
77<!-- step-children -->
78<?php foreach ($step_child_families as $family) : ?>
79    <?= view('modules/relatives/family', [
80        'individual'       => $individual,
81        'family'           => $family,
82        'type'             => 'FAMS',
83        'label'            => $family->fullName(),
84        'fam_access_level' => $fam_access_level,
85    ]) ?>
86<?php endforeach ?>
87
88<?php if ($can_edit) : ?>
89    <br>
90    <table class="table table-sm wt-facts-table" role="presentation">
91        <tbody>
92            <?php if ($spouse_families->count() > 1) : ?>
93                <tr>
94                    <td>
95                        <a href="<?= e(route(ReorderFamiliesPage::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) ?>">
96                            <?= view('icons/reorder') ?>
97                            <?= I18N::translate('Re-order families') ?>
98                        </a>
99                    </td>
100                </tr>
101            <?php endif ?>
102
103            <?php if ($parent_families->isEmpty()) : ?>
104                <tr>
105                    <td>
106                        <a href="<?= e(route(AddParentToIndividualPage::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref(), 'sex' => 'M', 'url' => $individual->url() . '#tab-relatives'])) ?>">
107                            <?= I18N::translate('Add a father') ?>
108                        </a>
109                    </td>
110                </tr>
111                <tr>
112                    <td>
113                        <a href="<?= e(route(AddParentToIndividualPage::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref(), 'sex' => 'F', 'url' => $individual->url() . '#tab-relatives'])) ?>">
114                            <?= I18N::translate('Add a mother') ?>
115                        </a>
116                    </td>
117                </tr>
118            <?php endif ?>
119
120            <tr>
121                <td>
122                    <a href="<?= e(route(LinkChildToFamilyPage::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) ?>">
123                        <?= I18N::translate('Link this individual to an existing family as a child') ?>
124                    </a>
125                </td>
126            </tr>
127
128            <tr>
129                <td>
130                    <a href="<?= e(route(AddSpouseToIndividualPage::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref(), 'url' => $individual->url() . '#tab-relatives'])) ?>">
131                        <?php if ($individual->sex() !== 'F') : ?>
132                            <?= I18N::translate('Add a wife') ?>
133                        <?php else : ?>
134                            <?= I18N::translate('Add a husband') ?>
135                        <?php endif ?>
136                    </a>
137                </td>
138            </tr>
139
140            <tr>
141                <td>
142                    <a href="<?= e(route(LinkSpouseToIndividualPage::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) ?>">
143                        <?php if ($individual->sex() !== 'F') : ?>
144                            <?= I18N::translate('Add a wife using an existing individual') ?>
145                        <?php else : ?>
146                            <?= I18N::translate('Add a husband using an existing individual') ?>
147                        <?php endif ?>
148                    </a>
149                </td>
150            </tr>
151
152            <tr>
153                <td>
154                    <a href="<?= e(route(AddChildToIndividualPage::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref(), 'sex' => 'U'])) ?>">
155                        <?= I18N::translate('Add a child to create a one-parent family') ?>
156                    </a>
157                </td>
158            </tr>
159        </tbody>
160    </table>
161<?php endif ?>
162</div>
163