1d70512abSGreg Roach<?php 2d70512abSGreg Roach 3d70512abSGreg Roachuse Fisharebest\Webtrees\Date; 47c2c99faSGreg Roachuse Fisharebest\Webtrees\Family; 57d70e4a7SGreg Roachuse Fisharebest\Webtrees\Gedcom; 67d70e4a7SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\AddChildToFamilyPage; 77c7d1e03SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\AddNewFact; 87c7d1e03SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\AddSpouseToFamilyPage; 92917771cSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ReorderChildrenPage; 107d70e4a7SGreg Roachuse Fisharebest\Webtrees\I18N; 117d70e4a7SGreg Roachuse Fisharebest\Webtrees\Individual; 126fcafd02SGreg Roachuse Fisharebest\Webtrees\Services\RelationshipService; 137d70e4a7SGreg Roach 147c2c99faSGreg Roach/** 157c2c99faSGreg Roach * @var Family $family 167c2c99faSGreg Roach * @var int $fam_access_level 177c2c99faSGreg Roach * @var Individual $individual 187c2c99faSGreg Roach * @var string $label 197c2c99faSGreg Roach * @var string $type 207c2c99faSGreg Roach */ 217c2c99faSGreg Roach 227d70e4a7SGreg Roach?> 23dd6b2bfcSGreg Roach 24dd6b2bfcSGreg Roach<table class="table table-sm wt-facts-table"> 25dd6b2bfcSGreg Roach <caption> 26dd6b2bfcSGreg Roach <i class="icon-cfamily"></i> 27dd6b2bfcSGreg Roach <a href="<?= e($family->url()) ?>"><?= $label ?></a> 28dd6b2bfcSGreg Roach </caption> 29dd6b2bfcSGreg Roach 30dd6b2bfcSGreg Roach <tbody> 31dd6b2bfcSGreg Roach <?php 32dd6b2bfcSGreg Roach $found = false; 338d0ebef0SGreg Roach foreach ($family->facts(['HUSB'], false, $fam_access_level) as $fact) { 34dd6b2bfcSGreg Roach $found |= !$fact->isPendingDeletion(); 35dc124885SGreg Roach $person = $fact->target(); 36dd6b2bfcSGreg Roach if ($person instanceof Individual) { 37*1baf69deSGreg Roach $row_class = 'wt-sex-' . strtolower($person->sex()); 38dd6b2bfcSGreg Roach if ($fact->isPendingAddition()) { 3971a69701SGreg Roach $row_class .= ' wt-new'; 40dd6b2bfcSGreg Roach } elseif ($fact->isPendingDeletion()) { 4171a69701SGreg Roach $row_class .= ' wt-old'; 42dd6b2bfcSGreg Roach } 43dd6b2bfcSGreg Roach ?> 44dd6b2bfcSGreg Roach <tr class="<?= $row_class ?>"> 45dd6b2bfcSGreg Roach <th scope="row"> 46dd6b2bfcSGreg Roach <?= $individual === $person ? '<i class="icon-selected"></i>' : '' ?> 476fcafd02SGreg Roach <?= app(RelationshipService::class)->getCloseRelationshipName($individual, $person) ?> 48dd6b2bfcSGreg Roach </th> 49dd6b2bfcSGreg Roach <td class="border-0 p-0"> 50516bb6deSGreg Roach <?= view('chart-box', ['individual' => $person]) ?> 51dd6b2bfcSGreg Roach </td> 52dd6b2bfcSGreg Roach </tr> 53dd6b2bfcSGreg Roach <?php 54dd6b2bfcSGreg Roach } 55dd6b2bfcSGreg Roach } 56dd6b2bfcSGreg Roach if (!$found && $family->canEdit()) { 57dd6b2bfcSGreg Roach ?> 58dd6b2bfcSGreg Roach <tr> 59dd6b2bfcSGreg Roach <th scope="row"></th> 60dd6b2bfcSGreg Roach <td> 61efd4768bSGreg Roach <a href="<?= e(route(AddSpouseToFamilyPage::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'sex' => 'M', 'url' => $individual->url() . '#tab-relatives'])) ?>"> 6217dd427eSGreg Roach <?= I18N::translate('Add a husband') ?> 63dd6b2bfcSGreg Roach </a> 64dd6b2bfcSGreg Roach </td> 65dd6b2bfcSGreg Roach </tr> 66dd6b2bfcSGreg Roach <?php 67dd6b2bfcSGreg Roach } 68dd6b2bfcSGreg Roach 69dd6b2bfcSGreg Roach $found = false; 708d0ebef0SGreg Roach foreach ($family->facts(['WIFE'], false, $fam_access_level) as $fact) { 71dc124885SGreg Roach $person = $fact->target(); 72dd6b2bfcSGreg Roach if ($person instanceof Individual) { 73dd6b2bfcSGreg Roach $found |= !$fact->isPendingDeletion(); 74*1baf69deSGreg Roach $row_class = 'wt-sex-' . strtolower($person->sex()); 75dd6b2bfcSGreg Roach if ($fact->isPendingAddition()) { 7671a69701SGreg Roach $row_class .= ' wt-new'; 77dd6b2bfcSGreg Roach } elseif ($fact->isPendingDeletion()) { 7871a69701SGreg Roach $row_class .= ' wt-old'; 79dd6b2bfcSGreg Roach } 80dd6b2bfcSGreg Roach ?> 81dd6b2bfcSGreg Roach 82dd6b2bfcSGreg Roach <tr class="<?= $row_class ?>"> 83dd6b2bfcSGreg Roach <th scope="row"> 84dd6b2bfcSGreg Roach <?= $individual === $person ? '<i class="icon-selected"></i>' : '' ?> 856fcafd02SGreg Roach <?= app(RelationshipService::class)->getCloseRelationshipName($individual, $person) ?> 86dd6b2bfcSGreg Roach </th> 87dd6b2bfcSGreg Roach <td class="border-0 p-0"> 88516bb6deSGreg Roach <?= view('chart-box', ['individual' => $person]) ?> 89dd6b2bfcSGreg Roach </td> 90dd6b2bfcSGreg Roach </tr> 91dd6b2bfcSGreg Roach <?php 92dd6b2bfcSGreg Roach } 93dd6b2bfcSGreg Roach } 94dd6b2bfcSGreg Roach if (!$found && $family->canEdit()) { ?> 95dd6b2bfcSGreg Roach <tr> 96dd6b2bfcSGreg Roach <th scope="row"></th> 97dd6b2bfcSGreg Roach <td> 98efd4768bSGreg Roach <a href="<?= e(route(AddSpouseToFamilyPage::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'sex' => 'F', 'url' => $individual->url() . '#tab-relatives'])) ?>"> 9917dd427eSGreg Roach <?= I18N::translate('Add a wife') ?> 100dd6b2bfcSGreg Roach </a> 101dd6b2bfcSGreg Roach </td> 102dd6b2bfcSGreg Roach </tr> 103dd6b2bfcSGreg Roach 104dd6b2bfcSGreg Roach <?php } ?> 105dd6b2bfcSGreg Roach 106dd6b2bfcSGreg Roach <?php 107dd6b2bfcSGreg Roach ///// MARR ///// 108dd6b2bfcSGreg Roach $found = false; 109dd6b2bfcSGreg Roach $prev = new Date(''); 1108d0ebef0SGreg Roach foreach ($family->facts(array_merge(Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS), true) as $fact) { 111dd6b2bfcSGreg Roach $found |= !$fact->isPendingDeletion(); 112dd6b2bfcSGreg Roach if ($fact->isPendingAddition()) { 11317dd427eSGreg Roach $row_class = 'wt-new'; 114dd6b2bfcSGreg Roach } elseif ($fact->isPendingDeletion()) { 11517dd427eSGreg Roach $row_class = 'wt-old'; 116dd6b2bfcSGreg Roach } else { 117dd6b2bfcSGreg Roach $row_class = ''; 118dd6b2bfcSGreg Roach } 119dd6b2bfcSGreg Roach ?> 120dd6b2bfcSGreg Roach 121dd6b2bfcSGreg Roach <tr class="<?= $row_class ?>"> 122dd6b2bfcSGreg Roach <th scope="row"> 123315eb316SGreg Roach <span class="visually-hidden"><?= $fact->label() ?></span> 124dd6b2bfcSGreg Roach </th> 1250ec49c9fSGreg Roach 126dd6b2bfcSGreg Roach <td> 12770ac1a22SGreg Roach <span class="label"><?= $fact->label() ?></span> 12870ac1a22SGreg Roach — 12970ac1a22SGreg Roach <span class="field"><?= $fact->date()->display() ?> — <?= $fact->place()->fullName() ?></span> 130dd6b2bfcSGreg Roach </td> 131dd6b2bfcSGreg Roach </tr> 132dd6b2bfcSGreg Roach 133dd6b2bfcSGreg Roach <?php 1342decada7SGreg Roach if (!$prev->isOK() && $fact->date()->isOK()) { 1352decada7SGreg Roach $prev = $fact->date(); 136dd6b2bfcSGreg Roach } 137dd6b2bfcSGreg Roach } 138dd6b2bfcSGreg Roach 139dd6b2bfcSGreg Roach if (!$found && $family->canShow() && $family->canEdit()) { 140dd6b2bfcSGreg Roach ?> 141dd6b2bfcSGreg Roach <tr> 142dd6b2bfcSGreg Roach <th scope="row"> 143315eb316SGreg Roach <span class="visually-hidden"><?= I18N::translate('Marriage') ?></span> 144dd6b2bfcSGreg Roach </th> 1450ec49c9fSGreg Roach 146dd6b2bfcSGreg Roach <td> 1472917771cSGreg Roach <a href="<?= e(route(AddNewFact::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'fact' => 'MARR'])) ?>"> 148dd6b2bfcSGreg Roach <?= I18N::translate('Add marriage details') ?> 149dd6b2bfcSGreg Roach </a> 150dd6b2bfcSGreg Roach </td> 151dd6b2bfcSGreg Roach </tr> 152dd6b2bfcSGreg Roach <?php 153dd6b2bfcSGreg Roach } 154dd6b2bfcSGreg Roach 155dd6b2bfcSGreg Roach ///// CHIL ///// 156dd6b2bfcSGreg Roach $child_number = 0; 1578d0ebef0SGreg Roach foreach ($family->facts(['CHIL'], false, $fam_access_level) as $fact) { 158dc124885SGreg Roach $person = $fact->target(); 159dd6b2bfcSGreg Roach if ($person instanceof Individual) { 160*1baf69deSGreg Roach $row_class = 'wt-sex-' . strtolower($person->sex()); 161dd6b2bfcSGreg Roach if ($fact->isPendingAddition()) { 162dd6b2bfcSGreg Roach $child_number++; 163dd6b2bfcSGreg Roach $row_class .= ' new'; 164dd6b2bfcSGreg Roach } elseif ($fact->isPendingDeletion()) { 165dd6b2bfcSGreg Roach $row_class .= ' old'; 166dd6b2bfcSGreg Roach } else { 167dd6b2bfcSGreg Roach $child_number++; 168dd6b2bfcSGreg Roach } 169dd6b2bfcSGreg Roach $next = new Date(''); 1708d0ebef0SGreg Roach foreach ($person->facts(Gedcom::BIRTH_EVENTS, true) as $bfact) { 1712decada7SGreg Roach if ($bfact->date()->isOK()) { 1722decada7SGreg Roach $next = $bfact->date(); 173dd6b2bfcSGreg Roach break; 174dd6b2bfcSGreg Roach } 175dd6b2bfcSGreg Roach } 176dd6b2bfcSGreg Roach ?> 177dd6b2bfcSGreg Roach 178dd6b2bfcSGreg Roach <tr class="<?= $row_class ?>"> 179dd6b2bfcSGreg Roach <th scope="row"> 180dd6b2bfcSGreg Roach <?php if ($individual === $person) : ?> 181dd6b2bfcSGreg Roach <i class="icon-selected"></i> 182dd6b2bfcSGreg Roach <?php endif ?> 183dd6b2bfcSGreg Roach 184dd6b2bfcSGreg Roach <?php if ($prev->isOK() && $next->isOK()) : ?> 18564490ee2SGreg Roach <div class="wt-date-difference collapse small"> 186dd6b2bfcSGreg Roach <?php $days = $next->maximumJulianDay() - $prev->minimumJulianDay(); ?> 187dd6b2bfcSGreg Roach <?php if ($days < 0 || $child_number > 1 && $days > 1 && $days < 240) : ?> 188e39fd5c6SGreg Roach <?= view('icons/warning') ?> 189dd6b2bfcSGreg Roach <?php endif ?> 190dd6b2bfcSGreg Roach 191dc270d8cSGreg Roach <?php $months = intdiv($days + 15 , 30); ?> 192dd6b2bfcSGreg Roach <?php if (abs($months) === 12 || abs($months) >= 24) : ?> 193dd6b2bfcSGreg Roach <?= I18N::plural('%s year', '%s years', round($months / 12), I18N::number(round($months / 12))) ?> 194dd6b2bfcSGreg Roach <?php elseif ($months !== 0) : ?> 195dd6b2bfcSGreg Roach <?= I18N::plural('%s month', '%s months', $months, I18N::number($months)) ?> 196dd6b2bfcSGreg Roach <?php endif ?> 197dd6b2bfcSGreg Roach </div> 198dd6b2bfcSGreg Roach <?php endif ?> 199dd6b2bfcSGreg Roach 2006fcafd02SGreg Roach <?= app(RelationshipService::class)->getCloseRelationshipName($individual, $person) ?> 201dd6b2bfcSGreg Roach </th> 202dd6b2bfcSGreg Roach <td class="border-0 p-0"> 203516bb6deSGreg Roach <?= view('chart-box', ['individual' => $person]) ?> 204dd6b2bfcSGreg Roach </td> 205dd6b2bfcSGreg Roach </tr> 206dd6b2bfcSGreg Roach <?php 207dd6b2bfcSGreg Roach $prev = $next; 208dd6b2bfcSGreg Roach } 209dd6b2bfcSGreg Roach } ?> 210dd6b2bfcSGreg Roach 211dd6b2bfcSGreg Roach <?php if ($family->canEdit()) : ?> 212dd6b2bfcSGreg Roach <tr> 213dd6b2bfcSGreg Roach <th scope="row"> 214315eb316SGreg Roach <span class="visually-hidden"><?= I18N::translate('Children') ?></span> 2150ec49c9fSGreg Roach </th> 2160ec49c9fSGreg Roach 2170ec49c9fSGreg Roach <td> 218efd4768bSGreg Roach <a href="<?= e(route(AddChildToFamilyPage::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'sex' => 'M', 'url' => $individual->url() . '#tab-relatives'])) ?>"> 2190ec49c9fSGreg Roach <?= $type === 'FAMS' ? I18N::translate('Add a son') : I18N::translate('Add a brother') ?> 2200ec49c9fSGreg Roach </a> 2210ec49c9fSGreg Roach | 222efd4768bSGreg Roach <a href="<?= e(route(AddChildToFamilyPage::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'sex' => 'F', 'url' => $individual->url() . '#tab-relatives'])) ?>"> 2230ec49c9fSGreg Roach <?= $type === 'FAMS' ? I18N::translate('Add a daughter') : I18N::translate('Add a sister') ?> 2240ec49c9fSGreg Roach </a> 2250ec49c9fSGreg Roach | 226efd4768bSGreg Roach <a href="<?= e(route(AddChildToFamilyPage::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'sex' => 'U', 'url' => $individual->url() . '#tab-relatives'])) ?>"> 2270ec49c9fSGreg Roach <?= $type === 'FAMS' ? I18N::translate('Add a child') : I18N::translate('Add a sibling') ?> 2280ec49c9fSGreg Roach </a> 2290ec49c9fSGreg Roach 230820b62dfSGreg Roach <?php if ($family->children()->count() > 1) : ?> 2310ec49c9fSGreg Roach <br> 2325229eadeSGreg Roach <a href="<?= e(route(ReorderChildrenPage::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>"> 233e837ff07SGreg Roach <?= I18N::translate('Re-order children') ?> 234dd6b2bfcSGreg Roach </a> 235dd6b2bfcSGreg Roach <?php endif; ?> 236dd6b2bfcSGreg Roach </td> 237dd6b2bfcSGreg Roach </tr> 238dd6b2bfcSGreg Roach <?php endif ?> 239dd6b2bfcSGreg Roach </tbody> 240dd6b2bfcSGreg Roach</table> 241