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