1d70512abSGreg Roach<?php 2d70512abSGreg Roach 3d70512abSGreg Roachuse Fisharebest\Webtrees\Date; 4d70512abSGreg Roach 5d70512abSGreg Roach?> 6dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\Functions\Functions; ?> 78d0ebef0SGreg Roach<?php use Fisharebest\Webtrees\Gedcom; ?> 8dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\GedcomTag; ?> 92917771cSGreg Roach<?php use Fisharebest\Webtrees\Http\RequestHandlers\AddNewFact; 102917771cSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ReorderChildrenPage; 115229eadeSGreg Roachuse Fisharebest\Webtrees\I18N; ?> 12dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\Individual; ?> 13dd6b2bfcSGreg Roach 14dd6b2bfcSGreg Roach<table class="table table-sm wt-facts-table"> 15dd6b2bfcSGreg Roach <caption> 16dd6b2bfcSGreg Roach <i class="icon-cfamily"></i> 17dd6b2bfcSGreg Roach <a href="<?= e($family->url()) ?>"><?= $label ?></a> 18dd6b2bfcSGreg Roach </caption> 19dd6b2bfcSGreg Roach 20dd6b2bfcSGreg Roach <tbody> 21dd6b2bfcSGreg Roach <?php 22dd6b2bfcSGreg Roach $found = false; 238d0ebef0SGreg Roach foreach ($family->facts(['HUSB'], false, $fam_access_level) as $fact) { 24dd6b2bfcSGreg Roach $found |= !$fact->isPendingDeletion(); 25dc124885SGreg Roach $person = $fact->target(); 26dd6b2bfcSGreg Roach if ($person instanceof Individual) { 2739ca88baSGreg Roach $row_class = 'wt-gender-' . $person->sex(); 28dd6b2bfcSGreg Roach if ($fact->isPendingAddition()) { 29dd6b2bfcSGreg Roach $row_class .= ' new'; 30dd6b2bfcSGreg Roach } elseif ($fact->isPendingDeletion()) { 31dd6b2bfcSGreg Roach $row_class .= ' old'; 32dd6b2bfcSGreg Roach } 33dd6b2bfcSGreg Roach ?> 34dd6b2bfcSGreg Roach <tr class="<?= $row_class ?>"> 35dd6b2bfcSGreg Roach <th scope="row"> 36dd6b2bfcSGreg Roach <?= $individual === $person ? '<i class="icon-selected"></i>' : '' ?> 37dd6b2bfcSGreg Roach <?= Functions::getCloseRelationshipName($individual, $person) ?> 38dd6b2bfcSGreg Roach </th> 39dd6b2bfcSGreg Roach <td class="border-0 p-0"> 40516bb6deSGreg Roach <?= view('chart-box', ['individual' => $person]) ?> 41dd6b2bfcSGreg Roach </td> 42dd6b2bfcSGreg Roach </tr> 43dd6b2bfcSGreg Roach <?php 44dd6b2bfcSGreg Roach } 45dd6b2bfcSGreg Roach } 46dd6b2bfcSGreg Roach if (!$found && $family->canEdit()) { 47dd6b2bfcSGreg Roach ?> 48dd6b2bfcSGreg Roach <tr> 49dd6b2bfcSGreg Roach <th scope="row"></th> 50dd6b2bfcSGreg Roach <td> 51d72b284aSGreg Roach <a href="<?= e(route('add-spouse-to-family', ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'famtag' => 'HUSB'])) ?>"> 5217dd427eSGreg Roach <?= I18N::translate('Add a husband') ?> 53dd6b2bfcSGreg Roach </a> 54dd6b2bfcSGreg Roach </td> 55dd6b2bfcSGreg Roach </tr> 56dd6b2bfcSGreg Roach <?php 57dd6b2bfcSGreg Roach } 58dd6b2bfcSGreg Roach 59dd6b2bfcSGreg Roach $found = false; 608d0ebef0SGreg Roach foreach ($family->facts(['WIFE'], false, $fam_access_level) as $fact) { 61dc124885SGreg Roach $person = $fact->target(); 62dd6b2bfcSGreg Roach if ($person instanceof Individual) { 63dd6b2bfcSGreg Roach $found |= !$fact->isPendingDeletion(); 6439ca88baSGreg Roach $row_class = 'wt-gender-' . $person->sex(); 65dd6b2bfcSGreg Roach if ($fact->isPendingAddition()) { 66dd6b2bfcSGreg Roach $row_class .= ' new'; 67dd6b2bfcSGreg Roach } elseif ($fact->isPendingDeletion()) { 68dd6b2bfcSGreg Roach $row_class .= ' old'; 69dd6b2bfcSGreg Roach } 70dd6b2bfcSGreg Roach ?> 71dd6b2bfcSGreg Roach 72dd6b2bfcSGreg Roach <tr class="<?= $row_class ?>"> 73dd6b2bfcSGreg Roach <th scope="row"> 74dd6b2bfcSGreg Roach <?= $individual === $person ? '<i class="icon-selected"></i>' : '' ?> 75dd6b2bfcSGreg Roach <?= Functions::getCloseRelationshipName($individual, $person) ?> 76dd6b2bfcSGreg Roach </th> 77dd6b2bfcSGreg Roach <td class="border-0 p-0"> 78516bb6deSGreg Roach <?= view('chart-box', ['individual' => $person]) ?> 79dd6b2bfcSGreg Roach </td> 80dd6b2bfcSGreg Roach </tr> 81dd6b2bfcSGreg Roach <?php 82dd6b2bfcSGreg Roach } 83dd6b2bfcSGreg Roach } 84dd6b2bfcSGreg Roach if (!$found && $family->canEdit()) { ?> 85dd6b2bfcSGreg Roach <tr> 86dd6b2bfcSGreg Roach <th scope="row"></th> 87dd6b2bfcSGreg Roach <td> 88d72b284aSGreg Roach <a href="<?= e(route('add-spouse-to-family', ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'famtag' => 'WIFE'])) ?>"> 8917dd427eSGreg Roach <?= I18N::translate('Add a wife') ?> 90dd6b2bfcSGreg Roach </a> 91dd6b2bfcSGreg Roach </td> 92dd6b2bfcSGreg Roach </tr> 93dd6b2bfcSGreg Roach 94dd6b2bfcSGreg Roach <?php } ?> 95dd6b2bfcSGreg Roach 96dd6b2bfcSGreg Roach <?php 97dd6b2bfcSGreg Roach ///// MARR ///// 98dd6b2bfcSGreg Roach $found = false; 99dd6b2bfcSGreg Roach $prev = new Date(''); 1008d0ebef0SGreg Roach foreach ($family->facts(array_merge(Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS), true) as $fact) { 101dd6b2bfcSGreg Roach $found |= !$fact->isPendingDeletion(); 102dd6b2bfcSGreg Roach if ($fact->isPendingAddition()) { 10317dd427eSGreg Roach $row_class = 'wt-new'; 104dd6b2bfcSGreg Roach } elseif ($fact->isPendingDeletion()) { 10517dd427eSGreg Roach $row_class = 'wt-old'; 106dd6b2bfcSGreg Roach } else { 107dd6b2bfcSGreg Roach $row_class = ''; 108dd6b2bfcSGreg Roach } 109dd6b2bfcSGreg Roach ?> 110dd6b2bfcSGreg Roach 111dd6b2bfcSGreg Roach <tr class="<?= $row_class ?>"> 112dd6b2bfcSGreg Roach <th scope="row"> 113*0ec49c9fSGreg Roach <span class="sr-only"><?= GedcomTag::getLabel($fact->getTag()) ?></span> 114dd6b2bfcSGreg Roach </th> 115*0ec49c9fSGreg Roach 116dd6b2bfcSGreg Roach <td> 117392561bbSGreg Roach <?= GedcomTag::getLabelValue($fact->getTag(), $fact->date()->display() . ' — ' . $fact->place()->fullName()) ?> 118dd6b2bfcSGreg Roach </td> 119dd6b2bfcSGreg Roach </tr> 120dd6b2bfcSGreg Roach 121dd6b2bfcSGreg Roach <?php 1222decada7SGreg Roach if (!$prev->isOK() && $fact->date()->isOK()) { 1232decada7SGreg Roach $prev = $fact->date(); 124dd6b2bfcSGreg Roach } 125dd6b2bfcSGreg Roach } 126dd6b2bfcSGreg Roach 127dd6b2bfcSGreg Roach if (!$found && $family->canShow() && $family->canEdit()) { 128dd6b2bfcSGreg Roach ?> 129dd6b2bfcSGreg Roach <tr> 130dd6b2bfcSGreg Roach <th scope="row"> 131*0ec49c9fSGreg Roach <span class="sr-only"><?= I18N::translate('Marriage') ?></span> 132dd6b2bfcSGreg Roach </th> 133*0ec49c9fSGreg Roach 134dd6b2bfcSGreg Roach <td> 1352917771cSGreg Roach <a href="<?= e(route(AddNewFact::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'fact' => 'MARR'])) ?>"> 136dd6b2bfcSGreg Roach <?= I18N::translate('Add marriage details') ?> 137dd6b2bfcSGreg Roach </a> 138dd6b2bfcSGreg Roach </td> 139dd6b2bfcSGreg Roach </tr> 140dd6b2bfcSGreg Roach <?php 141dd6b2bfcSGreg Roach } 142dd6b2bfcSGreg Roach 143dd6b2bfcSGreg Roach ///// CHIL ///// 144dd6b2bfcSGreg Roach $child_number = 0; 1458d0ebef0SGreg Roach foreach ($family->facts(['CHIL'], false, $fam_access_level) as $fact) { 146dc124885SGreg Roach $person = $fact->target(); 147dd6b2bfcSGreg Roach if ($person instanceof Individual) { 14839ca88baSGreg Roach $row_class = 'wt-gender-' . $person->sex(); 149dd6b2bfcSGreg Roach if ($fact->isPendingAddition()) { 150dd6b2bfcSGreg Roach $child_number++; 151dd6b2bfcSGreg Roach $row_class .= ' new'; 152dd6b2bfcSGreg Roach } elseif ($fact->isPendingDeletion()) { 153dd6b2bfcSGreg Roach $row_class .= ' old'; 154dd6b2bfcSGreg Roach } else { 155dd6b2bfcSGreg Roach $child_number++; 156dd6b2bfcSGreg Roach } 157dd6b2bfcSGreg Roach $next = new Date(''); 1588d0ebef0SGreg Roach foreach ($person->facts(Gedcom::BIRTH_EVENTS, true) as $bfact) { 1592decada7SGreg Roach if ($bfact->date()->isOK()) { 1602decada7SGreg Roach $next = $bfact->date(); 161dd6b2bfcSGreg Roach break; 162dd6b2bfcSGreg Roach } 163dd6b2bfcSGreg Roach } 164dd6b2bfcSGreg Roach ?> 165dd6b2bfcSGreg Roach 166dd6b2bfcSGreg Roach <tr class="<?= $row_class ?>"> 167dd6b2bfcSGreg Roach <th scope="row"> 168dd6b2bfcSGreg Roach <?php if ($individual === $person) : ?> 169dd6b2bfcSGreg Roach <i class="icon-selected"></i> 170dd6b2bfcSGreg Roach <?php endif ?> 171dd6b2bfcSGreg Roach 172dd6b2bfcSGreg Roach <?php if ($prev->isOK() && $next->isOK()) : ?> 17364490ee2SGreg Roach <div class="wt-date-difference collapse small"> 174dd6b2bfcSGreg Roach <?php $days = $next->maximumJulianDay() - $prev->minimumJulianDay(); ?> 175dd6b2bfcSGreg Roach <?php if ($days < 0 || $child_number > 1 && $days > 1 && $days < 240) : ?> 176e39fd5c6SGreg Roach <?= view('icons/warning') ?> 177dd6b2bfcSGreg Roach <?php endif ?> 178dd6b2bfcSGreg Roach 179dd6b2bfcSGreg Roach <?php $months = round($days / 30); ?> 180dd6b2bfcSGreg Roach <?php if (abs($months) === 12 || abs($months) >= 24) : ?> 181dd6b2bfcSGreg Roach <?= I18N::plural('%s year', '%s years', round($months / 12), I18N::number(round($months / 12))) ?> 182dd6b2bfcSGreg Roach <?php elseif ($months !== 0) : ?> 183dd6b2bfcSGreg Roach <?= I18N::plural('%s month', '%s months', $months, I18N::number($months)) ?> 184dd6b2bfcSGreg Roach <?php endif ?> 185dd6b2bfcSGreg Roach </div> 186dd6b2bfcSGreg Roach <?php endif ?> 187dd6b2bfcSGreg Roach 188dd6b2bfcSGreg Roach <?= Functions::getCloseRelationshipName($individual, $person) ?> 189dd6b2bfcSGreg Roach </th> 190dd6b2bfcSGreg Roach <td class="border-0 p-0"> 191516bb6deSGreg Roach <?= view('chart-box', ['individual' => $person]) ?> 192dd6b2bfcSGreg Roach </td> 193dd6b2bfcSGreg Roach </tr> 194dd6b2bfcSGreg Roach <?php 195dd6b2bfcSGreg Roach $prev = $next; 196dd6b2bfcSGreg Roach } 197dd6b2bfcSGreg Roach } ?> 198dd6b2bfcSGreg Roach 199dd6b2bfcSGreg Roach <?php if ($family->canEdit()) : ?> 200dd6b2bfcSGreg Roach <tr> 201dd6b2bfcSGreg Roach <th scope="row"> 202*0ec49c9fSGreg Roach <span class="sr-only"><?= I18N::translate('Children') ?></span> 203*0ec49c9fSGreg Roach </th> 204*0ec49c9fSGreg Roach 205*0ec49c9fSGreg Roach <td> 206*0ec49c9fSGreg Roach <a href="<?= e(route('add-child-to-family', ['gender' => 'M', 'tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>"> 207*0ec49c9fSGreg Roach <?= $type === 'FAMS' ? I18N::translate('Add a son') : I18N::translate('Add a brother') ?> 208*0ec49c9fSGreg Roach </a> 209*0ec49c9fSGreg Roach | 210*0ec49c9fSGreg Roach <a href="<?= e(route('add-child-to-family', ['gender' => 'F', 'tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>"> 211*0ec49c9fSGreg Roach <?= $type === 'FAMS' ? I18N::translate('Add a daughter') : I18N::translate('Add a sister') ?> 212*0ec49c9fSGreg Roach </a> 213*0ec49c9fSGreg Roach | 214*0ec49c9fSGreg Roach <a href="<?= e(route('add-child-to-family', ['gender' => 'U', 'tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>"> 215*0ec49c9fSGreg Roach <?= $type === 'FAMS' ? I18N::translate('Add a child') : I18N::translate('Add a sibling') ?> 216*0ec49c9fSGreg Roach </a> 217*0ec49c9fSGreg Roach 218820b62dfSGreg Roach <?php if ($family->children()->count() > 1) : ?> 219*0ec49c9fSGreg Roach <br> 2205229eadeSGreg Roach <a href="<?= e(route(ReorderChildrenPage::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>"> 221e837ff07SGreg Roach <?= I18N::translate('Re-order children') ?> 222dd6b2bfcSGreg Roach </a> 223dd6b2bfcSGreg Roach <?php endif; ?> 224dd6b2bfcSGreg Roach </td> 225dd6b2bfcSGreg Roach </tr> 226dd6b2bfcSGreg Roach <?php endif ?> 227dd6b2bfcSGreg Roach </tbody> 228dd6b2bfcSGreg Roach</table> 229