1dd6b2bfcSGreg Roach<?php 21b860509SRico Sonntagdeclare(strict_types=1); 31b860509SRico Sonntag 41b860509SRico Sonntaguse Fisharebest\Webtrees\Date; 51b860509SRico Sonntaguse Fisharebest\Webtrees\Gedcom; 61b860509SRico Sonntaguse Fisharebest\Webtrees\GedcomTag; 71b860509SRico Sonntaguse Fisharebest\Webtrees\I18N; 81b860509SRico Sonntaguse Fisharebest\Webtrees\Individual; 91b860509SRico Sonntaguse Fisharebest\Webtrees\View; 101b860509SRico Sonntaguse Ramsey\Uuid\Uuid; 111b860509SRico Sonntag 12dd6b2bfcSGreg Roach$table_id = 'table-fam-' . Uuid::uuid4()->toString(); // lists requires a unique ID in case there are multiple lists per page 131b860509SRico Sonntag 141b860509SRico Sonntag$hundred_years_ago = new DateTime(); 151b860509SRico Sonntag$hundred_years_ago->modify('-100 years'); 161b860509SRico Sonntag$hundred_years_ago = new Date($hundred_years_ago->format('Y')); 17dd6b2bfcSGreg Roach?> 18dd6b2bfcSGreg Roach 19dd6b2bfcSGreg Roach<?php View::push('javascript') ?> 20dd6b2bfcSGreg Roach<script> 211b860509SRico Sonntag 22dd6b2bfcSGreg Roach$("#<?= e($table_id) ?>").dataTable({ 23dd6b2bfcSGreg Roach dom: '<"H"<"filtersH_<?= e($table_id) ?>"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_<?= e($table_id) ?>">>', 24dd6b2bfcSGreg Roach autoWidth: false, 25dd6b2bfcSGreg Roach processing: true, 26dd6b2bfcSGreg Roach retrieve: true, 27dd6b2bfcSGreg Roach columns: [ 28dd6b2bfcSGreg Roach /* Given names */ { type: "text" }, 29dd6b2bfcSGreg Roach /* Surnames */ { type: "text" }, 30dd6b2bfcSGreg Roach /* Age */ { type: "num" }, 31dd6b2bfcSGreg Roach /* Given names */ { type: "text" }, 32dd6b2bfcSGreg Roach /* Surnames */ { type: "text" }, 33dd6b2bfcSGreg Roach /* Age */ { type: "num" }, 34dd6b2bfcSGreg Roach /* Marriage date */ { type: "num" }, 35dd6b2bfcSGreg Roach /* Anniversary */ { type: "num" }, 36dd6b2bfcSGreg Roach /* Marriage place */ { type: "text" }, 37dd6b2bfcSGreg Roach /* Children */ { type: "num" }, 38dd6b2bfcSGreg Roach /* Last change */ { visible: <?= json_encode((bool) $tree->getPreference('SHOW_LAST_CHANGE')) ?> }, 39dd6b2bfcSGreg Roach /* Filter marriage */ { sortable: false }, 40dd6b2bfcSGreg Roach /* Filter alive/dead */ { sortable: false }, 41dd6b2bfcSGreg Roach /* Filter tree */ { sortable: false } 42dd6b2bfcSGreg Roach ], 431b860509SRico Sonntag sorting: [ 441b860509SRico Sonntag [1, "asc"] 45b6c326d8SGreg Roach ] 461b860509SRico Sonntag}); 471b860509SRico Sonntag 481b860509SRico Sonntag$("#<?= e($table_id) ?>") 49dd6b2bfcSGreg Roach /* Hide/show parents */ 50dd6b2bfcSGreg Roach .on("click", ".btn-toggle-parents", function() { 51dd6b2bfcSGreg Roach $(this).toggleClass("ui-state-active"); 52dd6b2bfcSGreg Roach $(".parents", $(this).closest("table").DataTable().rows().nodes()).slideToggle(); 53dd6b2bfcSGreg Roach }) 54dd6b2bfcSGreg Roach /* Hide/show statistics */ 55dd6b2bfcSGreg Roach .on("click", ".btn-toggle-statistics", function() { 56dd6b2bfcSGreg Roach $(this).toggleClass("ui-state-active"); 571b860509SRico Sonntag $("#family-charts-<?= e($table_id) ?>").slideToggle({ 581b860509SRico Sonntag complete: function () { 591b860509SRico Sonntag // Trigger resize to redraw the chart 601b860509SRico Sonntag $('div[id^="google-chart-"]').resize(); 611b860509SRico Sonntag } 621b860509SRico Sonntag }); 63dd6b2bfcSGreg Roach }) 64dd6b2bfcSGreg Roach /* Filter buttons in table header */ 65dd6b2bfcSGreg Roach .on("click", "button[data-filter-column]", function() { 66dd6b2bfcSGreg Roach var btn = $(this); 67dd6b2bfcSGreg Roach // De-activate the other buttons in this button group 68dd6b2bfcSGreg Roach btn.siblings().removeClass("active"); 69dd6b2bfcSGreg Roach // Apply (or clear) this filter 70dd6b2bfcSGreg Roach var col = $("#<?= e($table_id) ?>").DataTable().column(btn.data("filter-column")); 71dd6b2bfcSGreg Roach if (btn.hasClass("active")) { 72dd6b2bfcSGreg Roach col.search("").draw(); 73dd6b2bfcSGreg Roach } else { 74dd6b2bfcSGreg Roach col.search(btn.data("filter-value")).draw(); 75dd6b2bfcSGreg Roach } 76dd6b2bfcSGreg Roach }); 771b860509SRico Sonntag 78dd6b2bfcSGreg Roach</script> 79dd6b2bfcSGreg Roach<?php View::endpush() ?> 80dd6b2bfcSGreg Roach 81dd6b2bfcSGreg Roach<?php 82dd6b2bfcSGreg Roach$max_age = (int) $tree->getPreference('MAX_ALIVE_AGE'); 83dd6b2bfcSGreg Roach 84dd6b2bfcSGreg Roach// init chart data 85dd6b2bfcSGreg Roach$marr_by_age = []; 86dd6b2bfcSGreg Roachfor ($age = 0; $age <= $max_age; $age++) { 871b860509SRico Sonntag $marr_by_age[$age]['M'] = 0; 881b860509SRico Sonntag $marr_by_age[$age]['F'] = 0; 891b860509SRico Sonntag $marr_by_age[$age]['U'] = 0; 90dd6b2bfcSGreg Roach} 91dd6b2bfcSGreg Roach$birt_by_decade = []; 92dd6b2bfcSGreg Roach$marr_by_decade = []; 931b860509SRico Sonntagfor ($year = 1400; $year < 2050; $year += 10) { 941b860509SRico Sonntag $birt_by_decade[$year]['M'] = 0; 951b860509SRico Sonntag $birt_by_decade[$year]['F'] = 0; 961b860509SRico Sonntag $birt_by_decade[$year]['U'] = 0; 971b860509SRico Sonntag $marr_by_decade[$year]['M'] = 0; 981b860509SRico Sonntag $marr_by_decade[$year]['F'] = 0; 991b860509SRico Sonntag $marr_by_decade[$year]['U'] = 0; 100dd6b2bfcSGreg Roach} 1011b860509SRico Sonntag 1021b860509SRico Sonntag$birthData = [ 1031b860509SRico Sonntag [ 1041b860509SRico Sonntag [ 1051b860509SRico Sonntag 'label' => I18N::translate('Century'), 1061b860509SRico Sonntag 'type' => 'date', 1071b860509SRico Sonntag ], [ 1081b860509SRico Sonntag 'label' => I18N::translate('Males'), 1091b860509SRico Sonntag 'type' => 'number', 1101b860509SRico Sonntag ], [ 1111b860509SRico Sonntag 'label' => I18N::translate('Females'), 1121b860509SRico Sonntag 'type' => 'number', 1131b860509SRico Sonntag ], 1141b860509SRico Sonntag ] 1151b860509SRico Sonntag]; 1161b860509SRico Sonntag 1171b860509SRico Sonntag$marriageData = [ 1181b860509SRico Sonntag [ 1191b860509SRico Sonntag [ 1201b860509SRico Sonntag 'label' => I18N::translate('Century'), 1211b860509SRico Sonntag 'type' => 'date', 1221b860509SRico Sonntag ], [ 1231b860509SRico Sonntag 'label' => I18N::translate('Males'), 1241b860509SRico Sonntag 'type' => 'number', 1251b860509SRico Sonntag ], [ 1261b860509SRico Sonntag 'label' => I18N::translate('Females'), 1271b860509SRico Sonntag 'type' => 'number', 1281b860509SRico Sonntag ], 1291b860509SRico Sonntag ] 1301b860509SRico Sonntag]; 1311b860509SRico Sonntag 1321b860509SRico Sonntag$marriageAgeData = [ 1331b860509SRico Sonntag [ 1341b860509SRico Sonntag I18N::translate('Age'), 1351b860509SRico Sonntag I18N::translate('Males'), 1361b860509SRico Sonntag I18N::translate('Females'), 1371b860509SRico Sonntag I18N::translate('Average age'), 1381b860509SRico Sonntag ] 1391b860509SRico Sonntag]; 1401b860509SRico Sonntag 141dd6b2bfcSGreg Roach?> 142dd6b2bfcSGreg Roach 143dd6b2bfcSGreg Roach<div class="fam-list"> 144b6c326d8SGreg Roach <table id="<?= e($table_id) ?>" 145b6c326d8SGreg Roach <?= view('lists/datatables-attributes') ?> 146b6c326d8SGreg Roach > 147dd6b2bfcSGreg Roach <thead> 148dd6b2bfcSGreg Roach <tr> 149dd6b2bfcSGreg Roach <th colspan="14"> 150dd6b2bfcSGreg Roach <div class="btn-toolbar d-flex justify-content-between mb-2"> 151dd6b2bfcSGreg Roach <div class="btn-group" data-toggle="buttons"> 152dd6b2bfcSGreg Roach <button 153dd6b2bfcSGreg Roach class="btn btn-secondary" 154dd6b2bfcSGreg Roach data-filter-column="12" 155dd6b2bfcSGreg Roach data-filter-value="N" 156dd6b2bfcSGreg Roach title="' . I18N::translate('Show individuals who are alive or couples where both partners are alive.') ?>" 157dd6b2bfcSGreg Roach > 158dd6b2bfcSGreg Roach <?= I18N::translate('Both alive') ?> 159dd6b2bfcSGreg Roach </button> 160dd6b2bfcSGreg Roach <button 161dd6b2bfcSGreg Roach class="btn btn-secondary" 162dd6b2bfcSGreg Roach data-filter-column="12" 163dd6b2bfcSGreg Roach data-filter-value="W" 164dd6b2bfcSGreg Roach title="<?= I18N::translate('Show couples where only the female partner is dead.') ?>" 165dd6b2bfcSGreg Roach > 166dd6b2bfcSGreg Roach <?= I18N::translate('Widower') ?> 167dd6b2bfcSGreg Roach </button> 168dd6b2bfcSGreg Roach <button 169dd6b2bfcSGreg Roach class="btn btn-secondary" 170dd6b2bfcSGreg Roach data-filter-column="12" 171dd6b2bfcSGreg Roach data-filter-value="H" 172dd6b2bfcSGreg Roach title="<?= I18N::translate('Show couples where only the male partner is dead.') ?>" 173dd6b2bfcSGreg Roach > 174dd6b2bfcSGreg Roach <?= I18N::translate('Widow') ?> 175dd6b2bfcSGreg Roach </button> 176dd6b2bfcSGreg Roach <button 177dd6b2bfcSGreg Roach class="btn btn-secondary" 178dd6b2bfcSGreg Roach data-filter-column="12" 179dd6b2bfcSGreg Roach data-filter-value="Y" 180dd6b2bfcSGreg Roach title="<?= I18N::translate('Show individuals who are dead or couples where both partners are dead.') ?>" 181dd6b2bfcSGreg Roach > 182dd6b2bfcSGreg Roach <?= I18N::translate('Both dead') ?> 183dd6b2bfcSGreg Roach </button> 184dd6b2bfcSGreg Roach </div> 185dd6b2bfcSGreg Roach <div class="btn-group" data-toggle="buttons"> 186dd6b2bfcSGreg Roach <button 187dd6b2bfcSGreg Roach class="btn btn-secondary" 188dd6b2bfcSGreg Roach data-filter-column="13" 189dd6b2bfcSGreg Roach data-filter-value="R" 190dd6b2bfcSGreg Roach 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.') ?>" 191dd6b2bfcSGreg Roach > 192dd6b2bfcSGreg Roach <?= I18N::translate('Roots') ?> 193dd6b2bfcSGreg Roach </button> 194dd6b2bfcSGreg Roach <button 195dd6b2bfcSGreg Roach class="btn btn-secondary" 196dd6b2bfcSGreg Roach data-filter-column="13" 197dd6b2bfcSGreg Roach data-filter-value="L" 198dd6b2bfcSGreg Roach title="<?= I18N::translate('Show “leaves” couples or individuals. These are individuals who are alive but have no children recorded in the database.') ?>" 199dd6b2bfcSGreg Roach > 200dd6b2bfcSGreg Roach <?= I18N::translate('Leaves') ?> 201dd6b2bfcSGreg Roach </button> 202dd6b2bfcSGreg Roach </div> 203dd6b2bfcSGreg Roach <div class="btn-group" data-toggle="buttons"> 204dd6b2bfcSGreg Roach <button 205dd6b2bfcSGreg Roach class="btn btn-secondary" 206dd6b2bfcSGreg Roach data-filter-column="11" 207dd6b2bfcSGreg Roach data-filter-value="U" 208dd6b2bfcSGreg Roach title="<?= I18N::translate('Show couples with an unknown marriage date.') ?>" 209dd6b2bfcSGreg Roach > 210dd6b2bfcSGreg Roach <?= I18N::translate('Marriage') ?> 211dd6b2bfcSGreg Roach </button> 212dd6b2bfcSGreg Roach <button 213dd6b2bfcSGreg Roach class="btn btn-secondary" 214dd6b2bfcSGreg Roach data-filter-column="11" 215dd6b2bfcSGreg Roach data-filter-value="YES" 216dd6b2bfcSGreg Roach title="<?= I18N::translate('Show couples who married more than 100 years ago.') ?>" 217dd6b2bfcSGreg Roach > 218dd6b2bfcSGreg Roach <?= I18N::translate('Marriage') ?>>100 219dd6b2bfcSGreg Roach </button> 220dd6b2bfcSGreg Roach <button 221dd6b2bfcSGreg Roach class="btn btn-secondary" 222dd6b2bfcSGreg Roach data-filter-column="11" 223dd6b2bfcSGreg Roach data-filter-value="Y100" 224dd6b2bfcSGreg Roach title="<?= I18N::translate('Show couples who married within the last 100 years.') ?>" 225dd6b2bfcSGreg Roach > 226dd6b2bfcSGreg Roach <?= I18N::translate('Marriage') ?><=100 227dd6b2bfcSGreg Roach </button> 228dd6b2bfcSGreg Roach <button 229dd6b2bfcSGreg Roach class="btn btn-secondary" 230dd6b2bfcSGreg Roach data-filter-column="11" 231dd6b2bfcSGreg Roach data-filter-value="D" 232dd6b2bfcSGreg Roach title="<?= I18N::translate('Show divorced couples.') ?>" 233dd6b2bfcSGreg Roach > 234dd6b2bfcSGreg Roach <?= I18N::translate('Divorce') ?> 235dd6b2bfcSGreg Roach </button> 236dd6b2bfcSGreg Roach <button 237dd6b2bfcSGreg Roach class="btn btn-secondary" 238dd6b2bfcSGreg Roach data-filter-column="11" 239dd6b2bfcSGreg Roach data-filter-value="M" 240dd6b2bfcSGreg Roach title="<?= I18N::translate('Show couples where either partner married more than once.') ?>" 241dd6b2bfcSGreg Roach > 242dd6b2bfcSGreg Roach <?= I18N::translate('Multiple marriages') ?> 243dd6b2bfcSGreg Roach </button> 244dd6b2bfcSGreg Roach </div> 245dd6b2bfcSGreg Roach </div> 246dd6b2bfcSGreg Roach </th> 247dd6b2bfcSGreg Roach </tr> 248dd6b2bfcSGreg Roach <tr> 249dd6b2bfcSGreg Roach <th><?= I18N::translate('Given names') ?></th> 250dd6b2bfcSGreg Roach <th><?= I18N::translate('Surname') ?></th> 251dd6b2bfcSGreg Roach <th><?= I18N::translate('Age') ?></th> 252dd6b2bfcSGreg Roach <th><?= I18N::translate('Given names') ?></th> 253dd6b2bfcSGreg Roach <th><?= I18N::translate('Surname') ?></th> 254dd6b2bfcSGreg Roach <th><?= I18N::translate('Age') ?></th> 255dd6b2bfcSGreg Roach <th><?= I18N::translate('Marriage') ?></th> 256e39fd5c6SGreg Roach <th> 257e39fd5c6SGreg Roach <span title="<?= I18N::translate('Anniversary') ?>"> 258e39fd5c6SGreg Roach <?= view('icons/anniversary') ?> 259e39fd5c6SGreg Roach </span> 260e39fd5c6SGreg Roach </th> 261dd6b2bfcSGreg Roach <th><?= I18N::translate('Place') ?></th> 262dd6b2bfcSGreg Roach <th><i class="icon-children" title="<?= I18N::translate('Children') ?>"></i></th> 263dd6b2bfcSGreg Roach <th><?= I18N::translate('Last change') ?></th> 264dd6b2bfcSGreg Roach <th hidden></th> 265dd6b2bfcSGreg Roach <th hidden></th> 266dd6b2bfcSGreg Roach <th hidden></th> 267dd6b2bfcSGreg Roach </tr> 268dd6b2bfcSGreg Roach </thead> 269dd6b2bfcSGreg Roach 270dd6b2bfcSGreg Roach <tfoot> 271dd6b2bfcSGreg Roach <tr> 272dd6b2bfcSGreg Roach <th colspan="14"> 273dd6b2bfcSGreg Roach <div class="btn-toolbar"> 274dd6b2bfcSGreg Roach <div class="btn-group"> 275dd6b2bfcSGreg Roach <button class="ui-state-default btn-toggle-parents"> 276dd6b2bfcSGreg Roach <?= I18N::translate('Show parents') ?> 277dd6b2bfcSGreg Roach </button> 278dd6b2bfcSGreg Roach <button class="ui-state-default btn-toggle-statistics"> 279dd6b2bfcSGreg Roach <?= I18N::translate('Show statistics charts') ?> 280dd6b2bfcSGreg Roach </button> 281dd6b2bfcSGreg Roach </div> 282dd6b2bfcSGreg Roach </div> 283dd6b2bfcSGreg Roach </th> 284dd6b2bfcSGreg Roach </tr> 285dd6b2bfcSGreg Roach </tfoot> 286dd6b2bfcSGreg Roach <tbody> 287dd6b2bfcSGreg Roach 288dd6b2bfcSGreg Roach <?php foreach ($families as $family) : ?> 28939ca88baSGreg Roach <?php $husb = $family->husband() ?? new Individual('H', '0 @H@ INDI', null, $family->tree()) ?> 29039ca88baSGreg Roach <?php $wife = $family->wife() ?? new Individual('W', '0 @W@ INDI', null, $family->tree()) ?> 291dd6b2bfcSGreg Roach 292*17dd427eSGreg Roach <tr class="<?= $family->isPendingDeletion() ? 'wt-old' : ($family->isPendingAddition() ? 'wt-new' : '') ?>"> 293dd6b2bfcSGreg Roach <!-- Husband name --> 29439ca88baSGreg Roach <td colspan="2" data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', implode(',', array_reverse(explode(',', $husb->sortName()))))) ?>"> 295dd6b2bfcSGreg Roach <?php foreach ($husb->getAllNames() as $num => $name) : ?> 296dd6b2bfcSGreg Roach <?php if ($name['type'] != '_MARNM' || $num == $husb->getPrimaryName()) : ?> 297dd6b2bfcSGreg Roach <a title="<?= $name['type'] === 'NAME' ? '' : GedcomTag::getLabel($name['type'], $husb) ?>" href="<?= e($family->url()) ?>" class="<?= $num === $husb->getPrimaryName() ? 'name2' : '' ?>"> 298dd6b2bfcSGreg Roach <?= $name['full'] ?> 299dd6b2bfcSGreg Roach </a> 300dd6b2bfcSGreg Roach <?php if ($num === $husb->getPrimaryName()) : ?> 301dd6b2bfcSGreg Roach <?= $husb->getSexImage() ?> 302dd6b2bfcSGreg Roach <?php endif ?> 303dd6b2bfcSGreg Roach <br> 304dd6b2bfcSGreg Roach <?php endif ?> 305dd6b2bfcSGreg Roach <?php endforeach ?> 306dd6b2bfcSGreg Roach <?= $husb->getPrimaryParentsNames('parents details1', 'none') ?> 307dd6b2bfcSGreg Roach </td> 308dd6b2bfcSGreg Roach 30939ca88baSGreg Roach <td hidden data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', $husb->sortName())) ?>"></td> 310dd6b2bfcSGreg Roach 311dd6b2bfcSGreg Roach <!-- Husband age --> 312dd6b2bfcSGreg Roach <?php 313dd6b2bfcSGreg Roach $mdate = $family->getMarriageDate(); 314dd6b2bfcSGreg Roach $hdate = $husb->getBirthDate(); 315dd6b2bfcSGreg Roach if ($hdate->isOK() && $mdate->isOK()) { 316dd6b2bfcSGreg Roach if ($hdate->gregorianYear() >= 1550 && $hdate->gregorianYear() < 2030) { 3171b860509SRico Sonntag ++$birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10][$husb->sex()]; 318dd6b2bfcSGreg Roach } 319dd6b2bfcSGreg Roach $hage = Date::getAgeYears($hdate, $mdate); 320dd6b2bfcSGreg Roach if ($hage >= 0 && $hage <= $max_age) { 3211b860509SRico Sonntag ++$marr_by_age[$hage][$husb->sex()]; 322dd6b2bfcSGreg Roach } 323dd6b2bfcSGreg Roach } 324dd6b2bfcSGreg Roach ?> 325242a7862SGreg Roach <td class="text-center" data-sort="<?= Date::getAgeDays($hdate, $mdate) ?>"> 326dd6b2bfcSGreg Roach <?= Date::getAge($hdate, $mdate) ?> 327dd6b2bfcSGreg Roach </td> 328dd6b2bfcSGreg Roach 329dd6b2bfcSGreg Roach <!-- Wife name --> 33039ca88baSGreg Roach <td colspan="2" data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', implode(',', array_reverse(explode(',', $wife->sortName()))))) ?>"> 331dd6b2bfcSGreg Roach <?php foreach ($wife->getAllNames() as $num => $name) : ?> 332dd6b2bfcSGreg Roach <?php if ($name['type'] != '_MARNM' || $num == $wife->getPrimaryName()) : ?> 333dd6b2bfcSGreg Roach <a title="<?= $name['type'] === 'NAME' ? '' : GedcomTag::getLabel($name['type'], $wife) ?>" href="<?= e($family->url()) ?>" class="<?= $num === $wife->getPrimaryName() ? 'name2' : '' ?>"> 334dd6b2bfcSGreg Roach <?= $name['full'] ?> 335dd6b2bfcSGreg Roach </a> 336dd6b2bfcSGreg Roach <?php if ($num === $wife->getPrimaryName()) : ?> 337dd6b2bfcSGreg Roach <?= $wife->getSexImage() ?> 338dd6b2bfcSGreg Roach <?php endif ?> 339dd6b2bfcSGreg Roach <br> 340dd6b2bfcSGreg Roach <?php endif ?> 341dd6b2bfcSGreg Roach <?php endforeach ?> 342dd6b2bfcSGreg Roach <?= $wife->getPrimaryParentsNames('parents details1', 'none') ?> 343dd6b2bfcSGreg Roach </td> 344dd6b2bfcSGreg Roach 34539ca88baSGreg Roach <td hidden data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', $wife->sortName())) ?>"></td> 346dd6b2bfcSGreg Roach 347dd6b2bfcSGreg Roach <!-- Wife age --> 348dd6b2bfcSGreg Roach <?php 349dd6b2bfcSGreg Roach $wdate = $wife->getBirthDate(); 350dd6b2bfcSGreg Roach if ($wdate->isOK() && $mdate->isOK()) { 351dd6b2bfcSGreg Roach if ($wdate->gregorianYear() >= 1550 && $wdate->gregorianYear() < 2030) { 3521b860509SRico Sonntag ++$birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10][$wife->sex()]; 353dd6b2bfcSGreg Roach } 354dd6b2bfcSGreg Roach $wage = Date::getAgeYears($wdate, $mdate); 355dd6b2bfcSGreg Roach if ($wage >= 0 && $wage <= $max_age) { 3561b860509SRico Sonntag ++$marr_by_age[$wage][$wife->sex()]; 357dd6b2bfcSGreg Roach } 358dd6b2bfcSGreg Roach } 359dd6b2bfcSGreg Roach ?> 360dd6b2bfcSGreg Roach 361242a7862SGreg Roach <td class="text-center" data-sort="<?= Date::getAgeDays($wdate, $mdate) ?>"> 362dd6b2bfcSGreg Roach <?= Date::getAge($wdate, $mdate) ?> 363dd6b2bfcSGreg Roach </td> 364dd6b2bfcSGreg Roach 365dd6b2bfcSGreg Roach <!-- Marriage date --> 366dd6b2bfcSGreg Roach <td data-sort="<?= $family->getMarriageDate()->julianDay() ?>"> 367dd6b2bfcSGreg Roach <?php if ($marriage_dates = $family->getAllMarriageDates()) : ?> 368dd6b2bfcSGreg Roach <?php foreach ($marriage_dates as $n => $marriage_date) : ?> 369dd6b2bfcSGreg Roach <div><?= $marriage_date->display(true) ?></div> 370dd6b2bfcSGreg Roach <?php endforeach ?> 371dd6b2bfcSGreg Roach <?php if ($marriage_dates[0]->gregorianYear() >= 1550 && $marriage_dates[0]->gregorianYear() < 2030) : ?> 3721b860509SRico Sonntag <?php 3731b860509SRico Sonntag ++$marr_by_decade[(int) ($marriage_dates[0]->gregorianYear() / 10) * 10][$husb->sex()]; 3741b860509SRico Sonntag ++$marr_by_decade[(int) ($marriage_dates[0]->gregorianYear() / 10) * 10][$wife->sex()]; 3751b860509SRico Sonntag ?> 376dd6b2bfcSGreg Roach <?php endif ?> 37739ca88baSGreg Roach <?php elseif ($family->facts(['_NMR'])->isNotEmpty()) : ?> 378dd6b2bfcSGreg Roach <?= I18N::translate('no') ?> 37939ca88baSGreg Roach <?php elseif ($family->facts(['MARR'])->isNotEmpty()) : ?> 380dd6b2bfcSGreg Roach <?= I18N::translate('yes') ?> 381dd6b2bfcSGreg Roach <?php endif ?> 382dd6b2bfcSGreg Roach </td> 383dd6b2bfcSGreg Roach 384dd6b2bfcSGreg Roach <!-- Marriage anniversary --> 385242a7862SGreg Roach <td class="text-center" data-sort="<?= -$family->getMarriageDate()->julianDay() ?>"> 386dd6b2bfcSGreg Roach <?= Date::getAge($family->getMarriageDate(), null) ?> 387dd6b2bfcSGreg Roach </td> 388dd6b2bfcSGreg Roach 389dd6b2bfcSGreg Roach <!-- Marriage place --> 390dd6b2bfcSGreg Roach <td> 391dd6b2bfcSGreg Roach <?php foreach ($family->getAllMarriagePlaces() as $n => $marriage_place) : ?> 392392561bbSGreg Roach <?= $marriage_place->shortName(true) ?> 393dd6b2bfcSGreg Roach <br> 394dd6b2bfcSGreg Roach <?php endforeach ?> 395dd6b2bfcSGreg Roach </td> 396dd6b2bfcSGreg Roach 397dd6b2bfcSGreg Roach <!-- Number of children --> 39839ca88baSGreg Roach <td class="text-center" data-sort="<?= $family->numberOfChildren() ?>"> 39939ca88baSGreg Roach <?= I18N::number($family->numberOfChildren()) ?> 400dd6b2bfcSGreg Roach </td> 401dd6b2bfcSGreg Roach 402dd6b2bfcSGreg Roach <!-- Last change --> 4034459dc9aSGreg Roach <td data-sort="<?= $family->lastChangeTimestamp()->unix() ?>"> 4044459dc9aSGreg Roach <?= view('components/datetime', ['timestamp' => $family->lastChangeTimestamp()]) ?> 405dd6b2bfcSGreg Roach </td> 406dd6b2bfcSGreg Roach 407dd6b2bfcSGreg Roach <!-- Filter by marriage date --> 408dd6b2bfcSGreg Roach <td hidden> 409dd6b2bfcSGreg Roach <?php if (!$family->canShow() || !$mdate->isOK()) : ?> 410dd6b2bfcSGreg Roach U 411dd6b2bfcSGreg Roach <?php elseif (Date::compare($mdate, $hundred_years_ago) > 0) : ?> 412dd6b2bfcSGreg Roach Y100 413dd6b2bfcSGreg Roach <?php else : ?> 414dd6b2bfcSGreg Roach YES 415dd6b2bfcSGreg Roach <?php endif ?> 41639ca88baSGreg Roach <?php if ($family->facts(Gedcom::DIVORCE_EVENTS)->isNotEmpty()) : ?> 417dd6b2bfcSGreg Roach D 418dd6b2bfcSGreg Roach <?php endif ?> 41939ca88baSGreg Roach <?php if (count($husb->spouseFamilies()) > 1 || count($wife->spouseFamilies()) > 1) : ?> 420dd6b2bfcSGreg Roach M 421dd6b2bfcSGreg Roach <?php endif ?> 422dd6b2bfcSGreg Roach </td> 423dd6b2bfcSGreg Roach 424dd6b2bfcSGreg Roach <!-- Filter by alive/dead --> 425dd6b2bfcSGreg Roach <td hidden> 426dd6b2bfcSGreg Roach <?php if ($husb->isDead() && $wife->isDead()) : ?> 427dd6b2bfcSGreg Roach Y 428dd6b2bfcSGreg Roach <?php endif ?> 429dd6b2bfcSGreg Roach <?php if ($husb->isDead() && !$wife->isDead()) : ?> 43039ca88baSGreg Roach <?php if ($wife->sex() == 'F') : ?> 431dd6b2bfcSGreg Roach H 432dd6b2bfcSGreg Roach <?php endif ?> 43339ca88baSGreg Roach <?php if ($wife->sex() == 'M') : ?> 434dd6b2bfcSGreg Roach W 435dd6b2bfcSGreg Roach <?php endif ?> 436dd6b2bfcSGreg Roach <?php endif ?> 437dd6b2bfcSGreg Roach <?php if (!$husb->isDead() && $wife->isDead()) : ?> 43839ca88baSGreg Roach <?php if ($husb->sex() == 'M') : ?> 439dd6b2bfcSGreg Roach W 440dd6b2bfcSGreg Roach <?php endif ?> 44139ca88baSGreg Roach <?php if ($husb->sex() == 'F') : ?> 442dd6b2bfcSGreg Roach H 443dd6b2bfcSGreg Roach <?php endif ?> 444dd6b2bfcSGreg Roach <?php endif ?> 445dd6b2bfcSGreg Roach <?php if (!$husb->isDead() && !$wife->isDead()) : ?> 446dd6b2bfcSGreg Roach N 447dd6b2bfcSGreg Roach <?php endif ?> 448dd6b2bfcSGreg Roach </td> 449dd6b2bfcSGreg Roach 450dd6b2bfcSGreg Roach <!-- Filter by roots/leaves --> 451dd6b2bfcSGreg Roach <td hidden> 45239ca88baSGreg Roach <?php if (!$husb->childFamilies() && !$wife->childFamilies()) : ?> 453dd6b2bfcSGreg Roach R 45439ca88baSGreg Roach <?php elseif (!$husb->isDead() && !$wife->isDead() && $family->numberOfChildren() === 0) : ?> 455dd6b2bfcSGreg Roach L 456dd6b2bfcSGreg Roach <?php endif ?> 457dd6b2bfcSGreg Roach </td> 458dd6b2bfcSGreg Roach </tr> 459dd6b2bfcSGreg Roach <?php endforeach ?> 460dd6b2bfcSGreg Roach </tbody> 461dd6b2bfcSGreg Roach </table> 4621b860509SRico Sonntag</div> 463dd6b2bfcSGreg Roach 4641b860509SRico Sonntag<div id="family-charts-<?= e($table_id) ?>" style="display: none;"> 4651b860509SRico Sonntag <div class="mb-3"> 4661b860509SRico Sonntag <div class="card-deck"> 4671b860509SRico Sonntag <div class="col-lg-12 col-md-12 mb-3"> 4681b860509SRico Sonntag <div class="card m-0"> 4691b860509SRico Sonntag <div class="card-header"> 4701b860509SRico Sonntag <?= I18N::translate('Decade of birth') ?> 4711b860509SRico Sonntag </div><div class="card-body"> 4721b860509SRico Sonntag <?php 4731b860509SRico Sonntag foreach ($birt_by_decade as $century => $values) { 4741b860509SRico Sonntag if (($values['M'] + $values['F']) > 0) { 4751b860509SRico Sonntag $birthData[] = [ 4761b860509SRico Sonntag [ 4771b860509SRico Sonntag 'v' => 'Date(' . $century . ', 0, 1)', 4781b860509SRico Sonntag 'f' => $century, 4791b860509SRico Sonntag ], 4801b860509SRico Sonntag $values['M'], 4811b860509SRico Sonntag $values['F'], 4821b860509SRico Sonntag ]; 4831b860509SRico Sonntag } 4841b860509SRico Sonntag } 4851b860509SRico Sonntag ?> 4861b860509SRico Sonntag <?= view('lists/chart-by-decade', ['data' => $birthData, 'title' => I18N::translate('Decade of birth')]) ?> 4871b860509SRico Sonntag </div> 4881b860509SRico Sonntag </div> 4891b860509SRico Sonntag </div> 4901b860509SRico Sonntag </div> 4911b860509SRico Sonntag <div class="card-deck"> 4921b860509SRico Sonntag <div class="col-lg-12 col-md-12 mb-3"> 4931b860509SRico Sonntag <div class="card m-0"> 4941b860509SRico Sonntag <div class="card-header"> 4951b860509SRico Sonntag <?= I18N::translate('Decade of marriage') ?> 4961b860509SRico Sonntag </div><div class="card-body"> 4971b860509SRico Sonntag <?php 4981b860509SRico Sonntag foreach ($marr_by_decade as $century => $values) { 4991b860509SRico Sonntag if (($values['M'] + $values['F']) > 0) { 5001b860509SRico Sonntag $marriageData[] = [ 5011b860509SRico Sonntag [ 5021b860509SRico Sonntag 'v' => 'Date(' . $century . ', 0, 1)', 5031b860509SRico Sonntag 'f' => $century, 5041b860509SRico Sonntag ], 5051b860509SRico Sonntag $values['M'], 5061b860509SRico Sonntag $values['F'], 5071b860509SRico Sonntag ]; 5081b860509SRico Sonntag } 5091b860509SRico Sonntag } 5101b860509SRico Sonntag ?> 5111b860509SRico Sonntag <?= view('lists/chart-by-decade', ['data' => $marriageData, 'title' => I18N::translate('Decade of marriage')]) ?> 5121b860509SRico Sonntag </div> 5131b860509SRico Sonntag </div> 5141b860509SRico Sonntag </div> 5151b860509SRico Sonntag </div> 5161b860509SRico Sonntag <div class="card-deck"> 5171b860509SRico Sonntag <div class="col-lg-12 col-md-12 mb-3"> 5181b860509SRico Sonntag <div class="card m-0"> 5191b860509SRico Sonntag <div class="card-header"> 5201b860509SRico Sonntag <?= I18N::translate('Age in year of marriage') ?> 5211b860509SRico Sonntag </div> 5221b860509SRico Sonntag <div class="card-body"> 5231b860509SRico Sonntag <?php 5241b860509SRico Sonntag $totalAge = 0; 5251b860509SRico Sonntag $totalSum = 0; 5261b860509SRico Sonntag $max = 0; 5271b860509SRico Sonntag 5281b860509SRico Sonntag foreach ($marr_by_age as $age => $values) { 5291b860509SRico Sonntag if (($values['M'] + $values['F']) > 0) { 5301b860509SRico Sonntag if (($values['M'] + $values['F']) > $max) { 5311b860509SRico Sonntag $max = $values['M'] + $values['F']; 5321b860509SRico Sonntag } 5331b860509SRico Sonntag 5341b860509SRico Sonntag $totalAge += $age * ($values['M'] + $values['F']); 5351b860509SRico Sonntag $totalSum += $values['M'] + $values['F']; 5361b860509SRico Sonntag 5371b860509SRico Sonntag $marriageAgeData[] = [ 5381b860509SRico Sonntag $age, 5391b860509SRico Sonntag $values['M'], 5401b860509SRico Sonntag $values['F'], 5411b860509SRico Sonntag null, 5421b860509SRico Sonntag ]; 5431b860509SRico Sonntag } 5441b860509SRico Sonntag } 5451b860509SRico Sonntag 5461b860509SRico Sonntag if ($totalSum > 0) { 5471b860509SRico Sonntag $marriageAgeData[] = [ 5481b860509SRico Sonntag round($totalAge / $totalSum, 1), 5491b860509SRico Sonntag null, 5501b860509SRico Sonntag null, 5511b860509SRico Sonntag 0, 5521b860509SRico Sonntag ]; 5531b860509SRico Sonntag 5541b860509SRico Sonntag $marriageAgeData[] = [ 5551b860509SRico Sonntag round($totalAge / $totalSum, 1), 5561b860509SRico Sonntag null, 5571b860509SRico Sonntag null, 5581b860509SRico Sonntag $max, 5591b860509SRico Sonntag ]; 5601b860509SRico Sonntag } 5611b860509SRico Sonntag ?> 5621b860509SRico Sonntag <?= view('lists/chart-by-age', ['data' => $marriageAgeData, 'title' => I18N::translate('Age in year of marriage')]) ?> 5631b860509SRico Sonntag </div> 5641b860509SRico Sonntag </div> 5651b860509SRico Sonntag </div> 5661b860509SRico Sonntag </div> 567dd6b2bfcSGreg Roach </div> 568dd6b2bfcSGreg Roach</div> 569