1dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\Date; ?> 2dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\Functions\Functions; ?> 38d0ebef0SGreg Roach<?php use Fisharebest\Webtrees\Gedcom; ?> 4dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\GedcomTag; ?> 5dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\I18N; ?> 6dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\Individual; ?> 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; 178d0ebef0SGreg Roach foreach ($family->facts(['HUSB'], false, $fam_access_level) as $fact) { 18dd6b2bfcSGreg Roach $found |= !$fact->isPendingDeletion(); 19dc124885SGreg Roach $person = $fact->target(); 20dd6b2bfcSGreg Roach if ($person instanceof Individual) { 2139ca88baSGreg Roach $row_class = 'wt-gender-' . $person->sex(); 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"> 34516bb6deSGreg Roach <?= view('chart-box', ['individual' => $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*d72b284aSGreg Roach <a href="<?= e(route('add-spouse-to-family', ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'famtag' => 'HUSB'])) ?>"> 4617dd427eSGreg Roach <?= I18N::translate('Add a husband') ?> 47dd6b2bfcSGreg Roach </a> 48dd6b2bfcSGreg Roach </td> 49dd6b2bfcSGreg Roach </tr> 50dd6b2bfcSGreg Roach <?php 51dd6b2bfcSGreg Roach } 52dd6b2bfcSGreg Roach 53dd6b2bfcSGreg Roach $found = false; 548d0ebef0SGreg Roach foreach ($family->facts(['WIFE'], false, $fam_access_level) as $fact) { 55dc124885SGreg Roach $person = $fact->target(); 56dd6b2bfcSGreg Roach if ($person instanceof Individual) { 57dd6b2bfcSGreg Roach $found |= !$fact->isPendingDeletion(); 5839ca88baSGreg Roach $row_class = 'wt-gender-' . $person->sex(); 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"> 72516bb6deSGreg Roach <?= view('chart-box', ['individual' => $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*d72b284aSGreg Roach <a href="<?= e(route('add-spouse-to-family', ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'famtag' => 'WIFE'])) ?>"> 8317dd427eSGreg Roach <?= I18N::translate('Add a wife') ?> 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(''); 948d0ebef0SGreg Roach foreach ($family->facts(array_merge(Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS), true) as $fact) { 95dd6b2bfcSGreg Roach $found |= !$fact->isPendingDeletion(); 96dd6b2bfcSGreg Roach if ($fact->isPendingAddition()) { 9717dd427eSGreg Roach $row_class = 'wt-new'; 98dd6b2bfcSGreg Roach } elseif ($fact->isPendingDeletion()) { 9917dd427eSGreg Roach $row_class = 'wt-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> 109392561bbSGreg Roach <?= GedcomTag::getLabelValue($fact->getTag(), $fact->date()->display() . ' — ' . $fact->place()->fullName()) ?> 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*d72b284aSGreg Roach <a href="<?= e(route('add-fact', ['tree' => $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; 1358d0ebef0SGreg Roach foreach ($family->facts(['CHIL'], false, $fam_access_level) as $fact) { 136dc124885SGreg Roach $person = $fact->target(); 137dd6b2bfcSGreg Roach if ($person instanceof Individual) { 13839ca88baSGreg Roach $row_class = 'wt-gender-' . $person->sex(); 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(''); 1488d0ebef0SGreg Roach foreach ($person->facts(Gedcom::BIRTH_EVENTS, 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()) : ?> 16364490ee2SGreg Roach <div class="wt-date-difference collapse small"> 164dd6b2bfcSGreg Roach <?php $days = $next->maximumJulianDay() - $prev->minimumJulianDay(); ?> 165dd6b2bfcSGreg Roach <?php if ($days < 0 || $child_number > 1 && $days > 1 && $days < 240) : ?> 166e39fd5c6SGreg Roach <?= view('icons/warning') ?> 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"> 181516bb6deSGreg Roach <?= view('chart-box', ['individual' => $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"> 192820b62dfSGreg Roach <?php if ($family->children()->count() > 1) : ?> 193*d72b284aSGreg Roach <a href="<?= e(route('reorder-children', ['tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>"> 194e39fd5c6SGreg Roach <?= view('icons/reorder') ?> 195e837ff07SGreg Roach <?= I18N::translate('Re-order children') ?> 196dd6b2bfcSGreg Roach </a> 197dd6b2bfcSGreg Roach <?php endif; ?> 198dd6b2bfcSGreg Roach </th> 199dd6b2bfcSGreg Roach <td> 200*d72b284aSGreg Roach <a href="<?= e(route('add-child-to-family', ['gender' => 'U', 'tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>"> 20122d65e5aSGreg Roach <?php if ($type === 'FAMS') : ?> 202dd6b2bfcSGreg Roach <?= I18N::translate('Add a son or daughter') ?> 203dd6b2bfcSGreg Roach <?php else : ?> 204dd6b2bfcSGreg Roach <?= I18N::translate('Add a brother or sister') ?> 205dd6b2bfcSGreg Roach <?php endif ?> 206dd6b2bfcSGreg Roach </a> 207dd6b2bfcSGreg Roach 208*d72b284aSGreg Roach <a href="<?= e(route('add-child-to-family', ['gender' => 'M', 'tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>" class="icon-sex_m_15x15"></a> 209dd6b2bfcSGreg Roach 210*d72b284aSGreg Roach <a href="<?= e(route('add-child-to-family', ['gender' => 'F', 'tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>" class="icon-sex_f_15x15"></a> 211dd6b2bfcSGreg Roach </td> 212dd6b2bfcSGreg Roach </tr> 213dd6b2bfcSGreg Roach <?php endif ?> 214dd6b2bfcSGreg Roach </tbody> 215dd6b2bfcSGreg Roach</table> 216