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