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