1<?php 2 3use Fisharebest\Webtrees\Date; 4use Fisharebest\Webtrees\Family; 5use Fisharebest\Webtrees\Functions\Functions; 6use Fisharebest\Webtrees\Gedcom; 7use Fisharebest\Webtrees\GedcomTag; 8use Fisharebest\Webtrees\Http\RequestHandlers\AddChildToFamilyPage; 9use Fisharebest\Webtrees\Http\RequestHandlers\AddNewFact; 10use Fisharebest\Webtrees\Http\RequestHandlers\AddSpouseToFamilyPage; 11use Fisharebest\Webtrees\Http\RequestHandlers\ReorderChildrenPage; 12use Fisharebest\Webtrees\I18N; 13use Fisharebest\Webtrees\Individual; 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 <?= Functions::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(), 'famtag' => 'HUSB'])) ?>"> 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 <?= Functions::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(), 'famtag' => 'WIFE'])) ?>"> 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 <?= GedcomTag::getLabelValue($fact->getTag(), $fact->date()->display() . ' — ' . $fact->place()->fullName()) ?> 129 </td> 130 </tr> 131 132 <?php 133 if (!$prev->isOK() && $fact->date()->isOK()) { 134 $prev = $fact->date(); 135 } 136 } 137 138 if (!$found && $family->canShow() && $family->canEdit()) { 139 ?> 140 <tr> 141 <th scope="row"> 142 <span class="sr-only"><?= I18N::translate('Marriage') ?></span> 143 </th> 144 145 <td> 146 <a href="<?= e(route(AddNewFact::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'fact' => 'MARR'])) ?>"> 147 <?= I18N::translate('Add marriage details') ?> 148 </a> 149 </td> 150 </tr> 151 <?php 152 } 153 154 ///// CHIL ///// 155 $child_number = 0; 156 foreach ($family->facts(['CHIL'], false, $fam_access_level) as $fact) { 157 $person = $fact->target(); 158 if ($person instanceof Individual) { 159 $row_class = 'wt-gender-' . $person->sex(); 160 if ($fact->isPendingAddition()) { 161 $child_number++; 162 $row_class .= ' new'; 163 } elseif ($fact->isPendingDeletion()) { 164 $row_class .= ' old'; 165 } else { 166 $child_number++; 167 } 168 $next = new Date(''); 169 foreach ($person->facts(Gedcom::BIRTH_EVENTS, true) as $bfact) { 170 if ($bfact->date()->isOK()) { 171 $next = $bfact->date(); 172 break; 173 } 174 } 175 ?> 176 177 <tr class="<?= $row_class ?>"> 178 <th scope="row"> 179 <?php if ($individual === $person) : ?> 180 <i class="icon-selected"></i> 181 <?php endif ?> 182 183 <?php if ($prev->isOK() && $next->isOK()) : ?> 184 <div class="wt-date-difference collapse small"> 185 <?php $days = $next->maximumJulianDay() - $prev->minimumJulianDay(); ?> 186 <?php if ($days < 0 || $child_number > 1 && $days > 1 && $days < 240) : ?> 187 <?= view('icons/warning') ?> 188 <?php endif ?> 189 190 <?php $months = intdiv($days + 15 , 30); ?> 191 <?php if (abs($months) === 12 || abs($months) >= 24) : ?> 192 <?= I18N::plural('%s year', '%s years', round($months / 12), I18N::number(round($months / 12))) ?> 193 <?php elseif ($months !== 0) : ?> 194 <?= I18N::plural('%s month', '%s months', $months, I18N::number($months)) ?> 195 <?php endif ?> 196 </div> 197 <?php endif ?> 198 199 <?= Functions::getCloseRelationshipName($individual, $person) ?> 200 </th> 201 <td class="border-0 p-0"> 202 <?= view('chart-box', ['individual' => $person]) ?> 203 </td> 204 </tr> 205 <?php 206 $prev = $next; 207 } 208 } ?> 209 210 <?php if ($family->canEdit()) : ?> 211 <tr> 212 <th scope="row"> 213 <span class="sr-only"><?= I18N::translate('Children') ?></span> 214 </th> 215 216 <td> 217 <a href="<?= e(route(AddChildToFamilyPage::class, ['gender' => 'M', 'tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>"> 218 <?= $type === 'FAMS' ? I18N::translate('Add a son') : I18N::translate('Add a brother') ?> 219 </a> 220 | 221 <a href="<?= e(route(AddChildToFamilyPage::class, ['gender' => 'F', 'tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>"> 222 <?= $type === 'FAMS' ? I18N::translate('Add a daughter') : I18N::translate('Add a sister') ?> 223 </a> 224 | 225 <a href="<?= e(route(AddChildToFamilyPage::class, ['gender' => 'U', 'tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>"> 226 <?= $type === 'FAMS' ? I18N::translate('Add a child') : I18N::translate('Add a sibling') ?> 227 </a> 228 229 <?php if ($family->children()->count() > 1) : ?> 230 <br> 231 <a href="<?= e(route(ReorderChildrenPage::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>"> 232 <?= I18N::translate('Re-order children') ?> 233 </a> 234 <?php endif; ?> 235 </td> 236 </tr> 237 <?php endif ?> 238 </tbody> 239</table> 240