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