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