xref: /webtrees/resources/views/modules/relatives/family.phtml (revision f4afa648fcb1eff2558e414d35a921dbfbf02078)
1dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\Date; ?>
2dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\Functions\Functions; ?>
3dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\GedcomTag; ?>
4dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\I18N; ?>
5dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\Individual; ?>
6dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\Theme; ?>
7dd6b2bfcSGreg Roach
8dd6b2bfcSGreg Roach<table class="table table-sm wt-facts-table">
9dd6b2bfcSGreg Roach    <caption>
10dd6b2bfcSGreg Roach        <i class="icon-cfamily"></i>
11dd6b2bfcSGreg Roach        <a href="<?= e($family->url()) ?>"><?= $label ?></a>
12dd6b2bfcSGreg Roach    </caption>
13dd6b2bfcSGreg Roach
14dd6b2bfcSGreg Roach    <tbody>
15dd6b2bfcSGreg Roach        <?php
16dd6b2bfcSGreg Roach        $found = false;
17dd6b2bfcSGreg Roach        foreach ($family->getFacts('HUSB', false, $fam_access_level) as $fact) {
18dd6b2bfcSGreg Roach            $found |= !$fact->isPendingDeletion();
19dc124885SGreg Roach            $person = $fact->target();
20dd6b2bfcSGreg Roach            if ($person instanceof Individual) {
21dd6b2bfcSGreg Roach                $row_class = 'wt-gender-' . $person->getSex();
22dd6b2bfcSGreg Roach                if ($fact->isPendingAddition()) {
23dd6b2bfcSGreg Roach                    $row_class .= ' new';
24dd6b2bfcSGreg Roach                } elseif ($fact->isPendingDeletion()) {
25dd6b2bfcSGreg Roach                    $row_class .= ' old';
26dd6b2bfcSGreg Roach                }
27dd6b2bfcSGreg Roach                ?>
28dd6b2bfcSGreg Roach                <tr class="<?= $row_class ?>">
29dd6b2bfcSGreg Roach                    <th scope="row">
30dd6b2bfcSGreg Roach                        <?= $individual === $person ? '<i class="icon-selected"></i>' : '' ?>
31dd6b2bfcSGreg Roach                        <?= Functions::getCloseRelationshipName($individual, $person) ?>
32dd6b2bfcSGreg Roach                    </th>
33dd6b2bfcSGreg Roach                    <td class="border-0 p-0">
34dd6b2bfcSGreg Roach                        <?= Theme::theme()->individualBoxLarge($person) ?>
35dd6b2bfcSGreg Roach                    </td>
36dd6b2bfcSGreg Roach                </tr>
37dd6b2bfcSGreg Roach                <?php
38dd6b2bfcSGreg Roach            }
39dd6b2bfcSGreg Roach        }
40dd6b2bfcSGreg Roach        if (!$found && $family->canEdit()) {
41dd6b2bfcSGreg Roach            ?>
42dd6b2bfcSGreg Roach            <tr>
43dd6b2bfcSGreg Roach                <th scope="row"></th>
44dd6b2bfcSGreg Roach                <td>
45*f4afa648SGreg Roach                    <a href="<?= e(route('add-spouse-to-family', ['ged' => $family->tree()->name(), 'xref' => $family->xref(), 'famtag' => 'HUSB'])) ?>">
46dd6b2bfcSGreg Roach                        <?= I18N::translate('Add a husband to this family') ?>
47dd6b2bfcSGreg Roach                    </a>
48dd6b2bfcSGreg Roach                </td>
49dd6b2bfcSGreg Roach            </tr>
50dd6b2bfcSGreg Roach            <?php
51dd6b2bfcSGreg Roach        }
52dd6b2bfcSGreg Roach
53dd6b2bfcSGreg Roach        $found = false;
54dd6b2bfcSGreg Roach        foreach ($family->getFacts('WIFE', false, $fam_access_level) as $fact) {
55dc124885SGreg Roach            $person = $fact->target();
56dd6b2bfcSGreg Roach            if ($person instanceof Individual) {
57dd6b2bfcSGreg Roach                $found |= !$fact->isPendingDeletion();
58dd6b2bfcSGreg Roach                $row_class = 'wt-gender-' . $person->getSex();
59dd6b2bfcSGreg Roach                if ($fact->isPendingAddition()) {
60dd6b2bfcSGreg Roach                    $row_class .= ' new';
61dd6b2bfcSGreg Roach                } elseif ($fact->isPendingDeletion()) {
62dd6b2bfcSGreg Roach                    $row_class .= ' old';
63dd6b2bfcSGreg Roach                }
64dd6b2bfcSGreg Roach                ?>
65dd6b2bfcSGreg Roach
66dd6b2bfcSGreg Roach                <tr class="<?= $row_class ?>">
67dd6b2bfcSGreg Roach                    <th scope="row">
68dd6b2bfcSGreg Roach                        <?= $individual === $person ? '<i class="icon-selected"></i>' : '' ?>
69dd6b2bfcSGreg Roach                        <?= Functions::getCloseRelationshipName($individual, $person) ?>
70dd6b2bfcSGreg Roach                    </th>
71dd6b2bfcSGreg Roach                    <td class="border-0 p-0">
72dd6b2bfcSGreg Roach                        <?= Theme::theme()->individualBoxLarge($person) ?>
73dd6b2bfcSGreg Roach                    </td>
74dd6b2bfcSGreg Roach                </tr>
75dd6b2bfcSGreg Roach                <?php
76dd6b2bfcSGreg Roach            }
77dd6b2bfcSGreg Roach        }
78dd6b2bfcSGreg Roach        if (!$found && $family->canEdit()) { ?>
79dd6b2bfcSGreg Roach            <tr>
80dd6b2bfcSGreg Roach                <th scope="row"></th>
81dd6b2bfcSGreg Roach                <td>
82*f4afa648SGreg Roach                    <a href="<?= e(route('add-spouse-to-family', ['ged' => $family->tree()->name(), 'xref' => $family->xref(), 'famtag' => 'WIFE'])) ?>">
83dd6b2bfcSGreg Roach                        <?= I18N::translate('Add a wife to this family') ?>
84dd6b2bfcSGreg Roach                    </a>
85dd6b2bfcSGreg Roach                </td>
86dd6b2bfcSGreg Roach            </tr>
87dd6b2bfcSGreg Roach
88dd6b2bfcSGreg Roach        <?php } ?>
89dd6b2bfcSGreg Roach
90dd6b2bfcSGreg Roach        <?php
91dd6b2bfcSGreg Roach        ///// MARR /////
92dd6b2bfcSGreg Roach        $found = false;
93dd6b2bfcSGreg Roach        $prev  = new Date('');
94dd6b2bfcSGreg Roach        foreach ($family->getFacts(WT_EVENTS_MARR . '|' . WT_EVENTS_DIV, true) as $fact) {
95dd6b2bfcSGreg Roach            $found |= !$fact->isPendingDeletion();
96dd6b2bfcSGreg Roach            if ($fact->isPendingAddition()) {
97dd6b2bfcSGreg Roach                $row_class = 'new';
98dd6b2bfcSGreg Roach            } elseif ($fact->isPendingDeletion()) {
99dd6b2bfcSGreg Roach                $row_class = 'old';
100dd6b2bfcSGreg Roach            } else {
101dd6b2bfcSGreg Roach                $row_class = '';
102dd6b2bfcSGreg Roach            }
103dd6b2bfcSGreg Roach            ?>
104dd6b2bfcSGreg Roach
105dd6b2bfcSGreg Roach            <tr class="<?= $row_class ?>">
106dd6b2bfcSGreg Roach                <th scope="row">
107dd6b2bfcSGreg Roach                </th>
108dd6b2bfcSGreg Roach                <td>
1092decada7SGreg Roach                    <?= GedcomTag::getLabelValue($fact->getTag(), $fact->date()->display() . ' — ' . $fact->place()->getFullName()) ?>
110dd6b2bfcSGreg Roach                </td>
111dd6b2bfcSGreg Roach            </tr>
112dd6b2bfcSGreg Roach
113dd6b2bfcSGreg Roach            <?php
1142decada7SGreg Roach            if (!$prev->isOK() && $fact->date()->isOK()) {
1152decada7SGreg Roach                $prev = $fact->date();
116dd6b2bfcSGreg Roach            }
117dd6b2bfcSGreg Roach        }
118dd6b2bfcSGreg Roach
119dd6b2bfcSGreg Roach        if (!$found && $family->canShow() && $family->canEdit()) {
120dd6b2bfcSGreg Roach            ?>
121dd6b2bfcSGreg Roach            <tr>
122dd6b2bfcSGreg Roach                <th scope="row">
123dd6b2bfcSGreg Roach                </th>
124dd6b2bfcSGreg Roach                <td>
125*f4afa648SGreg Roach                    <a href="<?= e(route('add-fact', ['ged' => $family->tree()->name(), 'xref' => $family->xref(), 'fact' => 'MARR'])) ?>">
126dd6b2bfcSGreg Roach                        <?= I18N::translate('Add marriage details') ?>
127dd6b2bfcSGreg Roach                    </a>
128dd6b2bfcSGreg Roach                </td>
129dd6b2bfcSGreg Roach            </tr>
130dd6b2bfcSGreg Roach            <?php
131dd6b2bfcSGreg Roach        }
132dd6b2bfcSGreg Roach
133dd6b2bfcSGreg Roach        ///// CHIL /////
134dd6b2bfcSGreg Roach        $child_number = 0;
135dd6b2bfcSGreg Roach        foreach ($family->getFacts('CHIL', false, $fam_access_level) as $fact) {
136dc124885SGreg Roach            $person = $fact->target();
137dd6b2bfcSGreg Roach            if ($person instanceof Individual) {
138dd6b2bfcSGreg Roach                $row_class = 'wt-gender-' . $person->getSex();
139dd6b2bfcSGreg Roach                if ($fact->isPendingAddition()) {
140dd6b2bfcSGreg Roach                    $child_number++;
141dd6b2bfcSGreg Roach                    $row_class .= ' new';
142dd6b2bfcSGreg Roach                } elseif ($fact->isPendingDeletion()) {
143dd6b2bfcSGreg Roach                    $row_class .= ' old';
144dd6b2bfcSGreg Roach                } else {
145dd6b2bfcSGreg Roach                    $child_number++;
146dd6b2bfcSGreg Roach                }
147dd6b2bfcSGreg Roach                $next = new Date('');
148dd6b2bfcSGreg Roach                foreach ($person->getFacts(WT_EVENTS_BIRT, true) as $bfact) {
1492decada7SGreg Roach                    if ($bfact->date()->isOK()) {
1502decada7SGreg Roach                        $next = $bfact->date();
151dd6b2bfcSGreg Roach                        break;
152dd6b2bfcSGreg Roach                    }
153dd6b2bfcSGreg Roach                }
154dd6b2bfcSGreg Roach                ?>
155dd6b2bfcSGreg Roach
156dd6b2bfcSGreg Roach                <tr class="<?= $row_class ?>">
157dd6b2bfcSGreg Roach                    <th scope="row">
158dd6b2bfcSGreg Roach                        <?php if ($individual === $person) : ?>
159dd6b2bfcSGreg Roach                            <i class="icon-selected"></i>
160dd6b2bfcSGreg Roach                        <?php endif ?>
161dd6b2bfcSGreg Roach
162dd6b2bfcSGreg Roach                        <?php if ($prev->isOK() && $next->isOK()) : ?>
163dd6b2bfcSGreg Roach                            <div class="elderdate age">
164dd6b2bfcSGreg Roach                                <?php $days = $next->maximumJulianDay() - $prev->minimumJulianDay(); ?>
165dd6b2bfcSGreg Roach                                <?php if ($days < 0 || $child_number > 1 && $days > 1 && $days < 240) : ?>
166dd6b2bfcSGreg Roach                                    <i class="icon-warning"></i>
167dd6b2bfcSGreg Roach                                <?php endif ?>
168dd6b2bfcSGreg Roach
169dd6b2bfcSGreg Roach                                <?php $months = round($days / 30); ?>
170dd6b2bfcSGreg Roach                                <?php if (abs($months) === 12 || abs($months) >= 24) : ?>
171dd6b2bfcSGreg Roach                                    <?= I18N::plural('%s year', '%s years', round($months / 12), I18N::number(round($months / 12))) ?>
172dd6b2bfcSGreg Roach                                <?php elseif ($months !== 0) : ?>
173dd6b2bfcSGreg Roach                                    <?= I18N::plural('%s month', '%s months', $months, I18N::number($months)) ?>
174dd6b2bfcSGreg Roach                                <?php endif ?>
175dd6b2bfcSGreg Roach                            </div>
176dd6b2bfcSGreg Roach                        <?php endif ?>
177dd6b2bfcSGreg Roach
178dd6b2bfcSGreg Roach                        <?= Functions::getCloseRelationshipName($individual, $person) ?>
179dd6b2bfcSGreg Roach                    </th>
180dd6b2bfcSGreg Roach                    <td class="border-0 p-0">
181dd6b2bfcSGreg Roach                        <?= Theme::theme()->individualBoxLarge($person) ?>
182dd6b2bfcSGreg Roach                    </td>
183dd6b2bfcSGreg Roach                </tr>
184dd6b2bfcSGreg Roach                <?php
185dd6b2bfcSGreg Roach                $prev = $next;
186dd6b2bfcSGreg Roach            }
187dd6b2bfcSGreg Roach        } ?>
188dd6b2bfcSGreg Roach
189dd6b2bfcSGreg Roach        <?php if ($family->canEdit()) : ?>
190dd6b2bfcSGreg Roach            <tr>
191dd6b2bfcSGreg Roach                <th scope="row">
192dd6b2bfcSGreg Roach                    <?php if (count($family->getChildren()) > 1) : ?>
193*f4afa648SGreg Roach                        <a href="<?= e(route('reorder-children', ['ged' => $family->tree()->name(), 'xref' => $family->xref()])) ?>">
194dd6b2bfcSGreg Roach                            <i class="icon-media-shuffle"></i> <?= I18N::translate('Re-order children') ?>
195dd6b2bfcSGreg Roach                        </a>
196dd6b2bfcSGreg Roach                    <?php endif; ?>
197dd6b2bfcSGreg Roach                </th>
198dd6b2bfcSGreg Roach                <td>
199*f4afa648SGreg Roach                    <a href="<?= e(route('add-child-to-family', ['gender' => 'U', 'ged' => $family->tree()->name(), 'xref' => $family->xref()])) ?>">
200dd6b2bfcSGreg Roach                        <?php if ($type == 'FAMS') : ?>
201dd6b2bfcSGreg Roach                            <?= I18N::translate('Add a son or daughter') ?>
202dd6b2bfcSGreg Roach                        <?php else : ?>
203dd6b2bfcSGreg Roach                            <?= I18N::translate('Add a brother or sister') ?>
204dd6b2bfcSGreg Roach                        <?php endif ?>
205dd6b2bfcSGreg Roach                    </a>
206dd6b2bfcSGreg Roach
207*f4afa648SGreg Roach                    <a href="<?= e(route('add-child-to-family', ['gender' => 'M', 'ged' => $family->tree()->name(), 'xref' => $family->xref()])) ?>" class="icon-sex_m_15x15"></a>
208dd6b2bfcSGreg Roach
209*f4afa648SGreg Roach                    <a href="<?= e(route('add-child-to-family', ['gender' => 'F', 'ged' => $family->tree()->name(), 'xref' => $family->xref()])) ?>" class="icon-sex_f_15x15"></a>
210dd6b2bfcSGreg Roach                </td>
211dd6b2bfcSGreg Roach            </tr>
212dd6b2bfcSGreg Roach        <?php endif ?>
213dd6b2bfcSGreg Roach    </tbody>
214dd6b2bfcSGreg Roach</table>
215