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