1dd6b2bfcSGreg Roach<?php 2d70512abSGreg Roach 31b860509SRico Sonntagdeclare(strict_types=1); 41b860509SRico Sonntag 5054771e9SGreg Roachuse Fisharebest\Webtrees\Age; 65373aac2SGreg Roachuse Fisharebest\Webtrees\Carbon; 71b860509SRico Sonntaguse Fisharebest\Webtrees\Date; 88fb4e87cSGreg Roachuse Fisharebest\Webtrees\Individual; 96b9cb339SGreg Roachuse Fisharebest\Webtrees\Registry; 10054771e9SGreg Roachuse Fisharebest\Webtrees\Family; 111b860509SRico Sonntaguse Fisharebest\Webtrees\I18N; 12054771e9SGreg Roachuse Fisharebest\Webtrees\Tree; 131b860509SRico Sonntaguse Fisharebest\Webtrees\View; 14054771e9SGreg Roachuse Illuminate\Support\Collection; 151b860509SRico Sonntaguse Ramsey\Uuid\Uuid; 161b860509SRico Sonntag 17dd6b2bfcSGreg Roach$table_id = 'table-fam-' . Uuid::uuid4()->toString(); // lists requires a unique ID in case there are multiple lists per page 181b860509SRico Sonntag 1953432476SGreg Roach$today = new Date(strtoupper(date('d M Y'))); 20b9597e06SGreg Roach$today_jd = Carbon::now()->julianDay(); 215373aac2SGreg Roach$hundred_years_ago = Carbon::now()->subYears(100)->julianDay(); 225373aac2SGreg Roach 23054771e9SGreg Roach/** 24054771e9SGreg Roach * @var Tree $tree 25054771e9SGreg Roach * @var Collection<Family> $families 26054771e9SGreg Roach */ 27054771e9SGreg Roach 28dd6b2bfcSGreg Roach?> 29dd6b2bfcSGreg Roach 30dd6b2bfcSGreg Roach<?php View::push('javascript') ?> 31dd6b2bfcSGreg Roach<script> 3232a5dd8dSGreg Roach$("#<?= e($table_id) ?> > .wt-table-family").dataTable({ 33dd6b2bfcSGreg Roach processing: true, 34dd6b2bfcSGreg Roach retrieve: true, 35dd6b2bfcSGreg Roach columns: [ 36dd6b2bfcSGreg Roach /* Given names */ { type: "text" }, 37dd6b2bfcSGreg Roach /* Surnames */ { type: "text" }, 38dd6b2bfcSGreg Roach /* Age */ { type: "num" }, 39dd6b2bfcSGreg Roach /* Given names */ { type: "text" }, 40dd6b2bfcSGreg Roach /* Surnames */ { type: "text" }, 41dd6b2bfcSGreg Roach /* Age */ { type: "num" }, 42dd6b2bfcSGreg Roach /* Marriage date */ { type: "num" }, 43dd6b2bfcSGreg Roach /* Anniversary */ { type: "num" }, 44dd6b2bfcSGreg Roach /* Marriage place */ { type: "text" }, 45dd6b2bfcSGreg Roach /* Children */ { type: "num" }, 46dd6b2bfcSGreg Roach /* Last change */ { visible: <?= json_encode((bool) $tree->getPreference('SHOW_LAST_CHANGE')) ?> }, 47dd6b2bfcSGreg Roach /* Filter marriage */ { sortable: false }, 48dd6b2bfcSGreg Roach /* Filter alive/dead */ { sortable: false }, 49dd6b2bfcSGreg Roach /* Filter tree */ { sortable: false } 50dd6b2bfcSGreg Roach ], 511b860509SRico Sonntag sorting: [ 521b860509SRico Sonntag [1, "asc"] 53b6c326d8SGreg Roach ] 541b860509SRico Sonntag}); 551b860509SRico Sonntag 561b860509SRico Sonntag$("#<?= e($table_id) ?>") 57dd6b2bfcSGreg Roach /* Hide/show parents */ 584843b94fSGreg Roach .on("click", "#btn-toggle-parents", function() { 595e6816beSGreg Roach $(".wt-individual-list-parents").slideToggle(); 60dd6b2bfcSGreg Roach }) 61dd6b2bfcSGreg Roach /* Hide/show statistics */ 624843b94fSGreg Roach .on("click", "#btn-toggle-statistics", function() { 631b860509SRico Sonntag $("#family-charts-<?= e($table_id) ?>").slideToggle({ 641b860509SRico Sonntag complete: function () { 651b860509SRico Sonntag // Trigger resize to redraw the chart 661b860509SRico Sonntag $('div[id^="google-chart-"]').resize(); 671b860509SRico Sonntag } 681b860509SRico Sonntag }); 69dd6b2bfcSGreg Roach }) 70dd6b2bfcSGreg Roach /* Filter buttons in table header */ 71604bfd4bSGreg Roach .on("click", "input[data-filter-column]", function() { 72604bfd4bSGreg Roach let checkbox = $(this); 731b860509SRico Sonntag 74604bfd4bSGreg Roach // Deselect other options 75*3a976702SJonathan Jaubart let siblings = checkbox.siblings("input[type='checkbox']"); 76*3a976702SJonathan Jaubart siblings.prop("checked", false).removeAttr("checked"); 77604bfd4bSGreg Roach 78604bfd4bSGreg Roach // Apply (or clear) this filter 79604bfd4bSGreg Roach let checked = checkbox.prop("checked"); 80604bfd4bSGreg Roach let filter = checked ? checkbox.data("filter-value") : ""; 8132a5dd8dSGreg Roach let column = $("#<?= e($table_id) ?> .wt-table-family").DataTable().column(checkbox.data("filter-column")); 82604bfd4bSGreg Roach column.search(filter).draw(); 83604bfd4bSGreg Roach }); 84dd6b2bfcSGreg Roach</script> 85dd6b2bfcSGreg Roach<?php View::endpush() ?> 86dd6b2bfcSGreg Roach 87dd6b2bfcSGreg Roach<?php 88dd6b2bfcSGreg Roach$max_age = (int) $tree->getPreference('MAX_ALIVE_AGE'); 89dd6b2bfcSGreg Roach 90dd6b2bfcSGreg Roach// init chart data 91dd6b2bfcSGreg Roach$marr_by_age = []; 92dd6b2bfcSGreg Roachfor ($age = 0; $age <= $max_age; $age++) { 931b860509SRico Sonntag $marr_by_age[$age]['M'] = 0; 941b860509SRico Sonntag $marr_by_age[$age]['F'] = 0; 951b860509SRico Sonntag $marr_by_age[$age]['U'] = 0; 96dd6b2bfcSGreg Roach} 97dd6b2bfcSGreg Roach$birt_by_decade = []; 98dd6b2bfcSGreg Roach$marr_by_decade = []; 991b860509SRico Sonntagfor ($year = 1400; $year < 2050; $year += 10) { 1001b860509SRico Sonntag $birt_by_decade[$year]['M'] = 0; 1011b860509SRico Sonntag $birt_by_decade[$year]['F'] = 0; 1021b860509SRico Sonntag $birt_by_decade[$year]['U'] = 0; 1031b860509SRico Sonntag $marr_by_decade[$year]['M'] = 0; 1041b860509SRico Sonntag $marr_by_decade[$year]['F'] = 0; 1051b860509SRico Sonntag $marr_by_decade[$year]['U'] = 0; 106dd6b2bfcSGreg Roach} 1071b860509SRico Sonntag 1081b860509SRico Sonntag$birthData = [ 1091b860509SRico Sonntag [ 1101b860509SRico Sonntag [ 1111b860509SRico Sonntag 'label' => I18N::translate('Century'), 1121b860509SRico Sonntag 'type' => 'date', 1131b860509SRico Sonntag ], [ 1141b860509SRico Sonntag 'label' => I18N::translate('Males'), 1151b860509SRico Sonntag 'type' => 'number', 1161b860509SRico Sonntag ], [ 1171b860509SRico Sonntag 'label' => I18N::translate('Females'), 1181b860509SRico Sonntag 'type' => 'number', 1191b860509SRico Sonntag ], 1201b860509SRico Sonntag ] 1211b860509SRico Sonntag]; 1221b860509SRico Sonntag 1231b860509SRico Sonntag$marriageData = [ 1241b860509SRico Sonntag [ 1251b860509SRico Sonntag [ 1261b860509SRico Sonntag 'label' => I18N::translate('Century'), 1271b860509SRico Sonntag 'type' => 'date', 1281b860509SRico Sonntag ], [ 1291b860509SRico Sonntag 'label' => I18N::translate('Males'), 1301b860509SRico Sonntag 'type' => 'number', 1311b860509SRico Sonntag ], [ 1321b860509SRico Sonntag 'label' => I18N::translate('Females'), 1331b860509SRico Sonntag 'type' => 'number', 1341b860509SRico Sonntag ], 1351b860509SRico Sonntag ] 1361b860509SRico Sonntag]; 1371b860509SRico Sonntag 1381b860509SRico Sonntag$marriageAgeData = [ 1391b860509SRico Sonntag [ 1401b860509SRico Sonntag I18N::translate('Age'), 1411b860509SRico Sonntag I18N::translate('Males'), 1421b860509SRico Sonntag I18N::translate('Females'), 1431b860509SRico Sonntag I18N::translate('Average age'), 1441b860509SRico Sonntag ] 1451b860509SRico Sonntag]; 1461b860509SRico Sonntag 147dd6b2bfcSGreg Roach?> 148dd6b2bfcSGreg Roach 14932a5dd8dSGreg Roach<div id="<?= e($table_id) ?>"> 15032a5dd8dSGreg Roach <table class="table table-bordered table-sm wt-table-family" 151b6c326d8SGreg Roach <?= view('lists/datatables-attributes') ?> 152b6c326d8SGreg Roach > 153dd6b2bfcSGreg Roach <thead> 154dd6b2bfcSGreg Roach <tr> 155dd6b2bfcSGreg Roach <th colspan="14"> 156dd6b2bfcSGreg Roach <div class="btn-toolbar d-flex justify-content-between mb-2"> 157*3a976702SJonathan Jaubart <div class="btn-group btn-group-sm" role="group"> 158*3a976702SJonathan Jaubart <input id="<?= e($table_id) ?>-bg-dead-N" class="btn-check" type="checkbox" data-filter-column="12" data-filter-value="N" autocomplete="off"> 159*3a976702SJonathan Jaubart <label for="<?= e($table_id) ?>-bg-dead-N" class="btn btn-outline-secondary btn-sm" title="' . I18N::translate('Show individuals who are alive or couples where both partners are alive.') ?>"> 160dd6b2bfcSGreg Roach <?= I18N::translate('Both alive') ?> 161604bfd4bSGreg Roach </label> 162*3a976702SJonathan Jaubart 163*3a976702SJonathan Jaubart <input id="<?= e($table_id) ?>-bg-dead-W" class="btn-check" type="checkbox" data-filter-column="12" data-filter-value="W" autocomplete="off"> 164*3a976702SJonathan Jaubart <label for="<?= e($table_id) ?>-bg-dead-W" class="btn btn-outline-secondary" title="<?= I18N::translate('Show couples where only the female partner is dead.') ?>"> 165dd6b2bfcSGreg Roach <?= I18N::translate('Widower') ?> 166604bfd4bSGreg Roach </label> 167*3a976702SJonathan Jaubart 168*3a976702SJonathan Jaubart <input id="<?= e($table_id) ?>-bg-dead-H" class="btn-check" type="checkbox" data-filter-column="12" data-filter-value="H" autocomplete="off"> 169*3a976702SJonathan Jaubart <label for="<?= e($table_id) ?>-bg-dead-H" class="btn btn-outline-secondary" title="<?= I18N::translate('Show couples where only the male partner is dead.') ?>"> 170dd6b2bfcSGreg Roach <?= I18N::translate('Widow') ?> 171604bfd4bSGreg Roach </label> 172*3a976702SJonathan Jaubart 173*3a976702SJonathan Jaubart <input id="<?= e($table_id) ?>-bg-dead-Y" class="btn-check" type="checkbox" data-filter-column="12" data-filter-value="Y" autocomplete="off"> 174*3a976702SJonathan Jaubart <label for="<?= e($table_id) ?>-bg-dead-Y" class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals who are dead or couples where both partners are dead.') ?>"> 175dd6b2bfcSGreg Roach <?= I18N::translate('Both dead') ?> 176604bfd4bSGreg Roach </label> 177dd6b2bfcSGreg Roach </div> 178604bfd4bSGreg Roach 179*3a976702SJonathan Jaubart <div class="btn-group btn-group-sm" role="group"> 180*3a976702SJonathan Jaubart <input id="<?= e($table_id) ?>-bg-roots-R" class="btn-check" type="checkbox" data-filter-column="13" data-filter-value="R" autocomplete="off"> 181*3a976702SJonathan Jaubart <label for="<?= e($table_id) ?>-bg-roots-R" class="btn btn-outline-secondary" title="<?= I18N::translate('Show “roots” couples or individuals. These individuals may also be called “patriarchs”. They are individuals who have no parents recorded in the database.') ?>"> 182dd6b2bfcSGreg Roach <?= I18N::translate('Roots') ?> 183604bfd4bSGreg Roach </label> 184*3a976702SJonathan Jaubart 185*3a976702SJonathan Jaubart <input id="<?= e($table_id) ?>-bg-roots-L" class="btn-check" type="checkbox" data-filter-column="13" data-filter-value="L" autocomplete="off"> 186*3a976702SJonathan Jaubart <label for="<?= e($table_id) ?>-bg-roots-L" class="btn btn-outline-secondary" title="<?= I18N::translate('Show “leaves” couples or individuals. These are individuals who are alive but have no children recorded in the database.') ?>"> 187dd6b2bfcSGreg Roach <?= I18N::translate('Leaves') ?> 188604bfd4bSGreg Roach </label> 189dd6b2bfcSGreg Roach </div> 190604bfd4bSGreg Roach 191*3a976702SJonathan Jaubart <div class="btn-group btn-group-sm" role="group"> 192*3a976702SJonathan Jaubart <input id="<?= e($table_id) ?>-bg-marr-U" class="btn-check" type="checkbox" data-filter-column="11" data-filter-value="U" autocomplete="off"> 193*3a976702SJonathan Jaubart <label for="<?= e($table_id) ?>-bg-marr-U" class="btn btn-outline-secondary" title="<?= I18N::translate('Show couples with an unknown marriage date.') ?>"> 194b9597e06SGreg Roach <?= I18N::translate('Not married') ?> 195604bfd4bSGreg Roach </label> 196*3a976702SJonathan Jaubart 197*3a976702SJonathan Jaubart <input id="<?= e($table_id) ?>-bg-marr-YES" class="btn-check" type="checkbox" data-filter-column="11" data-filter-value="YES" autocomplete="off"> 198*3a976702SJonathan Jaubart <label for="<?= e($table_id) ?>-bg-marr-YES" class="btn btn-outline-secondary" title="<?= I18N::translate('Show couples who married more than 100 years ago.') ?>"> 199dd6b2bfcSGreg Roach <?= I18N::translate('Marriage') ?>>100 200604bfd4bSGreg Roach </label> 201*3a976702SJonathan Jaubart 202*3a976702SJonathan Jaubart <input id="<?= e($table_id) ?>-bg-marr-Y100" class="btn-check" type="checkbox" data-filter-column="11" data-filter-value="Y100" autocomplete="off"> 203*3a976702SJonathan Jaubart <label for="<?= e($table_id) ?>-bg-marr-Y100" class="btn btn-outline-secondary" title="<?= I18N::translate('Show couples who married within the last 100 years.') ?>"> 204dd6b2bfcSGreg Roach <?= I18N::translate('Marriage') ?><=100 205604bfd4bSGreg Roach </label> 206*3a976702SJonathan Jaubart 207*3a976702SJonathan Jaubart <input id="<?= e($table_id) ?>-bg-marr-D" class="btn-check" type="checkbox" data-filter-column="11" data-filter-value="D" autocomplete="off"> 208*3a976702SJonathan Jaubart <label for="<?= e($table_id) ?>-bg-marr-D" class="btn btn-outline-secondary" title="<?= I18N::translate('Show divorced couples.') ?>"> 209dd6b2bfcSGreg Roach <?= I18N::translate('Divorce') ?> 210604bfd4bSGreg Roach </label> 211*3a976702SJonathan Jaubart 212*3a976702SJonathan Jaubart <input id="<?= e($table_id) ?>-bg-marr-M" class="btn-check" type="checkbox" data-filter-column="11" data-filter-value="M" autocomplete="off"> 213*3a976702SJonathan Jaubart <label for="<?= e($table_id) ?>-bg-marr-M" class="btn btn-outline-secondary" title="<?= I18N::translate('Show couples where either partner married more than once.') ?>"> 214dd6b2bfcSGreg Roach <?= I18N::translate('Multiple marriages') ?> 215604bfd4bSGreg Roach </label> 216dd6b2bfcSGreg Roach </div> 217dd6b2bfcSGreg Roach </div> 218dd6b2bfcSGreg Roach </th> 219dd6b2bfcSGreg Roach </tr> 220dd6b2bfcSGreg Roach <tr> 221dd6b2bfcSGreg Roach <th><?= I18N::translate('Given names') ?></th> 222dd6b2bfcSGreg Roach <th><?= I18N::translate('Surname') ?></th> 223dd6b2bfcSGreg Roach <th><?= I18N::translate('Age') ?></th> 224dd6b2bfcSGreg Roach <th><?= I18N::translate('Given names') ?></th> 225dd6b2bfcSGreg Roach <th><?= I18N::translate('Surname') ?></th> 226dd6b2bfcSGreg Roach <th><?= I18N::translate('Age') ?></th> 227dd6b2bfcSGreg Roach <th><?= I18N::translate('Marriage') ?></th> 228e39fd5c6SGreg Roach <th> 229e39fd5c6SGreg Roach <span title="<?= I18N::translate('Anniversary') ?>"> 230e39fd5c6SGreg Roach <?= view('icons/anniversary') ?> 231e39fd5c6SGreg Roach </span> 232e39fd5c6SGreg Roach </th> 233dd6b2bfcSGreg Roach <th><?= I18N::translate('Place') ?></th> 234dd6b2bfcSGreg Roach <th><i class="icon-children" title="<?= I18N::translate('Children') ?>"></i></th> 235dd6b2bfcSGreg Roach <th><?= I18N::translate('Last change') ?></th> 236dd6b2bfcSGreg Roach <th hidden></th> 237dd6b2bfcSGreg Roach <th hidden></th> 238dd6b2bfcSGreg Roach <th hidden></th> 239dd6b2bfcSGreg Roach </tr> 240dd6b2bfcSGreg Roach </thead> 241dd6b2bfcSGreg Roach 242dd6b2bfcSGreg Roach <tbody> 243dd6b2bfcSGreg Roach <?php foreach ($families as $family) : ?> 2446b9cb339SGreg Roach <?php $husb = $family->husband() ?? Registry::individualFactory()->new('H', '0 @H@ INDI', null, $family->tree()) ?> 2456b9cb339SGreg Roach <?php $wife = $family->wife() ?? Registry::individualFactory()->new('W', '0 @W@ INDI', null, $family->tree()) ?> 246dd6b2bfcSGreg Roach 247b16bf9d4SGreg Roach <tr class="<?= $family->isPendingAddition() ? 'wt-new' : '' ?> <?= $family->isPendingDeletion() ? 'wt-old' : '' ?>"> 248dd6b2bfcSGreg Roach <!-- Husband name --> 2498fb4e87cSGreg Roach <td colspan="2" data-sort="<?= e(str_replace([',', Individual::PRAENOMEN_NESCIO, Individual::NOMEN_NESCIO], 'AAAA', implode(',', array_reverse(explode(',', $husb->sortName()))))) ?>"> 250dd6b2bfcSGreg Roach <?php foreach ($husb->getAllNames() as $num => $name) : ?> 25122d65e5aSGreg Roach <?php if ($name['type'] !== '_MARNM' || $num == $husb->getPrimaryName()) : ?> 2528d25f0dbSGreg Roach <a title="<?= $name['type'] === '_MARNM' ? I18N::translate('Married name') : '' ?>" href="<?= e($family->url()) ?>" class="<?= $num === $husb->getPrimaryName() ? 'name2' : '' ?>"> 253dd6b2bfcSGreg Roach <?= $name['full'] ?> 254dd6b2bfcSGreg Roach </a> 255dd6b2bfcSGreg Roach <?php if ($num === $husb->getPrimaryName()) : ?> 25608362db4SGreg Roach <small><?= view('icons/sex', ['sex' => $husb->sex()]) ?></small> 257dd6b2bfcSGreg Roach <?php endif ?> 258dd6b2bfcSGreg Roach <br> 259dd6b2bfcSGreg Roach <?php endif ?> 260dd6b2bfcSGreg Roach <?php endforeach ?> 2615e6816beSGreg Roach <?= view('lists/individual-table-parents', ['individual' => $husb]) ?> 262dd6b2bfcSGreg Roach </td> 263dd6b2bfcSGreg Roach 2648fb4e87cSGreg Roach <td hidden data-sort="<?= e(str_replace([',', Individual::PRAENOMEN_NESCIO, Individual::NOMEN_NESCIO], 'AAAA', $husb->sortName())) ?>"></td> 265dd6b2bfcSGreg Roach 266dd6b2bfcSGreg Roach <!-- Husband age --> 267dd6b2bfcSGreg Roach <?php 26853432476SGreg Roach $age = new Age($husb->getBirthDate(), $family->getMarriageDate()); 26953432476SGreg Roach $year = $wife->getBirthDate()->gregorianYear(); 270054771e9SGreg Roach 27153432476SGreg Roach if ($year >= 1550 && $year < 2030) { 27253432476SGreg Roach ++$birt_by_decade[(int) ($year / 10) * 10][$husb->sex()]; 273dd6b2bfcSGreg Roach } 274054771e9SGreg Roach 27553432476SGreg Roach if ($age->ageYears() >= 0 && $age->ageYears() <= $max_age) { 27653432476SGreg Roach ++$marr_by_age[$age->ageYears()][$husb->sex()]; 277dd6b2bfcSGreg Roach } 278dd6b2bfcSGreg Roach ?> 27953432476SGreg Roach <td class="text-center" data-sort="<?= $age->ageDays() ?>"> 28053432476SGreg Roach <?= $age->ageYearsString() ?> 281dd6b2bfcSGreg Roach </td> 282dd6b2bfcSGreg Roach 283dd6b2bfcSGreg Roach <!-- Wife name --> 2848fb4e87cSGreg Roach <td colspan="2" data-sort="<?= e(str_replace([',', Individual::PRAENOMEN_NESCIO, Individual::NOMEN_NESCIO], 'AAAA', implode(',', array_reverse(explode(',', $wife->sortName()))))) ?>"> 285dd6b2bfcSGreg Roach <?php foreach ($wife->getAllNames() as $num => $name) : ?> 28622d65e5aSGreg Roach <?php if ($name['type'] !== '_MARNM' || $num == $wife->getPrimaryName()) : ?> 2878d25f0dbSGreg Roach <a title="<?= $name['type'] === '_MARNM' ? I18N::translate('Married name') : '' ?>" href="<?= e($family->url()) ?>" class="<?= $num === $wife->getPrimaryName() ? 'name2' : '' ?>"> 288dd6b2bfcSGreg Roach <?= $name['full'] ?> 289dd6b2bfcSGreg Roach </a> 290dd6b2bfcSGreg Roach <?php if ($num === $wife->getPrimaryName()) : ?> 29108362db4SGreg Roach <small><?= view('icons/sex', ['sex' => $wife->sex()]) ?></small> 292dd6b2bfcSGreg Roach <?php endif ?> 293dd6b2bfcSGreg Roach <br> 294dd6b2bfcSGreg Roach <?php endif ?> 295dd6b2bfcSGreg Roach <?php endforeach ?> 2965e6816beSGreg Roach <?= view('lists/individual-table-parents', ['individual' => $wife]) ?> 297dd6b2bfcSGreg Roach </td> 298dd6b2bfcSGreg Roach 2998fb4e87cSGreg Roach <td hidden data-sort="<?= e(str_replace([',', Individual::PRAENOMEN_NESCIO, Individual::NOMEN_NESCIO], 'AAAA', $wife->sortName())) ?>"></td> 300dd6b2bfcSGreg Roach 301dd6b2bfcSGreg Roach <!-- Wife age --> 302dd6b2bfcSGreg Roach <?php 30353432476SGreg Roach $age = new Age($wife->getBirthDate(), $family->getMarriageDate()); 30453432476SGreg Roach $year = $wife->getBirthDate()->gregorianYear(); 305054771e9SGreg Roach 30653432476SGreg Roach if ($year >= 1550 && $year < 2030) { 30753432476SGreg Roach ++$birt_by_decade[(int) ($year / 10) * 10][$wife->sex()]; 308dd6b2bfcSGreg Roach } 309054771e9SGreg Roach 31053432476SGreg Roach if ($age->ageYears() >= 0 && $age->ageYears() <= $max_age) { 31153432476SGreg Roach ++$marr_by_age[$age->ageYears()][$wife->sex()]; 312dd6b2bfcSGreg Roach } 313dd6b2bfcSGreg Roach ?> 31453432476SGreg Roach <td class="text-center" data-sort="<?= $age->ageDays() ?>"> 31553432476SGreg Roach <?= $age->ageYearsString() ?> 316dd6b2bfcSGreg Roach </td> 317dd6b2bfcSGreg Roach 318dd6b2bfcSGreg Roach <!-- Marriage date --> 319dd6b2bfcSGreg Roach <td data-sort="<?= $family->getMarriageDate()->julianDay() ?>"> 320dd6b2bfcSGreg Roach <?php if ($marriage_dates = $family->getAllMarriageDates()) : ?> 321dd6b2bfcSGreg Roach <?php foreach ($marriage_dates as $n => $marriage_date) : ?> 322dd6b2bfcSGreg Roach <div><?= $marriage_date->display(true) ?></div> 323dd6b2bfcSGreg Roach <?php endforeach ?> 324dd6b2bfcSGreg Roach <?php if ($marriage_dates[0]->gregorianYear() >= 1550 && $marriage_dates[0]->gregorianYear() < 2030) : ?> 3251b860509SRico Sonntag <?php 3261b860509SRico Sonntag ++$marr_by_decade[(int) ($marriage_dates[0]->gregorianYear() / 10) * 10][$husb->sex()]; 3271b860509SRico Sonntag ++$marr_by_decade[(int) ($marriage_dates[0]->gregorianYear() / 10) * 10][$wife->sex()]; 3281b860509SRico Sonntag ?> 329dd6b2bfcSGreg Roach <?php endif ?> 33039ca88baSGreg Roach <?php elseif ($family->facts(['_NMR'])->isNotEmpty()) : ?> 331dd6b2bfcSGreg Roach <?= I18N::translate('no') ?> 33239ca88baSGreg Roach <?php elseif ($family->facts(['MARR'])->isNotEmpty()) : ?> 333dd6b2bfcSGreg Roach <?= I18N::translate('yes') ?> 334dd6b2bfcSGreg Roach <?php endif ?> 335dd6b2bfcSGreg Roach </td> 336dd6b2bfcSGreg Roach 337dd6b2bfcSGreg Roach <!-- Marriage anniversary --> 33853432476SGreg Roach <?php $age = new Age($family->getMarriageDate(), $today) ?> 33953432476SGreg Roach <td class="text-center" data-sort="<?= $age->ageDays() ?>"> 34053432476SGreg Roach <?= $age->ageYearsString() ?> 341dd6b2bfcSGreg Roach </td> 342dd6b2bfcSGreg Roach 343dd6b2bfcSGreg Roach <!-- Marriage place --> 3448c0ff4ddSGreg Roach <td data-sort="<?= e($family->getMarriagePlace()->gedcomName()) ?>"> 345dd6b2bfcSGreg Roach <?php foreach ($family->getAllMarriagePlaces() as $n => $marriage_place) : ?> 346392561bbSGreg Roach <?= $marriage_place->shortName(true) ?> 347dd6b2bfcSGreg Roach <br> 348dd6b2bfcSGreg Roach <?php endforeach ?> 349dd6b2bfcSGreg Roach </td> 350dd6b2bfcSGreg Roach 351dd6b2bfcSGreg Roach <!-- Number of children --> 35239ca88baSGreg Roach <td class="text-center" data-sort="<?= $family->numberOfChildren() ?>"> 35339ca88baSGreg Roach <?= I18N::number($family->numberOfChildren()) ?> 354dd6b2bfcSGreg Roach </td> 355dd6b2bfcSGreg Roach 356dd6b2bfcSGreg Roach <!-- Last change --> 3574459dc9aSGreg Roach <td data-sort="<?= $family->lastChangeTimestamp()->unix() ?>"> 3584459dc9aSGreg Roach <?= view('components/datetime', ['timestamp' => $family->lastChangeTimestamp()]) ?> 359dd6b2bfcSGreg Roach </td> 360dd6b2bfcSGreg Roach 361dd6b2bfcSGreg Roach <!-- Filter by marriage date --> 362dd6b2bfcSGreg Roach <td hidden> 36353432476SGreg Roach <?php if ($family->getMarriageDate()->maximumJulianDay() > $hundred_years_ago && $family->getMarriageDate()->maximumJulianDay() <= $today_jd) : ?> 364dd6b2bfcSGreg Roach Y100 365b9597e06SGreg Roach <?php elseif ($family->facts(['MARR'])->isNotEmpty()) : ?> 366dd6b2bfcSGreg Roach YES 367b9597e06SGreg Roach <?php else : ?> 368b9597e06SGreg Roach U 369dd6b2bfcSGreg Roach <?php endif ?> 370b9597e06SGreg Roach <?php if ($family->facts(['DIV'])->isNotEmpty()) : ?> 371dd6b2bfcSGreg Roach D 372dd6b2bfcSGreg Roach <?php endif ?> 37339ca88baSGreg Roach <?php if (count($husb->spouseFamilies()) > 1 || count($wife->spouseFamilies()) > 1) : ?> 374dd6b2bfcSGreg Roach M 375dd6b2bfcSGreg Roach <?php endif ?> 376dd6b2bfcSGreg Roach </td> 377dd6b2bfcSGreg Roach 378dd6b2bfcSGreg Roach <!-- Filter by alive/dead --> 379dd6b2bfcSGreg Roach <td hidden> 380dd6b2bfcSGreg Roach <?php if ($husb->isDead() && $wife->isDead()) : ?> 381dd6b2bfcSGreg Roach Y 382dd6b2bfcSGreg Roach <?php endif ?> 383dd6b2bfcSGreg Roach <?php if ($husb->isDead() && !$wife->isDead()) : ?> 38422d65e5aSGreg Roach <?php if ($wife->sex() === 'F') : ?> 385dd6b2bfcSGreg Roach H 386dd6b2bfcSGreg Roach <?php endif ?> 38722d65e5aSGreg Roach <?php if ($wife->sex() === 'M') : ?> 388dd6b2bfcSGreg Roach W 389dd6b2bfcSGreg Roach <?php endif ?> 390dd6b2bfcSGreg Roach <?php endif ?> 391dd6b2bfcSGreg Roach <?php if (!$husb->isDead() && $wife->isDead()) : ?> 39222d65e5aSGreg Roach <?php if ($husb->sex() === 'M') : ?> 393dd6b2bfcSGreg Roach W 394dd6b2bfcSGreg Roach <?php endif ?> 39522d65e5aSGreg Roach <?php if ($husb->sex() === 'F') : ?> 396dd6b2bfcSGreg Roach H 397dd6b2bfcSGreg Roach <?php endif ?> 398dd6b2bfcSGreg Roach <?php endif ?> 399dd6b2bfcSGreg Roach <?php if (!$husb->isDead() && !$wife->isDead()) : ?> 400dd6b2bfcSGreg Roach N 401dd6b2bfcSGreg Roach <?php endif ?> 402dd6b2bfcSGreg Roach </td> 403dd6b2bfcSGreg Roach 404dd6b2bfcSGreg Roach <!-- Filter by roots/leaves --> 405dd6b2bfcSGreg Roach <td hidden> 4066f04756aSJonathan Jaubart <?php if ($husb->childFamilies()->isEmpty() && $wife->childFamilies()->isEmpty()) : ?> 407dd6b2bfcSGreg Roach R 40839ca88baSGreg Roach <?php elseif (!$husb->isDead() && !$wife->isDead() && $family->numberOfChildren() === 0) : ?> 409dd6b2bfcSGreg Roach L 410dd6b2bfcSGreg Roach <?php endif ?> 411dd6b2bfcSGreg Roach </td> 412dd6b2bfcSGreg Roach </tr> 413dd6b2bfcSGreg Roach <?php endforeach ?> 414dd6b2bfcSGreg Roach </tbody> 4157039fd97SGreg Roach 4167039fd97SGreg Roach <tfoot> 4177039fd97SGreg Roach <tr> 4187039fd97SGreg Roach <th colspan="14"> 419604bfd4bSGreg Roach <div class="btn-group btn-group-sm"> 420315eb316SGreg Roach <button id="btn-toggle-parents" class="btn btn-outline-secondary" data-bs-toggle="button" data-persist="show-parents"> 4217039fd97SGreg Roach <?= I18N::translate('Show parents') ?> 4227039fd97SGreg Roach </button> 423315eb316SGreg Roach <button id="btn-toggle-statistics" class="btn btn-outline-secondary" data-bs-toggle="button" data-persist="show-statistics"> 4247039fd97SGreg Roach <?= I18N::translate('Show statistics charts') ?> 4257039fd97SGreg Roach </button> 4267039fd97SGreg Roach </div> 4277039fd97SGreg Roach </th> 4287039fd97SGreg Roach </tr> 4297039fd97SGreg Roach </tfoot> 430dd6b2bfcSGreg Roach </table> 4311b860509SRico Sonntag</div> 432dd6b2bfcSGreg Roach 4331b860509SRico Sonntag<div id="family-charts-<?= e($table_id) ?>" style="display: none;"> 4341b860509SRico Sonntag <div class="mb-3"> 4351b860509SRico Sonntag <div class="card-deck"> 4361b860509SRico Sonntag <div class="col-lg-12 col-md-12 mb-3"> 4371b860509SRico Sonntag <div class="card m-0"> 4381b860509SRico Sonntag <div class="card-header"> 4391b860509SRico Sonntag <?= I18N::translate('Decade of birth') ?> 4401b860509SRico Sonntag </div><div class="card-body"> 4411b860509SRico Sonntag <?php 4421b860509SRico Sonntag foreach ($birt_by_decade as $century => $values) { 4431b860509SRico Sonntag if (($values['M'] + $values['F']) > 0) { 4441b860509SRico Sonntag $birthData[] = [ 4451b860509SRico Sonntag [ 4461b860509SRico Sonntag 'v' => 'Date(' . $century . ', 0, 1)', 4471b860509SRico Sonntag 'f' => $century, 4481b860509SRico Sonntag ], 4491b860509SRico Sonntag $values['M'], 4501b860509SRico Sonntag $values['F'], 4511b860509SRico Sonntag ]; 4521b860509SRico Sonntag } 4531b860509SRico Sonntag } 4541b860509SRico Sonntag ?> 4551b860509SRico Sonntag <?= view('lists/chart-by-decade', ['data' => $birthData, 'title' => I18N::translate('Decade of birth')]) ?> 4561b860509SRico Sonntag </div> 4571b860509SRico Sonntag </div> 4581b860509SRico Sonntag </div> 4591b860509SRico Sonntag </div> 4601b860509SRico Sonntag <div class="card-deck"> 4611b860509SRico Sonntag <div class="col-lg-12 col-md-12 mb-3"> 4621b860509SRico Sonntag <div class="card m-0"> 4631b860509SRico Sonntag <div class="card-header"> 4641b860509SRico Sonntag <?= I18N::translate('Decade of marriage') ?> 4651b860509SRico Sonntag </div><div class="card-body"> 4661b860509SRico Sonntag <?php 4671b860509SRico Sonntag foreach ($marr_by_decade as $century => $values) { 4681b860509SRico Sonntag if (($values['M'] + $values['F']) > 0) { 4691b860509SRico Sonntag $marriageData[] = [ 4701b860509SRico Sonntag [ 4711b860509SRico Sonntag 'v' => 'Date(' . $century . ', 0, 1)', 4721b860509SRico Sonntag 'f' => $century, 4731b860509SRico Sonntag ], 4741b860509SRico Sonntag $values['M'], 4751b860509SRico Sonntag $values['F'], 4761b860509SRico Sonntag ]; 4771b860509SRico Sonntag } 4781b860509SRico Sonntag } 4791b860509SRico Sonntag ?> 4801b860509SRico Sonntag <?= view('lists/chart-by-decade', ['data' => $marriageData, 'title' => I18N::translate('Decade of marriage')]) ?> 4811b860509SRico Sonntag </div> 4821b860509SRico Sonntag </div> 4831b860509SRico Sonntag </div> 4841b860509SRico Sonntag </div> 4851b860509SRico Sonntag <div class="card-deck"> 4861b860509SRico Sonntag <div class="col-lg-12 col-md-12 mb-3"> 4871b860509SRico Sonntag <div class="card m-0"> 4881b860509SRico Sonntag <div class="card-header"> 4891b860509SRico Sonntag <?= I18N::translate('Age in year of marriage') ?> 4901b860509SRico Sonntag </div> 4911b860509SRico Sonntag <div class="card-body"> 4921b860509SRico Sonntag <?php 4931b860509SRico Sonntag $totalAge = 0; 4941b860509SRico Sonntag $totalSum = 0; 4951b860509SRico Sonntag $max = 0; 4961b860509SRico Sonntag 4971b860509SRico Sonntag foreach ($marr_by_age as $age => $values) { 4981b860509SRico Sonntag if (($values['M'] + $values['F']) > 0) { 4991b860509SRico Sonntag if (($values['M'] + $values['F']) > $max) { 5001b860509SRico Sonntag $max = $values['M'] + $values['F']; 5011b860509SRico Sonntag } 5021b860509SRico Sonntag 5031b860509SRico Sonntag $totalAge += $age * ($values['M'] + $values['F']); 5041b860509SRico Sonntag $totalSum += $values['M'] + $values['F']; 5051b860509SRico Sonntag 5061b860509SRico Sonntag $marriageAgeData[] = [ 5071b860509SRico Sonntag $age, 5081b860509SRico Sonntag $values['M'], 5091b860509SRico Sonntag $values['F'], 5101b860509SRico Sonntag null, 5111b860509SRico Sonntag ]; 5121b860509SRico Sonntag } 5131b860509SRico Sonntag } 5141b860509SRico Sonntag 5151b860509SRico Sonntag if ($totalSum > 0) { 5161b860509SRico Sonntag $marriageAgeData[] = [ 5171b860509SRico Sonntag round($totalAge / $totalSum, 1), 5181b860509SRico Sonntag null, 5191b860509SRico Sonntag null, 5201b860509SRico Sonntag 0, 5211b860509SRico Sonntag ]; 5221b860509SRico Sonntag 5231b860509SRico Sonntag $marriageAgeData[] = [ 5241b860509SRico Sonntag round($totalAge / $totalSum, 1), 5251b860509SRico Sonntag null, 5261b860509SRico Sonntag null, 5271b860509SRico Sonntag $max, 5281b860509SRico Sonntag ]; 5291b860509SRico Sonntag } 5301b860509SRico Sonntag ?> 5311b860509SRico Sonntag <?= view('lists/chart-by-age', ['data' => $marriageAgeData, 'title' => I18N::translate('Age in year of marriage')]) ?> 5321b860509SRico Sonntag </div> 5331b860509SRico Sonntag </div> 5341b860509SRico Sonntag </div> 5351b860509SRico Sonntag </div> 536dd6b2bfcSGreg Roach </div> 537dd6b2bfcSGreg Roach</div> 538