1dd6b2bfcSGreg Roach<?php 2*1b860509SRico Sonntagdeclare(strict_types=1); 3*1b860509SRico Sonntag 4*1b860509SRico Sonntaguse Fisharebest\Webtrees\Auth; 5*1b860509SRico Sonntaguse Fisharebest\Webtrees\Date; 6*1b860509SRico Sonntaguse Fisharebest\Webtrees\GedcomTag; 7*1b860509SRico Sonntaguse Fisharebest\Webtrees\I18N; 8*1b860509SRico Sonntaguse Fisharebest\Webtrees\Individual; 9*1b860509SRico Sonntaguse Fisharebest\Webtrees\Module\ModuleInterface; 10*1b860509SRico Sonntaguse Fisharebest\Webtrees\Module\RelationshipsChartModule; 11*1b860509SRico Sonntaguse Fisharebest\Webtrees\Services\ModuleService; 12*1b860509SRico Sonntaguse Fisharebest\Webtrees\View; 13*1b860509SRico Sonntaguse Ramsey\Uuid\Uuid; 14*1b860509SRico Sonntag 15dd6b2bfcSGreg Roach// lists requires a unique ID in case there are multiple lists per page 16dd6b2bfcSGreg Roach$table_id = 'table-indi-' . Uuid::uuid4()->toString(); 17dd6b2bfcSGreg Roach 18*1b860509SRico Sonntag$hundred_years_ago = new DateTime(); 19*1b860509SRico Sonntag$hundred_years_ago->modify('-100 years'); 20*1b860509SRico Sonntag$hundred_years_ago = new Date($hundred_years_ago->format('Y')); 21*1b860509SRico Sonntag 22dd6b2bfcSGreg Roach$unique_indis = []; // Don't double-count indis with multiple names. 2384b37362SGreg Roach 24*1b860509SRico Sonntag$module = app(ModuleService::class) 25*1b860509SRico Sonntag ->findByComponent('chart', $tree, Auth::user()) 26*1b860509SRico Sonntag ->first(function (ModuleInterface $module) { 2790d97cc8SGreg Roach return $module instanceof RelationshipsChartModule; 2890d97cc8SGreg Roach }); 29dd6b2bfcSGreg Roach?> 30dd6b2bfcSGreg Roach 31dd6b2bfcSGreg Roach<?php View::push('javascript') ?> 32dd6b2bfcSGreg Roach<script> 33*1b860509SRico Sonntag 34dd6b2bfcSGreg Roach$("#<?= e($table_id) ?>").dataTable({ 35dd6b2bfcSGreg Roach dom: '<"H"<"filtersH_<?= e($table_id) ?>">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_<?= e($table_id) ?>">>', 36dd6b2bfcSGreg Roach <?= I18N::datatablesI18N() ?>, 37dd6b2bfcSGreg Roach autoWidth: false, 38dd6b2bfcSGreg Roach processing: true, 39dd6b2bfcSGreg Roach retrieve: true, 40dd6b2bfcSGreg Roach columns: [ 41dd6b2bfcSGreg Roach /* Given names */ { type: "text" }, 42dd6b2bfcSGreg Roach /* Surnames */ { type: "text" }, 43dd6b2bfcSGreg Roach /* SOSA numnber */ { type: "num", visible: <?= json_encode($sosa) ?> }, 44dd6b2bfcSGreg Roach /* Birth date */ { type: "num" }, 45dd6b2bfcSGreg Roach /* Anniversary */ { type: "num" }, 46dd6b2bfcSGreg Roach /* Birthplace */ { type: "text" }, 47dd6b2bfcSGreg Roach /* Children */ { type: "num" }, 48dd6b2bfcSGreg Roach /* Deate date */ { type: "num" }, 49dd6b2bfcSGreg Roach /* Anniversary */ { type: "num" }, 50dd6b2bfcSGreg Roach /* Age */ { type: "num" }, 51dd6b2bfcSGreg Roach /* Death place */ { type: "text" }, 52dd6b2bfcSGreg Roach /* Last change */ { visible: <?= json_encode($tree->getPreference('SHOW_LAST_CHANGE')) ?> }, 53dd6b2bfcSGreg Roach /* Filter sex */ { sortable: false }, 54dd6b2bfcSGreg Roach /* Filter birth */ { sortable: false }, 55dd6b2bfcSGreg Roach /* Filter death */ { sortable: false }, 56dd6b2bfcSGreg Roach /* Filter tree */ { sortable: false } 57dd6b2bfcSGreg Roach ], 58dd6b2bfcSGreg Roach sorting: <?= json_encode($sosa ? [[4, "asc"]] : [[1, "asc"]]) ?>, 59dd6b2bfcSGreg Roach displayLength: 20, 60dd6b2bfcSGreg Roach pagingType: "full_numbers" 61dd6b2bfcSGreg Roach}); 62dd6b2bfcSGreg Roach 63dd6b2bfcSGreg Roach$("#<?= e($table_id) ?>") 64dd6b2bfcSGreg Roach /* Hide/show parents */ 65dd6b2bfcSGreg Roach .on("click", ".btn-toggle-parents", function() { 66dd6b2bfcSGreg Roach $(this).toggleClass("ui-state-active"); 67dd6b2bfcSGreg Roach $(".parents", $(this).closest("table").DataTable().rows().nodes()).slideToggle(); 68dd6b2bfcSGreg Roach }) 69dd6b2bfcSGreg Roach /* Hide/show statistics */ 70dd6b2bfcSGreg Roach .on("click", ".btn-toggle-statistics", function() { 71dd6b2bfcSGreg Roach $(this).toggleClass("ui-state-active"); 72*1b860509SRico Sonntag $("#individual-charts-<?= e($table_id) ?>").slideToggle({ 73*1b860509SRico Sonntag complete: function () { 74*1b860509SRico Sonntag // Trigger resize to redraw the chart 75*1b860509SRico Sonntag $('div[id^="google-chart-"]').resize(); 76*1b860509SRico Sonntag } 77*1b860509SRico Sonntag }); 78dd6b2bfcSGreg Roach }) 79dd6b2bfcSGreg Roach /* Filter buttons in table header */ 80dd6b2bfcSGreg Roach .on("click", "button[data-filter-column]", function() { 81dd6b2bfcSGreg Roach var btn = $(this); 82dd6b2bfcSGreg Roach // De-activate the other buttons in this button group 83dd6b2bfcSGreg Roach btn.siblings().removeClass("active"); 84dd6b2bfcSGreg Roach // Apply (or clear) this filter 85dd6b2bfcSGreg Roach var col = $("#<?= e($table_id) ?>").DataTable().column(btn.data("filter-column")); 86dd6b2bfcSGreg Roach if (btn.hasClass("active")) { 87dd6b2bfcSGreg Roach col.search("").draw(); 88dd6b2bfcSGreg Roach } else { 89dd6b2bfcSGreg Roach col.search(btn.data("filter-value")).draw(); 90dd6b2bfcSGreg Roach } 91dd6b2bfcSGreg Roach }); 92*1b860509SRico Sonntag 93dd6b2bfcSGreg Roach</script> 94dd6b2bfcSGreg Roach<?php View::endpush() ?> 95dd6b2bfcSGreg Roach 96dd6b2bfcSGreg Roach<?php 97dd6b2bfcSGreg Roach$max_age = (int) $tree->getPreference('MAX_ALIVE_AGE'); 98dd6b2bfcSGreg Roach 99dd6b2bfcSGreg Roach// Inititialise chart data 100dd6b2bfcSGreg Roach$deat_by_age = []; 101dd6b2bfcSGreg Roachfor ($age = 0; $age <= $max_age; $age++) { 102*1b860509SRico Sonntag $deat_by_age[$age]['M'] = 0; 103*1b860509SRico Sonntag $deat_by_age[$age]['F'] = 0; 104*1b860509SRico Sonntag $deat_by_age[$age]['U'] = 0; 105dd6b2bfcSGreg Roach} 106dd6b2bfcSGreg Roach$birt_by_decade = []; 107dd6b2bfcSGreg Roach$deat_by_decade = []; 108*1b860509SRico Sonntagfor ($year = 1400; $year < 2050; $year += 10) { 109*1b860509SRico Sonntag $birt_by_decade[$year]['M'] = 0; 110*1b860509SRico Sonntag $birt_by_decade[$year]['F'] = 0; 111*1b860509SRico Sonntag $birt_by_decade[$year]['U'] = 0; 112*1b860509SRico Sonntag $deat_by_decade[$year]['M'] = 0; 113*1b860509SRico Sonntag $deat_by_decade[$year]['F'] = 0; 114*1b860509SRico Sonntag $deat_by_decade[$year]['U'] = 0; 115dd6b2bfcSGreg Roach} 116*1b860509SRico Sonntag 117*1b860509SRico Sonntag$birthData = [ 118*1b860509SRico Sonntag [ 119*1b860509SRico Sonntag [ 120*1b860509SRico Sonntag 'label' => I18N::translate('Century'), 121*1b860509SRico Sonntag 'type' => 'date', 122*1b860509SRico Sonntag ], [ 123*1b860509SRico Sonntag 'label' => I18N::translate('Males'), 124*1b860509SRico Sonntag 'type' => 'number', 125*1b860509SRico Sonntag ], [ 126*1b860509SRico Sonntag 'label' => I18N::translate('Females'), 127*1b860509SRico Sonntag 'type' => 'number', 128*1b860509SRico Sonntag ], 129*1b860509SRico Sonntag ] 130*1b860509SRico Sonntag]; 131*1b860509SRico Sonntag 132*1b860509SRico Sonntag$deathData = [ 133*1b860509SRico Sonntag [ 134*1b860509SRico Sonntag [ 135*1b860509SRico Sonntag 'label' => I18N::translate('Century'), 136*1b860509SRico Sonntag 'type' => 'date', 137*1b860509SRico Sonntag ], [ 138*1b860509SRico Sonntag 'label' => I18N::translate('Males'), 139*1b860509SRico Sonntag 'type' => 'number', 140*1b860509SRico Sonntag ], [ 141*1b860509SRico Sonntag 'label' => I18N::translate('Females'), 142*1b860509SRico Sonntag 'type' => 'number', 143*1b860509SRico Sonntag ], 144*1b860509SRico Sonntag ] 145*1b860509SRico Sonntag]; 146*1b860509SRico Sonntag 147*1b860509SRico Sonntag$deathAgeData = [ 148*1b860509SRico Sonntag [ 149*1b860509SRico Sonntag I18N::translate('Age'), 150*1b860509SRico Sonntag I18N::translate('Males'), 151*1b860509SRico Sonntag I18N::translate('Females'), 152*1b860509SRico Sonntag I18N::translate('Average age'), 153*1b860509SRico Sonntag ] 154*1b860509SRico Sonntag]; 155*1b860509SRico Sonntag 156dd6b2bfcSGreg Roach?> 157dd6b2bfcSGreg Roach 158dd6b2bfcSGreg Roach<div class="indi-list"> 159dd6b2bfcSGreg Roach <table id="<?= e($table_id) ?>"> 160dd6b2bfcSGreg Roach <thead> 161dd6b2bfcSGreg Roach <tr> 162dd6b2bfcSGreg Roach <th colspan="16"> 163dd6b2bfcSGreg Roach <div class="btn-toolbar d-flex justify-content-between mb-2" role="toolbar"> 164dd6b2bfcSGreg Roach <div class="btn-group" data-toggle="buttons"> 165dd6b2bfcSGreg Roach <button 166dd6b2bfcSGreg Roach class="btn btn-secondary" 167dd6b2bfcSGreg Roach data-filter-column="12" 168dd6b2bfcSGreg Roach data-filter-value="M" 169dd6b2bfcSGreg Roach title="<?= I18N::translate('Show only males.') ?>" 170dd6b2bfcSGreg Roach > 171dd6b2bfcSGreg Roach <?= Individual::sexImage('M', 'large') ?> 172dd6b2bfcSGreg Roach </button> 173dd6b2bfcSGreg Roach <button 174dd6b2bfcSGreg Roach class="btn btn-secondary" 175dd6b2bfcSGreg Roach data-filter-column="12" 176dd6b2bfcSGreg Roach data-filter-value="F" 177dd6b2bfcSGreg Roach title="<?= I18N::translate('Show only females.') ?>" 178dd6b2bfcSGreg Roach > 179dd6b2bfcSGreg Roach <?= Individual::sexImage('F', 'large') ?> 180dd6b2bfcSGreg Roach </button> 181dd6b2bfcSGreg Roach <button 182dd6b2bfcSGreg Roach class="btn btn-secondary" 183dd6b2bfcSGreg Roach data-filter-column="12" 184dd6b2bfcSGreg Roach data-filter-value="U" 185dd6b2bfcSGreg Roach title="<?= I18N::translate('Show only individuals for whom the gender is not known.') ?>" 186dd6b2bfcSGreg Roach > 187dd6b2bfcSGreg Roach <?= Individual::sexImage('U', 'large') ?> 188dd6b2bfcSGreg Roach </button> 189dd6b2bfcSGreg Roach </div> 190dd6b2bfcSGreg Roach <div class="btn-group" data-toggle="buttons"> 191dd6b2bfcSGreg Roach <button 192dd6b2bfcSGreg Roach class="btn btn-secondary" 193dd6b2bfcSGreg Roach data-filter-column="14" 194dd6b2bfcSGreg Roach data-filter-value="N" 195dd6b2bfcSGreg Roach title="<?= I18N::translate('Show individuals who are alive or couples where both partners are alive.') ?>" 196dd6b2bfcSGreg Roach > 197dd6b2bfcSGreg Roach <?= I18N::translate('Alive') ?> 198dd6b2bfcSGreg Roach </button> 199dd6b2bfcSGreg Roach <button 200dd6b2bfcSGreg Roach class="btn btn-secondary" 201dd6b2bfcSGreg Roach data-filter-column="14" 202dd6b2bfcSGreg Roach data-filter-value="Y" 203dd6b2bfcSGreg Roach title="<?= I18N::translate('Show individuals who are dead or couples where both partners are dead.') ?>" 204dd6b2bfcSGreg Roach > 205dd6b2bfcSGreg Roach <?= I18N::translate('Dead') ?> 206dd6b2bfcSGreg Roach </button> 207dd6b2bfcSGreg Roach <button 208dd6b2bfcSGreg Roach class="btn btn-secondary" 209dd6b2bfcSGreg Roach data-filter-column="14" 210dd6b2bfcSGreg Roach data-filter-value="YES" 211dd6b2bfcSGreg Roach title="<?= I18N::translate('Show individuals who died more than 100 years ago.') ?>" 212dd6b2bfcSGreg Roach > 213dd6b2bfcSGreg Roach <?= I18N::translate('Death') ?>>100 214dd6b2bfcSGreg Roach </button> 215dd6b2bfcSGreg Roach <button 216dd6b2bfcSGreg Roach class="btn btn-secondary" 217dd6b2bfcSGreg Roach data-filter-column="14" 218dd6b2bfcSGreg Roach data-filter-value="Y100" 219dd6b2bfcSGreg Roach title="<?= I18N::translate('Show individuals who died within the last 100 years.') ?>" 220dd6b2bfcSGreg Roach > 221392561bbSGreg Roach <?= I18N::translate('Death') ?><=100 222dd6b2bfcSGreg Roach </button> 223dd6b2bfcSGreg Roach </div> 224dd6b2bfcSGreg Roach <div class="btn-group" data-toggle="buttons"> 225dd6b2bfcSGreg Roach <button 226dd6b2bfcSGreg Roach class="btn btn-secondary" 227dd6b2bfcSGreg Roach data-filter-column="13" 228dd6b2bfcSGreg Roach data-filter-value="YES" 229dd6b2bfcSGreg Roach title="<?= I18N::translate('Show individuals born more than 100 years ago.') ?>" 230dd6b2bfcSGreg Roach > 231dd6b2bfcSGreg Roach <?= I18N::translate('Birth') ?>>100 232dd6b2bfcSGreg Roach </button> 233dd6b2bfcSGreg Roach <button 234dd6b2bfcSGreg Roach class="btn btn-secondary" 235dd6b2bfcSGreg Roach data-filter-column="13" 236dd6b2bfcSGreg Roach data-filter-value="Y100" 237dd6b2bfcSGreg Roach title="<?= I18N::translate('Show individuals born within the last 100 years.') ?>" 238dd6b2bfcSGreg Roach > 239dd6b2bfcSGreg Roach <?= I18N::translate('Birth') ?><=100 240dd6b2bfcSGreg Roach </button> 241dd6b2bfcSGreg Roach </div> 242dd6b2bfcSGreg Roach <div class="btn-group" data-toggle="buttons"> 243dd6b2bfcSGreg Roach <button 244dd6b2bfcSGreg Roach class="btn btn-secondary" 245dd6b2bfcSGreg Roach data-filter-column="15" 246dd6b2bfcSGreg Roach data-filter-value="R" 247dd6b2bfcSGreg 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.') ?>" 248dd6b2bfcSGreg Roach > 249dd6b2bfcSGreg Roach <?= I18N::translate('Roots') ?> 250dd6b2bfcSGreg Roach </button> 251dd6b2bfcSGreg Roach <button 252dd6b2bfcSGreg Roach class="btn btn-secondary" 253dd6b2bfcSGreg Roach data-filter-column="15" 254dd6b2bfcSGreg Roach data-filter-value="L" 255dd6b2bfcSGreg Roach title="<?= I18N::translate('Show “leaves” couples or individuals. These are individuals who are alive but have no children recorded in the database.') ?>" 256dd6b2bfcSGreg Roach > 257dd6b2bfcSGreg Roach <?= I18N::translate('Leaves') ?> 258dd6b2bfcSGreg Roach </button> 259dd6b2bfcSGreg Roach </div> 260dd6b2bfcSGreg Roach </div> 261dd6b2bfcSGreg Roach </th> 262dd6b2bfcSGreg Roach </tr> 263dd6b2bfcSGreg Roach <tr> 264dd6b2bfcSGreg Roach <th><?= I18N::translate('Given names') ?></th> 265dd6b2bfcSGreg Roach <th><?= I18N::translate('Surname') ?></th> 266dd6b2bfcSGreg Roach <th><?= /* I18N: Abbreviation for “Sosa-Stradonitz number”. This is an individual’s surname, so may need transliterating into non-latin alphabets. */ 267dd6b2bfcSGreg Roach I18N::translate('Sosa') ?></th> 268dd6b2bfcSGreg Roach <th><?= I18N::translate('Birth') ?></th> 269dd6b2bfcSGreg Roach <th> 270e39fd5c6SGreg Roach <span title="<?= I18N::translate('Anniversary') ?>"> 271e39fd5c6SGreg Roach <?= view('icons/anniversary') ?> 272e39fd5c6SGreg Roach </span> 273dd6b2bfcSGreg Roach </th> 274dd6b2bfcSGreg Roach <th><?= I18N::translate('Place') ?></th> 275dd6b2bfcSGreg Roach <th> 276dd6b2bfcSGreg Roach <i class="icon-children" title="<?= I18N::translate('Children') ?>"></i> 277dd6b2bfcSGreg Roach </th> 278dd6b2bfcSGreg Roach <th><?= I18N::translate('Death') ?></th> 279dd6b2bfcSGreg Roach <th> 280e39fd5c6SGreg Roach <span title="<?= I18N::translate('Anniversary') ?>"> 281e39fd5c6SGreg Roach <?= view('icons/anniversary') ?> 282e39fd5c6SGreg Roach </span> 283dd6b2bfcSGreg Roach </th> 284dd6b2bfcSGreg Roach <th><?= I18N::translate('Age') ?></th> 285dd6b2bfcSGreg Roach <th><?= I18N::translate('Place') ?></th> 286dd6b2bfcSGreg Roach <th><?= I18N::translate('Last change') ?></th> 287dd6b2bfcSGreg Roach <th hidden></th> 288dd6b2bfcSGreg Roach <th hidden></th> 289dd6b2bfcSGreg Roach <th hidden></th> 290dd6b2bfcSGreg Roach <th hidden></th> 291dd6b2bfcSGreg Roach </tr> 292dd6b2bfcSGreg Roach </thead> 293dd6b2bfcSGreg Roach <tfoot> 294dd6b2bfcSGreg Roach <tr> 295dd6b2bfcSGreg Roach <th colspan="16"> 296dd6b2bfcSGreg Roach <div class="btn-toolbar"> 297dd6b2bfcSGreg Roach <div class="btn-group"> 298dd6b2bfcSGreg Roach <button class="ui-state-default btn-toggle-parents"> 299dd6b2bfcSGreg Roach <?= I18N::translate('Show parents') ?> 300dd6b2bfcSGreg Roach </button> 301dd6b2bfcSGreg Roach <button class="ui-state-default btn-toggle-statistics"> 302dd6b2bfcSGreg Roach <?= I18N::translate('Show statistics charts') ?> 303dd6b2bfcSGreg Roach </button> 304dd6b2bfcSGreg Roach </div> 305dd6b2bfcSGreg Roach </div> 306dd6b2bfcSGreg Roach </th> 307dd6b2bfcSGreg Roach </tr> 308dd6b2bfcSGreg Roach </tfoot> 309dd6b2bfcSGreg Roach 310dd6b2bfcSGreg Roach <tbody> 311dd6b2bfcSGreg Roach <?php foreach ($individuals as $key => $individual) : ?> 312dd6b2bfcSGreg Roach <tr class="<?= $individual->isPendingDeletion() ? 'old' : ($individual->isPendingAddition() ? 'new' : '') ?>"> 31339ca88baSGreg Roach <td colspan="2" data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', implode(',', array_reverse(explode(',', $individual->sortName()))))) ?>"> 314dd6b2bfcSGreg Roach <?php foreach ($individual->getAllNames() as $num => $name) : ?> 315dd6b2bfcSGreg Roach <a title="<?= $name['type'] === 'NAME' ? '' : GedcomTag::getLabel($name['type'], $individual) ?>" href="<?= e($individual->url()) ?>" class="<?= $num === $individual->getPrimaryName() ? 'name2' : '' ?>"> 316dd6b2bfcSGreg Roach <?= $name['full'] ?> 317dd6b2bfcSGreg Roach </a> 318dd6b2bfcSGreg Roach <?php if ($num === $individual->getPrimaryName()) : ?> 319dd6b2bfcSGreg Roach <?= $individual->getSexImage() ?> 320dd6b2bfcSGreg Roach <?php endif ?> 321dd6b2bfcSGreg Roach <br> 322dd6b2bfcSGreg Roach <?php endforeach ?> 323dd6b2bfcSGreg Roach <?= $individual->getPrimaryParentsNames('parents details1', 'none') ?> 324dd6b2bfcSGreg Roach </td> 325dd6b2bfcSGreg Roach 32639ca88baSGreg Roach <td hidden data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', $individual->sortName())) ?>"></td> 327dd6b2bfcSGreg Roach 328242a7862SGreg Roach <td class="text-center" data-sort="<?= $key ?>"> 329dd6b2bfcSGreg Roach <?php if ($sosa) : ?> 33084b37362SGreg Roach <?php if ($module instanceof RelationshipsChartModule) : ?> 33184b37362SGreg Roach <a href="<?= e($module->chartUrl($individuals[1], ['xref2' => $individual->xref()])) ?>" rel="nofollow" title="<?= I18N::translate('Relationships') ?>" rel="nofollow"> 332dd6b2bfcSGreg Roach <?= I18N::number($key) ?> 333dd6b2bfcSGreg Roach </a> 33484b37362SGreg Roach <?php else : ?> 33584b37362SGreg Roach <?= I18N::number($key) ?> 33684b37362SGreg Roach <?php endif ?> 337dd6b2bfcSGreg Roach <?php endif ?> 338dd6b2bfcSGreg Roach </td> 339dd6b2bfcSGreg Roach 340dd6b2bfcSGreg Roach <!-- Birth date --> 341dd6b2bfcSGreg Roach <td data-sort="<?= $individual->getEstimatedBirthDate()->julianDay() ?>"> 342dd6b2bfcSGreg Roach <?php $birth_dates = $individual->getAllBirthDates(); ?> 343dd6b2bfcSGreg Roach 344dd6b2bfcSGreg Roach <?php foreach ($birth_dates as $n => $birth_date) : ?> 345dd6b2bfcSGreg Roach <?= $birth_date->display(true) ?> 346dd6b2bfcSGreg Roach <br> 347dd6b2bfcSGreg Roach <?php endforeach ?> 348dd6b2bfcSGreg Roach </td> 349dd6b2bfcSGreg Roach 350dd6b2bfcSGreg Roach <!-- Birth anniversary --> 351242a7862SGreg Roach <td class="text-center" data-sort="<?= -$individual->getEstimatedBirthDate()->julianDay() ?>"> 352c0935879SGreg Roach <?php if (isset($birth_dates[0]) && $birth_dates[0]->gregorianYear() >= 1550 && $birth_dates[0]->gregorianYear() < 2030 && !isset($unique_indis[$individual->xref()])) : ?> 353*1b860509SRico Sonntag <?php 354*1b860509SRico Sonntag ++$birt_by_decade[(int) ($birth_dates[0]->gregorianYear() / 10) * 10][$individual->sex()]; 355*1b860509SRico Sonntag ?> 356*1b860509SRico Sonntag <?= Date::getAge($birth_dates[0]) ?> 357dd6b2bfcSGreg Roach <?php endif ?> 358dd6b2bfcSGreg Roach </td> 359dd6b2bfcSGreg Roach 360dd6b2bfcSGreg Roach <!-- Birth place --> 361dd6b2bfcSGreg Roach <td> 362dd6b2bfcSGreg Roach <?php foreach ($individual->getAllBirthPlaces() as $n => $birth_place) : ?> 363392561bbSGreg Roach <?= $birth_place->shortName(true) ?> 364dd6b2bfcSGreg Roach <br> 365dd6b2bfcSGreg Roach <?php endforeach ?> 366dd6b2bfcSGreg Roach </td> 367dd6b2bfcSGreg Roach 368dd6b2bfcSGreg Roach <!-- Number of children --> 36939ca88baSGreg Roach <td class="text-center" data-sort="<?= $individual->numberOfChildren() ?>"> 37039ca88baSGreg Roach <?= I18N::number($individual->numberOfChildren()) ?> 371dd6b2bfcSGreg Roach </td> 372dd6b2bfcSGreg Roach 373dd6b2bfcSGreg Roach <!-- Death date --> 374dd6b2bfcSGreg Roach <?php $death_dates = $individual->getAllDeathDates() ?> 375dd6b2bfcSGreg Roach <td data-sort="<?= $individual->getEstimatedDeathDate()->julianDay() ?>"> 376dd6b2bfcSGreg Roach <?php foreach ($death_dates as $num => $death_date) : ?> 377dd6b2bfcSGreg Roach <?= $death_date->display(true) ?> 378dd6b2bfcSGreg Roach <br> 379dd6b2bfcSGreg Roach <?php endforeach ?> 380dd6b2bfcSGreg Roach </td> 381dd6b2bfcSGreg Roach 382dd6b2bfcSGreg Roach <!-- Death anniversary --> 383242a7862SGreg Roach <td class="text-center" data-sort="<?= -$individual->getEstimatedDeathDate()->julianDay() ?>"> 384c0935879SGreg Roach <?php if (isset($death_dates[0]) && $death_dates[0]->gregorianYear() >= 1550 && $death_dates[0]->gregorianYear() < 2030 && !isset($unique_indis[$individual->xref()])) : ?> 385*1b860509SRico Sonntag <?php 386*1b860509SRico Sonntag ++$deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10][$individual->sex()]; 387*1b860509SRico Sonntag ?> 388*1b860509SRico Sonntag <?= Date::getAge($death_dates[0]) ?> 389dd6b2bfcSGreg Roach <?php endif ?> 390dd6b2bfcSGreg Roach </td> 391dd6b2bfcSGreg Roach 392dd6b2bfcSGreg Roach <!-- Age at death --> 393dd6b2bfcSGreg Roach <?php if (isset($birth_dates[0]) && isset($death_dates[0])) : ?> 394dd6b2bfcSGreg Roach <?php $age_at_death = I18N::number((int) Date::getAgeYears($birth_dates[0], $death_dates[0])); ?> 395dd6b2bfcSGreg Roach <?php $age_at_death_sort = Date::getAge($birth_dates[0], $death_dates[0]); ?> 396c0935879SGreg Roach <?php if (!isset($unique_indis[$individual->xref()]) && $age_at_death >= 0 && $age_at_death <= $max_age) : ?> 397*1b860509SRico Sonntag <?php 398*1b860509SRico Sonntag ++$deat_by_age[$age_at_death][$individual->sex()]; 399*1b860509SRico Sonntag ?> 400dd6b2bfcSGreg Roach <?php endif ?> 401dd6b2bfcSGreg Roach <?php else : ?> 402dd6b2bfcSGreg Roach <?php $age_at_death = ''; ?> 403dd6b2bfcSGreg Roach <?php $age_at_death_sort = PHP_INT_MAX; ?> 404dd6b2bfcSGreg Roach <?php endif ?> 405242a7862SGreg Roach <td class="text-center" data-sort="<?= e($age_at_death_sort) ?>"> 406dd6b2bfcSGreg Roach <?= e($age_at_death) ?> 407dd6b2bfcSGreg Roach </td> 408dd6b2bfcSGreg Roach 409dd6b2bfcSGreg Roach <!-- Death place --> 410dd6b2bfcSGreg Roach <td> 411dd6b2bfcSGreg Roach <?php foreach ($individual->getAllDeathPlaces() as $n => $death_place) : ?> 412392561bbSGreg Roach <?= $death_place->shortName(true) ?> 413dd6b2bfcSGreg Roach <br> 414dd6b2bfcSGreg Roach <?php endforeach ?> 415dd6b2bfcSGreg Roach </td> 416dd6b2bfcSGreg Roach 417dd6b2bfcSGreg Roach <!-- Last change --> 418dd6b2bfcSGreg Roach <td data-sort="<?= $individual->lastChangeTimestamp(true) ?>"> 419dd6b2bfcSGreg Roach <?= $individual->lastChangeTimestamp() ?> 420dd6b2bfcSGreg Roach </td> 421dd6b2bfcSGreg Roach 422dd6b2bfcSGreg Roach <!-- Filter by sex --> 423dd6b2bfcSGreg Roach <td hidden> 42439ca88baSGreg Roach <?= $individual->sex() ?> 425dd6b2bfcSGreg Roach </td> 426dd6b2bfcSGreg Roach 427dd6b2bfcSGreg Roach <!-- Filter by birth date --> 428dd6b2bfcSGreg Roach <td hidden> 429dd6b2bfcSGreg Roach <?php if (!$individual->canShow() || Date::compare($individual->getEstimatedBirthDate(), $hundred_years_ago) > 0) : ?> 430dd6b2bfcSGreg Roach Y100 431dd6b2bfcSGreg Roach <?php else : ?> 432dd6b2bfcSGreg Roach YES 433dd6b2bfcSGreg Roach <?php endif ?> 434dd6b2bfcSGreg Roach </td> 435dd6b2bfcSGreg Roach 436dd6b2bfcSGreg Roach <!-- Filter by death date --> 437dd6b2bfcSGreg Roach <td hidden> 438dd6b2bfcSGreg Roach <?php if (isset($death_dates[0]) && Date::compare($death_dates[0], $hundred_years_ago) > 0) : ?> 439dd6b2bfcSGreg Roach Y100 440dd6b2bfcSGreg Roach <?php elseif ($individual->isDead()) : ?> 441dd6b2bfcSGreg Roach YES 442dd6b2bfcSGreg Roach <?php else : ?> 443dd6b2bfcSGreg Roach N 444dd6b2bfcSGreg Roach <?php endif ?> 445dd6b2bfcSGreg Roach </td> 446dd6b2bfcSGreg Roach 447dd6b2bfcSGreg Roach <!-- Filter by roots/leaves --> 448dd6b2bfcSGreg Roach <td hidden> 44939ca88baSGreg Roach <?php if (!$individual->childFamilies()) : ?> 450dd6b2bfcSGreg Roach R 45139ca88baSGreg Roach <?php elseif (!$individual->isDead() && $individual->numberOfChildren() < 1) : ?> 452dd6b2bfcSGreg Roach L 453dd6b2bfcSGreg Roach <?php endif ?> 454dd6b2bfcSGreg Roach </td> 455dd6b2bfcSGreg Roach </tr> 456dd6b2bfcSGreg Roach 457c0935879SGreg Roach <?php $unique_indis[$individual->xref()] = true ?> 458dd6b2bfcSGreg Roach <?php endforeach ?> 459dd6b2bfcSGreg Roach </tbody> 460dd6b2bfcSGreg Roach </table> 461*1b860509SRico Sonntag</div> 462dd6b2bfcSGreg Roach 463*1b860509SRico Sonntag<div id="individual-charts-<?= e($table_id) ?>" style="display: none;"> 464*1b860509SRico Sonntag <div class="mb-3"> 465*1b860509SRico Sonntag <div class="card-deck"> 466*1b860509SRico Sonntag <div class="col-lg-12 col-md-12 mb-3"> 467*1b860509SRico Sonntag <div class="card m-0"> 468*1b860509SRico Sonntag <div class="card-header"> 469*1b860509SRico Sonntag <?= I18N::translate('Decade of birth') ?> 470*1b860509SRico Sonntag </div> 471*1b860509SRico Sonntag <div class="card-body"> 472*1b860509SRico Sonntag <?php 473*1b860509SRico Sonntag foreach ($birt_by_decade as $century => $values) { 474*1b860509SRico Sonntag if (($values['M'] + $values['F']) > 0) { 475*1b860509SRico Sonntag $birthData[] = [ 476*1b860509SRico Sonntag [ 477*1b860509SRico Sonntag 'v' => 'Date(' . $century . ', 0, 1)', 478*1b860509SRico Sonntag 'f' => $century, 479*1b860509SRico Sonntag ], 480*1b860509SRico Sonntag $values['M'], 481*1b860509SRico Sonntag $values['F'], 482*1b860509SRico Sonntag ]; 483*1b860509SRico Sonntag } 484*1b860509SRico Sonntag } 485*1b860509SRico Sonntag ?> 486*1b860509SRico Sonntag <?= view('lists/chart-by-decade', ['data' => $birthData, 'title' => I18N::translate('Decade of birth')]) ?> 487*1b860509SRico Sonntag </div> 488*1b860509SRico Sonntag </div> 489*1b860509SRico Sonntag </div> 490*1b860509SRico Sonntag </div> 491*1b860509SRico Sonntag <div class="card-deck"> 492*1b860509SRico Sonntag <div class="col-lg-12 col-md-12 mb-3"> 493*1b860509SRico Sonntag <div class="card m-0"> 494*1b860509SRico Sonntag <div class="card-header"> 495*1b860509SRico Sonntag <?= I18N::translate('Decade of death') ?> 496*1b860509SRico Sonntag </div> 497*1b860509SRico Sonntag <div class="card-body"> 498*1b860509SRico Sonntag <?php 499*1b860509SRico Sonntag foreach ($deat_by_decade as $century => $values) { 500*1b860509SRico Sonntag if (($values['M'] + $values['F']) > 0) { 501*1b860509SRico Sonntag $deathData[] = [ 502*1b860509SRico Sonntag [ 503*1b860509SRico Sonntag 'v' => 'Date(' . $century . ', 0, 1)', 504*1b860509SRico Sonntag 'f' => $century, 505*1b860509SRico Sonntag ], 506*1b860509SRico Sonntag $values['M'], 507*1b860509SRico Sonntag $values['F'], 508*1b860509SRico Sonntag ]; 509*1b860509SRico Sonntag } 510*1b860509SRico Sonntag } 511*1b860509SRico Sonntag ?> 512*1b860509SRico Sonntag <?= view('lists/chart-by-decade', ['data' => $deathData, 'title' => I18N::translate('Decade of death')]) ?> 513*1b860509SRico Sonntag </div> 514*1b860509SRico Sonntag </div> 515*1b860509SRico Sonntag </div> 516*1b860509SRico Sonntag </div> 517*1b860509SRico Sonntag <div class="card-deck"> 518*1b860509SRico Sonntag <div class="col-lg-12 col-md-12 mb-3"> 519*1b860509SRico Sonntag <div class="card m-0"> 520*1b860509SRico Sonntag <div class="card-header"> 521*1b860509SRico Sonntag <?= I18N::translate('Age related to death year') ?> 522*1b860509SRico Sonntag </div> 523*1b860509SRico Sonntag <div class="card-body"> 524*1b860509SRico Sonntag <?php 525*1b860509SRico Sonntag $totalAge = 0; 526*1b860509SRico Sonntag $totalSum = 0; 527*1b860509SRico Sonntag $max = 0; 528*1b860509SRico Sonntag 529*1b860509SRico Sonntag foreach ($deat_by_age as $age => $values) { 530*1b860509SRico Sonntag if (($values['M'] + $values['F']) > 0) { 531*1b860509SRico Sonntag if (($values['M'] + $values['F']) > $max) { 532*1b860509SRico Sonntag $max = $values['M'] + $values['F']; 533*1b860509SRico Sonntag } 534*1b860509SRico Sonntag 535*1b860509SRico Sonntag $totalAge += $age * ($values['M'] + $values['F']); 536*1b860509SRico Sonntag $totalSum += $values['M'] + $values['F']; 537*1b860509SRico Sonntag 538*1b860509SRico Sonntag $deathAgeData[] = [ 539*1b860509SRico Sonntag $age, 540*1b860509SRico Sonntag $values['M'], 541*1b860509SRico Sonntag $values['F'], 542*1b860509SRico Sonntag null, 543*1b860509SRico Sonntag ]; 544*1b860509SRico Sonntag } 545*1b860509SRico Sonntag } 546*1b860509SRico Sonntag 547*1b860509SRico Sonntag if ($totalSum > 0) { 548*1b860509SRico Sonntag $deathAgeData[] = [ 549*1b860509SRico Sonntag round($totalAge / $totalSum, 1), 550*1b860509SRico Sonntag null, 551*1b860509SRico Sonntag null, 552*1b860509SRico Sonntag 0, 553*1b860509SRico Sonntag ]; 554*1b860509SRico Sonntag 555*1b860509SRico Sonntag $deathAgeData[] = [ 556*1b860509SRico Sonntag round($totalAge / $totalSum, 1), 557*1b860509SRico Sonntag null, 558*1b860509SRico Sonntag null, 559*1b860509SRico Sonntag $max, 560*1b860509SRico Sonntag ]; 561*1b860509SRico Sonntag } 562*1b860509SRico Sonntag ?> 563*1b860509SRico Sonntag <?= view('lists/chart-by-age', ['data' => $deathAgeData, 'title' => I18N::translate('Age related to death year')]) ?> 564*1b860509SRico Sonntag </div> 565*1b860509SRico Sonntag </div> 566*1b860509SRico Sonntag </div> 567*1b860509SRico Sonntag </div> 568dd6b2bfcSGreg Roach </div> 569dd6b2bfcSGreg Roach</div> 570