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