xref: /webtrees/resources/views/lists/individuals-table.phtml (revision af8b52f0c4b9205fb4ecf76ae5124334fdbcc4b5)
1dd6b2bfcSGreg Roach<?php
2d70512abSGreg Roach
31b860509SRico Sonntagdeclare(strict_types=1);
41b860509SRico Sonntag
51b860509SRico Sonntaguse Fisharebest\Webtrees\Auth;
65373aac2SGreg Roachuse Fisharebest\Webtrees\Carbon;
71b860509SRico Sonntaguse Fisharebest\Webtrees\Date;
81b860509SRico Sonntaguse Fisharebest\Webtrees\GedcomTag;
91b860509SRico Sonntaguse Fisharebest\Webtrees\I18N;
1087cca37cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleChartInterface;
111b860509SRico Sonntaguse Fisharebest\Webtrees\Module\ModuleInterface;
121b860509SRico Sonntaguse Fisharebest\Webtrees\Module\RelationshipsChartModule;
131b860509SRico Sonntaguse Fisharebest\Webtrees\Services\ModuleService;
14b9597e06SGreg Roachuse Fisharebest\Webtrees\Tree;
151b860509SRico Sonntaguse Fisharebest\Webtrees\View;
161b860509SRico Sonntaguse Ramsey\Uuid\Uuid;
171b860509SRico Sonntag
18b9597e06SGreg Roach/**
19b9597e06SGreg Roach * @var Tree $tree
20b9597e06SGreg Roach */
21b9597e06SGreg Roach
22dd6b2bfcSGreg Roach// lists requires a unique ID in case there are multiple lists per page
23dd6b2bfcSGreg Roach$table_id = 'table-indi-' . Uuid::uuid4()->toString();
24dd6b2bfcSGreg Roach
25b9597e06SGreg Roach$today_jd          = Carbon::now()->julianDay();
265373aac2SGreg Roach$hundred_years_ago = Carbon::now()->subYears(100)->julianDay();
271b860509SRico Sonntag
28dd6b2bfcSGreg Roach$unique_indis = []; // Don't double-count indis with multiple names.
2984b37362SGreg Roach
30b2a8cedfSGreg Roach$show_estimated_dates = (bool) $tree->getPreference('SHOW_EST_LIST_DATES');
31b2a8cedfSGreg Roach
321b860509SRico Sonntag$module = app(ModuleService::class)
3387cca37cSGreg Roach    ->findByComponent(ModuleChartInterface::class, $tree, Auth::user())
340b5fd0a6SGreg Roach    ->first(static function (ModuleInterface $module) {
3590d97cc8SGreg Roach        return $module instanceof RelationshipsChartModule;
3690d97cc8SGreg Roach    });
37dd6b2bfcSGreg Roach?>
38dd6b2bfcSGreg Roach
39dd6b2bfcSGreg Roach<?php View::push('javascript') ?>
40dd6b2bfcSGreg Roach<script>
4132a5dd8dSGreg Roach$("#<?= e($table_id) ?> > .wt-table-individual").dataTable({
42dd6b2bfcSGreg Roach    processing: true,
43dd6b2bfcSGreg Roach    retrieve: true,
44dd6b2bfcSGreg Roach    columns: [
45dd6b2bfcSGreg Roach        /* Given names  */ { type: "text" },
46dd6b2bfcSGreg Roach        /* Surnames     */ { type: "text" },
4732a5dd8dSGreg Roach        /* SOSA number  */ { type: "num", visible: <?= json_encode($sosa) ?> },
48dd6b2bfcSGreg Roach        /* Birth date   */ { type: "num" },
49dd6b2bfcSGreg Roach        /* Anniversary  */ { type: "num" },
50dd6b2bfcSGreg Roach        /* Birthplace   */ { type: "text" },
51dd6b2bfcSGreg Roach        /* Children     */ { type: "num" },
52dd6b2bfcSGreg Roach        /* Deate date   */ { type: "num" },
53dd6b2bfcSGreg Roach        /* Anniversary  */ { type: "num" },
54dd6b2bfcSGreg Roach        /* Age          */ { type: "num" },
55dd6b2bfcSGreg Roach        /* Death place  */ { type: "text" },
56dd6b2bfcSGreg Roach        /* Last change  */ { visible: <?= json_encode($tree->getPreference('SHOW_LAST_CHANGE')) ?> },
57dd6b2bfcSGreg Roach        /* Filter sex   */ { sortable: false },
58dd6b2bfcSGreg Roach        /* Filter birth */ { sortable: false },
59dd6b2bfcSGreg Roach        /* Filter death */ { sortable: false },
60dd6b2bfcSGreg Roach        /* Filter tree  */ { sortable: false }
61dd6b2bfcSGreg Roach    ],
62b2c011d7SGreg Roach    sorting: <?= json_encode($sosa ? [[4, 'asc']] : [[1, 'asc']]) ?>
63dd6b2bfcSGreg Roach});
64dd6b2bfcSGreg Roach
65dd6b2bfcSGreg Roach$("#<?= e($table_id) ?>")
66dd6b2bfcSGreg Roach    /* Hide/show parents */
674843b94fSGreg Roach    .on("click", "#btn-toggle-parents", function() {
685e6816beSGreg Roach        $(".wt-individual-list-parents").slideToggle();
69dd6b2bfcSGreg Roach    })
70dd6b2bfcSGreg Roach    /* Hide/show statistics */
714843b94fSGreg Roach    .on("click", "#btn-toggle-statistics", function() {
721b860509SRico Sonntag        $("#individual-charts-<?= e($table_id) ?>").slideToggle({
731b860509SRico Sonntag            complete: function () {
741b860509SRico Sonntag                // Trigger resize to redraw the chart
751b860509SRico Sonntag                $('div[id^="google-chart-"]').resize();
761b860509SRico Sonntag            }
771b860509SRico Sonntag        });
78dd6b2bfcSGreg Roach    })
79dd6b2bfcSGreg Roach    /* Filter buttons in table header */
80604bfd4bSGreg Roach    .on("click", "input[data-filter-column]", function() {
81604bfd4bSGreg Roach        let checkbox = $(this);
82604bfd4bSGreg Roach        let siblings = checkbox.parent().siblings();
831b860509SRico Sonntag
84604bfd4bSGreg Roach        // Deselect other options
85604bfd4bSGreg Roach        siblings.children().prop("checked", false).removeAttr("checked");
86604bfd4bSGreg Roach        siblings.removeClass('active');
87604bfd4bSGreg Roach
88604bfd4bSGreg Roach        // Apply (or clear) this filter
89604bfd4bSGreg Roach        let checked = checkbox.prop("checked");
90604bfd4bSGreg Roach        let filter  = checked ? checkbox.data("filter-value") : "";
9132a5dd8dSGreg Roach        let column  = $("#<?= e($table_id) ?> .wt-table-individual").DataTable().column(checkbox.data("filter-column"));
92604bfd4bSGreg Roach        column.search(filter).draw();
93604bfd4bSGreg Roach    });
94dd6b2bfcSGreg Roach</script>
95dd6b2bfcSGreg Roach<?php View::endpush() ?>
96dd6b2bfcSGreg Roach
97dd6b2bfcSGreg Roach<?php
98dd6b2bfcSGreg Roach$max_age = (int) $tree->getPreference('MAX_ALIVE_AGE');
99dd6b2bfcSGreg Roach
100dd6b2bfcSGreg Roach// Inititialise chart data
101dd6b2bfcSGreg Roach$deat_by_age = [];
102dd6b2bfcSGreg Roachfor ($age = 0; $age <= $max_age; $age++) {
1031b860509SRico Sonntag    $deat_by_age[$age]['M'] = 0;
1041b860509SRico Sonntag    $deat_by_age[$age]['F'] = 0;
1051b860509SRico Sonntag    $deat_by_age[$age]['U'] = 0;
106dd6b2bfcSGreg Roach}
107dd6b2bfcSGreg Roach$birt_by_decade = [];
108dd6b2bfcSGreg Roach$deat_by_decade = [];
1091b860509SRico Sonntagfor ($year = 1400; $year < 2050; $year += 10) {
1101b860509SRico Sonntag    $birt_by_decade[$year]['M'] = 0;
1111b860509SRico Sonntag    $birt_by_decade[$year]['F'] = 0;
1121b860509SRico Sonntag    $birt_by_decade[$year]['U'] = 0;
1131b860509SRico Sonntag    $deat_by_decade[$year]['M'] = 0;
1141b860509SRico Sonntag    $deat_by_decade[$year]['F'] = 0;
1151b860509SRico Sonntag    $deat_by_decade[$year]['U'] = 0;
116dd6b2bfcSGreg Roach}
1171b860509SRico Sonntag
1181b860509SRico Sonntag$birthData = [
1191b860509SRico Sonntag    [
1201b860509SRico Sonntag        [
1211b860509SRico Sonntag            'label' => I18N::translate('Century'),
1221b860509SRico Sonntag            'type'  => 'date',
1231b860509SRico Sonntag        ], [
1241b860509SRico Sonntag            'label' => I18N::translate('Males'),
1251b860509SRico Sonntag            'type'  => 'number',
1261b860509SRico Sonntag        ], [
1271b860509SRico Sonntag            'label' => I18N::translate('Females'),
1281b860509SRico Sonntag            'type'  => 'number',
1291b860509SRico Sonntag        ],
1301b860509SRico Sonntag    ]
1311b860509SRico Sonntag];
1321b860509SRico Sonntag
1331b860509SRico Sonntag$deathData = [
1341b860509SRico Sonntag    [
1351b860509SRico Sonntag        [
1361b860509SRico Sonntag            'label' => I18N::translate('Century'),
1371b860509SRico Sonntag            'type'  => 'date',
1381b860509SRico Sonntag        ], [
1391b860509SRico Sonntag            'label' => I18N::translate('Males'),
1401b860509SRico Sonntag            'type'  => 'number',
1411b860509SRico Sonntag        ], [
1421b860509SRico Sonntag            'label' => I18N::translate('Females'),
1431b860509SRico Sonntag            'type'  => 'number',
1441b860509SRico Sonntag        ],
1451b860509SRico Sonntag    ]
1461b860509SRico Sonntag];
1471b860509SRico Sonntag
1481b860509SRico Sonntag$deathAgeData = [
1491b860509SRico Sonntag    [
1501b860509SRico Sonntag        I18N::translate('Age'),
1511b860509SRico Sonntag        I18N::translate('Males'),
1521b860509SRico Sonntag        I18N::translate('Females'),
1531b860509SRico Sonntag        I18N::translate('Average age'),
1541b860509SRico Sonntag    ]
1551b860509SRico Sonntag];
1561b860509SRico Sonntag
157dd6b2bfcSGreg Roach?>
158dd6b2bfcSGreg Roach
15932a5dd8dSGreg Roach<div id="<?= e($table_id) ?>">
16032a5dd8dSGreg Roach    <table class="table table-bordered table-sm wt-table-individual"
161b6c326d8SGreg Roach        <?= view('lists/datatables-attributes') ?>
162b6c326d8SGreg Roach    >
163dd6b2bfcSGreg Roach        <thead>
164dd6b2bfcSGreg Roach            <tr>
165dd6b2bfcSGreg Roach                <th colspan="16">
166dd6b2bfcSGreg Roach                    <div class="btn-toolbar d-flex justify-content-between mb-2" role="toolbar">
167604bfd4bSGreg Roach                        <div class="btn-group btn-group-toggle btn-group-sm" data-toggle="buttons">
168*af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show only males.') ?>">
169604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="12" data-filter-value="M">
17008362db4SGreg Roach                                <?= view('icons/sex', ['sex' => 'M']) ?>
171604bfd4bSGreg Roach                            </label>
172*af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show only females.') ?>">
173604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="12" data-filter-value="F">
17408362db4SGreg Roach                                <?= view('icons/sex', ['sex' => 'F']) ?>
175604bfd4bSGreg Roach                            </label>
176*af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show only individuals for whom the gender is not known.') ?>">
177604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="12" data-filter-value="U">
17808362db4SGreg Roach                                <?= view('icons/sex', ['sex' => 'U']) ?>
179604bfd4bSGreg Roach                            </label>
180dd6b2bfcSGreg Roach                        </div>
181604bfd4bSGreg Roach
182604bfd4bSGreg Roach                        <div class="btn-group btn-group-toggle btn-group-sm" data-toggle="buttons">
183*af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals who are alive or couples where both partners are alive.') ?>">
184604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="14" data-filter-value="N">
185dd6b2bfcSGreg Roach                                <?= I18N::translate('Alive') ?>
186604bfd4bSGreg Roach                            </label>
187*af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals who are dead or couples where both partners are dead.') ?>">
188604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="14" data-filter-value="Y">
189dd6b2bfcSGreg Roach                                <?= I18N::translate('Dead') ?>
190604bfd4bSGreg Roach                            </label>
191*af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals who died more than 100 years ago.') ?>">
192604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="14" data-filter-value="YES">
193dd6b2bfcSGreg Roach                                <?= I18N::translate('Death') ?>&gt;100
194604bfd4bSGreg Roach                            </label>
195*af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals who died within the last 100 years.') ?>">
196604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="14" data-filter-value="Y100">
197392561bbSGreg Roach                                <?= I18N::translate('Death') ?>&lt;=100
198604bfd4bSGreg Roach                            </label>
199dd6b2bfcSGreg Roach                        </div>
200604bfd4bSGreg Roach
201604bfd4bSGreg Roach                        <div class="btn-group btn-group-toggle btn-group-sm" data-toggle="buttons">
202*af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals born more than 100 years ago.') ?>">
203604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="13" data-filter-value="YES">
204dd6b2bfcSGreg Roach                                <?= I18N::translate('Birth') ?>&gt;100
205604bfd4bSGreg Roach                            </label>
206*af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals born within the last 100 years.') ?>">
207604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="13" data-filter-value="Y100">
208dd6b2bfcSGreg Roach                                <?= I18N::translate('Birth') ?>&lt;=100
209604bfd4bSGreg Roach                            </label>
210dd6b2bfcSGreg Roach                        </div>
211604bfd4bSGreg Roach
212604bfd4bSGreg Roach                        <div class="btn-group btn-group-toggle btn-group-sm" data-toggle="buttons">
213*af8b52f0SGreg Roach                            <label 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.') ?>">
214604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="15" data-filter-value="R">
215dd6b2bfcSGreg Roach                                <?= I18N::translate('Roots') ?>
216604bfd4bSGreg Roach                            </label>
217*af8b52f0SGreg Roach                            <label 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.') ?>">
218604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="15" data-filter-value="L">
219dd6b2bfcSGreg Roach                                <?= I18N::translate('Leaves') ?>
220604bfd4bSGreg Roach                            </label>
221dd6b2bfcSGreg Roach                        </div>
222dd6b2bfcSGreg Roach                    </div>
223dd6b2bfcSGreg Roach                </th>
224dd6b2bfcSGreg Roach            </tr>
225dd6b2bfcSGreg Roach            <tr>
226dd6b2bfcSGreg Roach                <th><?= I18N::translate('Given names') ?></th>
227dd6b2bfcSGreg Roach                <th><?= I18N::translate('Surname') ?></th>
228dd6b2bfcSGreg Roach                <th><?= /* I18N: Abbreviation for “Sosa-Stradonitz number”. This is an individual’s surname, so may need transliterating into non-latin alphabets. */
229dd6b2bfcSGreg Roach                    I18N::translate('Sosa') ?></th>
230dd6b2bfcSGreg Roach                <th><?= I18N::translate('Birth') ?></th>
231dd6b2bfcSGreg Roach                <th>
232e39fd5c6SGreg Roach                    <span title="<?= I18N::translate('Anniversary') ?>">
233e39fd5c6SGreg Roach                        <?= view('icons/anniversary') ?>
234e39fd5c6SGreg Roach                    </span>
235dd6b2bfcSGreg Roach                </th>
236dd6b2bfcSGreg Roach                <th><?= I18N::translate('Place') ?></th>
237dd6b2bfcSGreg Roach                <th>
238dd6b2bfcSGreg Roach                    <i class="icon-children" title="<?= I18N::translate('Children') ?>"></i>
239dd6b2bfcSGreg Roach                </th>
240dd6b2bfcSGreg Roach                <th><?= I18N::translate('Death') ?></th>
241dd6b2bfcSGreg Roach                <th>
242e39fd5c6SGreg Roach                    <span title="<?= I18N::translate('Anniversary') ?>">
243e39fd5c6SGreg Roach                        <?= view('icons/anniversary') ?>
244e39fd5c6SGreg Roach                    </span>
245dd6b2bfcSGreg Roach                </th>
246dd6b2bfcSGreg Roach                <th><?= I18N::translate('Age') ?></th>
247dd6b2bfcSGreg Roach                <th><?= I18N::translate('Place') ?></th>
248dd6b2bfcSGreg Roach                <th><?= I18N::translate('Last change') ?></th>
249dd6b2bfcSGreg Roach                <th hidden></th>
250dd6b2bfcSGreg Roach                <th hidden></th>
251dd6b2bfcSGreg Roach                <th hidden></th>
252dd6b2bfcSGreg Roach                <th hidden></th>
253dd6b2bfcSGreg Roach            </tr>
254dd6b2bfcSGreg Roach        </thead>
255dd6b2bfcSGreg Roach
256dd6b2bfcSGreg Roach        <tbody>
257dd6b2bfcSGreg Roach            <?php foreach ($individuals as $key => $individual) : ?>
25817dd427eSGreg Roach            <tr class="<?= $individual->isPendingDeletion() ? 'wt-old' : ($individual->isPendingAddition() ? 'wt-new' : '') ?>">
25939ca88baSGreg Roach                <td colspan="2" data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', implode(',', array_reverse(explode(',', $individual->sortName()))))) ?>">
260dd6b2bfcSGreg Roach                    <?php foreach ($individual->getAllNames() as $num => $name) : ?>
261e840bf40SGreg Roach                        <a title="<?= $name['type'] === 'NAME' ? '' : strip_tags(GedcomTag::getLabel($name['type'], $individual)) ?>" href="<?= e($individual->url()) ?>" class="<?= $num === $individual->getPrimaryName() ? 'name2' : '' ?>">
262dd6b2bfcSGreg Roach                            <?= $name['full'] ?>
263dd6b2bfcSGreg Roach                        </a>
264dd6b2bfcSGreg Roach                        <?php if ($num === $individual->getPrimaryName()) : ?>
26508362db4SGreg Roach                            <small><?= view('icons/sex', ['sex' => $individual->sex()]) ?></small>
266dd6b2bfcSGreg Roach                        <?php endif ?>
267dd6b2bfcSGreg Roach                        <br>
268dd6b2bfcSGreg Roach                    <?php endforeach ?>
2695e6816beSGreg Roach                    <?= view('lists/individual-table-parents', ['individual' => $individual]) ?>
270dd6b2bfcSGreg Roach                </td>
271dd6b2bfcSGreg Roach
27239ca88baSGreg Roach                <td hidden data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', $individual->sortName())) ?>"></td>
273dd6b2bfcSGreg Roach
274242a7862SGreg Roach                <td class="text-center" data-sort="<?= $key ?>">
275dd6b2bfcSGreg Roach                    <?php if ($sosa) : ?>
27684b37362SGreg Roach                        <?php if ($module instanceof RelationshipsChartModule) : ?>
27784b37362SGreg Roach                            <a href="<?= e($module->chartUrl($individuals[1], ['xref2' => $individual->xref()])) ?>" rel="nofollow" title="<?= I18N::translate('Relationships') ?>" rel="nofollow">
278dd6b2bfcSGreg Roach                                <?= I18N::number($key) ?>
279dd6b2bfcSGreg Roach                            </a>
28084b37362SGreg Roach                        <?php else : ?>
28184b37362SGreg Roach                            <?= I18N::number($key) ?>
28284b37362SGreg Roach                        <?php endif ?>
283dd6b2bfcSGreg Roach                    <?php endif ?>
284dd6b2bfcSGreg Roach                </td>
285dd6b2bfcSGreg Roach
286dd6b2bfcSGreg Roach                <!-- Birth date -->
287dd6b2bfcSGreg Roach                <td data-sort="<?= $individual->getEstimatedBirthDate()->julianDay() ?>">
288dd6b2bfcSGreg Roach                    <?php $birth_dates = $individual->getAllBirthDates(); ?>
289dd6b2bfcSGreg Roach
290dd6b2bfcSGreg Roach                    <?php foreach ($birth_dates as $n => $birth_date) : ?>
291dd6b2bfcSGreg Roach                        <?= $birth_date->display(true) ?>
292dd6b2bfcSGreg Roach                        <br>
293dd6b2bfcSGreg Roach                    <?php endforeach ?>
29414147f6fSGreg Roach
295b2a8cedfSGreg Roach                    <?php if (empty($birth_dates) && $show_estimated_dates) : ?>
29614147f6fSGreg Roach                        <?= $individual->getEstimatedBirthDate()->display(true) ?>
29714147f6fSGreg Roach                    <?php endif ?>
298dd6b2bfcSGreg Roach                </td>
299dd6b2bfcSGreg Roach
300dd6b2bfcSGreg Roach                <!-- Birth anniversary -->
301242a7862SGreg Roach                <td class="text-center" data-sort="<?= - $individual->getEstimatedBirthDate()->julianDay() ?>">
302c0935879SGreg Roach                    <?php if (isset($birth_dates[0]) && $birth_dates[0]->gregorianYear() >= 1550 && $birth_dates[0]->gregorianYear() < 2030 && !isset($unique_indis[$individual->xref()])) : ?>
3031b860509SRico Sonntag                        <?php
3041b860509SRico Sonntag                            ++$birt_by_decade[(int) ($birth_dates[0]->gregorianYear() / 10) * 10][$individual->sex()];
3051b860509SRico Sonntag                        ?>
3061b860509SRico Sonntag                        <?= Date::getAge($birth_dates[0]) ?>
307dd6b2bfcSGreg Roach                    <?php endif ?>
308dd6b2bfcSGreg Roach                </td>
309dd6b2bfcSGreg Roach
310dd6b2bfcSGreg Roach                <!-- Birth place -->
311dd6b2bfcSGreg Roach                <td>
312dd6b2bfcSGreg Roach                    <?php foreach ($individual->getAllBirthPlaces() as $n => $birth_place) : ?>
313392561bbSGreg Roach                        <?= $birth_place->shortName(true) ?>
314dd6b2bfcSGreg Roach                        <br>
315dd6b2bfcSGreg Roach                    <?php endforeach ?>
316dd6b2bfcSGreg Roach                </td>
317dd6b2bfcSGreg Roach
318dd6b2bfcSGreg Roach                <!-- Number of children -->
31939ca88baSGreg Roach                <td class="text-center" data-sort="<?= $individual->numberOfChildren() ?>">
32039ca88baSGreg Roach                    <?= I18N::number($individual->numberOfChildren()) ?>
321dd6b2bfcSGreg Roach                </td>
322dd6b2bfcSGreg Roach
323dd6b2bfcSGreg Roach                <!--    Death date -->
324dd6b2bfcSGreg Roach                <?php $death_dates = $individual->getAllDeathDates() ?>
325dd6b2bfcSGreg Roach                <td data-sort="<?= $individual->getEstimatedDeathDate()->julianDay() ?>">
326dd6b2bfcSGreg Roach                    <?php foreach ($death_dates as $num => $death_date) : ?>
327dd6b2bfcSGreg Roach                        <?= $death_date->display(true) ?>
328dd6b2bfcSGreg Roach                    <br>
329dd6b2bfcSGreg Roach                    <?php endforeach ?>
33014147f6fSGreg Roach
331b2a8cedfSGreg Roach                    <?php if (empty($death_dates) && $show_estimated_dates && $individual->getEstimatedDeathDate()->minimumDate()->minimumJulianDay() < $today_jd) : ?>
33214147f6fSGreg Roach                        <?= $individual->getEstimatedDeathDate()->display(true) ?>
33314147f6fSGreg Roach                    <?php endif ?>
334dd6b2bfcSGreg Roach                </td>
335dd6b2bfcSGreg Roach
336dd6b2bfcSGreg Roach                <!-- Death anniversary -->
337242a7862SGreg Roach                <td class="text-center" data-sort="<?= - $individual->getEstimatedDeathDate()->julianDay() ?>">
338c0935879SGreg Roach                    <?php if (isset($death_dates[0]) && $death_dates[0]->gregorianYear() >= 1550 && $death_dates[0]->gregorianYear() < 2030 && !isset($unique_indis[$individual->xref()])) : ?>
3391b860509SRico Sonntag                        <?php
3401b860509SRico Sonntag                            ++$deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10][$individual->sex()];
3411b860509SRico Sonntag                        ?>
3421b860509SRico Sonntag                        <?= Date::getAge($death_dates[0]) ?>
343dd6b2bfcSGreg Roach                    <?php endif ?>
344dd6b2bfcSGreg Roach                </td>
345dd6b2bfcSGreg Roach
346dd6b2bfcSGreg Roach                <!-- Age at death -->
3473cfcc809SGreg Roach                <?php if (isset($birth_dates[0], $death_dates[0])) : ?>
34857ab2231SGreg Roach                    <?php $age_at_death_years = Date::getAgeYears($birth_dates[0], $death_dates[0]); ?>
349dd6b2bfcSGreg Roach                    <?php $age_at_death_sort = Date::getAge($birth_dates[0], $death_dates[0]); ?>
3504e96702fSGreg Roach                    <?php $age_at_death_display = I18N::number($age_at_death_years); ?>
3514e96702fSGreg Roach                    <?php if (!isset($unique_indis[$individual->xref()]) && $age_at_death_years >= 0 && $age_at_death_years <= $max_age) : ?>
3521b860509SRico Sonntag                        <?php
3534e96702fSGreg Roach                            ++$deat_by_age[$age_at_death_years][$individual->sex()];
3541b860509SRico Sonntag                        ?>
355dd6b2bfcSGreg Roach                    <?php endif ?>
356dd6b2bfcSGreg Roach                <?php else : ?>
3574e96702fSGreg Roach                    <?php $age_at_death_display = ''; ?>
358dd6b2bfcSGreg Roach                    <?php $age_at_death_sort = PHP_INT_MAX; ?>
359dd6b2bfcSGreg Roach                <?php endif ?>
360242a7862SGreg Roach                <td class="text-center" data-sort="<?= e($age_at_death_sort) ?>">
3614e96702fSGreg Roach                    <?= e($age_at_death_display) ?>
362dd6b2bfcSGreg Roach                </td>
363dd6b2bfcSGreg Roach
364dd6b2bfcSGreg Roach                <!-- Death place -->
365dd6b2bfcSGreg Roach                <td>
366dd6b2bfcSGreg Roach                    <?php foreach ($individual->getAllDeathPlaces() as $n => $death_place) : ?>
367392561bbSGreg Roach                        <?= $death_place->shortName(true) ?>
368dd6b2bfcSGreg Roach                        <br>
369dd6b2bfcSGreg Roach                    <?php endforeach ?>
370dd6b2bfcSGreg Roach                </td>
371dd6b2bfcSGreg Roach
372dd6b2bfcSGreg Roach                <!-- Last change -->
3734459dc9aSGreg Roach                <td data-sort="<?= $individual->lastChangeTimestamp()->unix() ?>">
3744459dc9aSGreg Roach                    <?= view('components/datetime', ['timestamp' => $individual->lastChangeTimestamp()]) ?>
375dd6b2bfcSGreg Roach                </td>
376dd6b2bfcSGreg Roach
377dd6b2bfcSGreg Roach                <!-- Filter by sex -->
378dd6b2bfcSGreg Roach                <td hidden>
37939ca88baSGreg Roach                    <?= $individual->sex() ?>
380dd6b2bfcSGreg Roach                </td>
381dd6b2bfcSGreg Roach
382dd6b2bfcSGreg Roach                <!-- Filter by birth date -->
383dd6b2bfcSGreg Roach                <td hidden>
384b9597e06SGreg Roach                    <?php if ($individual->getEstimatedBirthDate()->maximumJulianDay() > $hundred_years_ago && $individual->getEstimatedBirthDate()->maximumJulianDay() <= $today_jd) : ?>
385dd6b2bfcSGreg Roach                        Y100
386dd6b2bfcSGreg Roach                    <?php else : ?>
387dd6b2bfcSGreg Roach                        YES
388dd6b2bfcSGreg Roach                    <?php endif ?>
389dd6b2bfcSGreg Roach                </td>
390dd6b2bfcSGreg Roach
391dd6b2bfcSGreg Roach                <!-- Filter by death date -->
392dd6b2bfcSGreg Roach                <td hidden>
393b9597e06SGreg Roach                    <?php if ($individual->getEstimatedDeathDate()->maximumJulianDay() > $hundred_years_ago && $individual->getEstimatedDeathDate()->maximumJulianDay() <= $today_jd) : ?>
394dd6b2bfcSGreg Roach                        Y100
395dd6b2bfcSGreg Roach                    <?php elseif ($individual->isDead()) : ?>
396dd6b2bfcSGreg Roach                        YES
397dd6b2bfcSGreg Roach                    <?php else : ?>
398dd6b2bfcSGreg Roach                        N
399dd6b2bfcSGreg Roach                    <?php endif ?>
400dd6b2bfcSGreg Roach                </td>
401dd6b2bfcSGreg Roach
402dd6b2bfcSGreg Roach                <!-- Filter by roots/leaves -->
403dd6b2bfcSGreg Roach                <td hidden>
40408662657SGreg Roach                    <?php if ($individual->childFamilies()->isEmpty()) : ?>
405dd6b2bfcSGreg Roach                        R
40639ca88baSGreg Roach                    <?php elseif (!$individual->isDead() && $individual->numberOfChildren() < 1) : ?>
407dd6b2bfcSGreg Roach                        L
408dd6b2bfcSGreg Roach                    <?php endif ?>
409dd6b2bfcSGreg Roach                </td>
410dd6b2bfcSGreg Roach            </tr>
411dd6b2bfcSGreg Roach
412c0935879SGreg Roach                <?php $unique_indis[$individual->xref()] = true ?>
413dd6b2bfcSGreg Roach            <?php endforeach ?>
414dd6b2bfcSGreg Roach        </tbody>
4157039fd97SGreg Roach
4167039fd97SGreg Roach        <tfoot>
4177039fd97SGreg Roach            <tr>
4187039fd97SGreg Roach                <th colspan="16">
419604bfd4bSGreg Roach                    <div class="btn-group btn-group-sm">
420*af8b52f0SGreg Roach                        <button id="btn-toggle-parents" class="btn btn-outline-secondary" data-toggle="button" data-persist="show-parents">
4217039fd97SGreg Roach                            <?= I18N::translate('Show parents') ?>
4227039fd97SGreg Roach                        </button>
423*af8b52f0SGreg Roach                        <button id="btn-toggle-statistics" class="btn btn-outline-secondary" data-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="individual-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>
4411b860509SRico Sonntag                    <div class="card-body">
4421b860509SRico Sonntag                        <?php
4431b860509SRico Sonntag                        foreach ($birt_by_decade as $century => $values) {
4441b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
4451b860509SRico Sonntag                                $birthData[] = [
4461b860509SRico Sonntag                                    [
4471b860509SRico Sonntag                                        'v' => 'Date(' . $century . ', 0, 1)',
4481b860509SRico Sonntag                                        'f' => $century,
4491b860509SRico Sonntag                                    ],
4501b860509SRico Sonntag                                    $values['M'],
4511b860509SRico Sonntag                                    $values['F'],
4521b860509SRico Sonntag                                ];
4531b860509SRico Sonntag                            }
4541b860509SRico Sonntag                        }
4551b860509SRico Sonntag                        ?>
4561b860509SRico Sonntag                        <?= view('lists/chart-by-decade', ['data' => $birthData, 'title' => I18N::translate('Decade of birth')]) ?>
4571b860509SRico Sonntag                    </div>
4581b860509SRico Sonntag                </div>
4591b860509SRico Sonntag            </div>
4601b860509SRico Sonntag        </div>
4611b860509SRico Sonntag        <div class="card-deck">
4621b860509SRico Sonntag            <div class="col-lg-12 col-md-12 mb-3">
4631b860509SRico Sonntag                <div class="card m-0">
4641b860509SRico Sonntag                    <div class="card-header">
4651b860509SRico Sonntag                        <?= I18N::translate('Decade of death') ?>
4661b860509SRico Sonntag                    </div>
4671b860509SRico Sonntag                    <div class="card-body">
4681b860509SRico Sonntag                        <?php
4691b860509SRico Sonntag                        foreach ($deat_by_decade as $century => $values) {
4701b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
4711b860509SRico Sonntag                                $deathData[] = [
4721b860509SRico Sonntag                                    [
4731b860509SRico Sonntag                                        'v' => 'Date(' . $century . ', 0, 1)',
4741b860509SRico Sonntag                                        'f' => $century,
4751b860509SRico Sonntag                                    ],
4761b860509SRico Sonntag                                    $values['M'],
4771b860509SRico Sonntag                                    $values['F'],
4781b860509SRico Sonntag                                ];
4791b860509SRico Sonntag                            }
4801b860509SRico Sonntag                        }
4811b860509SRico Sonntag                        ?>
4821b860509SRico Sonntag                        <?= view('lists/chart-by-decade', ['data' => $deathData, 'title' => I18N::translate('Decade of death')]) ?>
4831b860509SRico Sonntag                    </div>
4841b860509SRico Sonntag                </div>
4851b860509SRico Sonntag            </div>
4861b860509SRico Sonntag        </div>
4871b860509SRico Sonntag        <div class="card-deck">
4881b860509SRico Sonntag            <div class="col-lg-12 col-md-12 mb-3">
4891b860509SRico Sonntag                <div class="card m-0">
4901b860509SRico Sonntag                    <div class="card-header">
4911b860509SRico Sonntag                        <?= I18N::translate('Age related to death year') ?>
4921b860509SRico Sonntag                    </div>
4931b860509SRico Sonntag                    <div class="card-body">
4941b860509SRico Sonntag                        <?php
4951b860509SRico Sonntag                            $totalAge = 0;
4961b860509SRico Sonntag                            $totalSum = 0;
4971b860509SRico Sonntag                            $max      = 0;
4981b860509SRico Sonntag
4991b860509SRico Sonntag                        foreach ($deat_by_age as $age => $values) {
5001b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
5011b860509SRico Sonntag                                if (($values['M'] + $values['F']) > $max) {
5021b860509SRico Sonntag                                    $max = $values['M'] + $values['F'];
5031b860509SRico Sonntag                                }
5041b860509SRico Sonntag
5051b860509SRico Sonntag                                $totalAge += $age * ($values['M'] + $values['F']);
5061b860509SRico Sonntag                                $totalSum += $values['M'] + $values['F'];
5071b860509SRico Sonntag
5081b860509SRico Sonntag                                $deathAgeData[] = [
5091b860509SRico Sonntag                                    $age,
5101b860509SRico Sonntag                                    $values['M'],
5111b860509SRico Sonntag                                    $values['F'],
5121b860509SRico Sonntag                                    null,
5131b860509SRico Sonntag                                ];
5141b860509SRico Sonntag                            }
5151b860509SRico Sonntag                        }
5161b860509SRico Sonntag
5171b860509SRico Sonntag                        if ($totalSum > 0) {
5181b860509SRico Sonntag                            $deathAgeData[] = [
5191b860509SRico Sonntag                                round($totalAge / $totalSum, 1),
5201b860509SRico Sonntag                                null,
5211b860509SRico Sonntag                                null,
5221b860509SRico Sonntag                                0,
5231b860509SRico Sonntag                            ];
5241b860509SRico Sonntag
5251b860509SRico Sonntag                            $deathAgeData[] = [
5261b860509SRico Sonntag                                round($totalAge / $totalSum, 1),
5271b860509SRico Sonntag                                null,
5281b860509SRico Sonntag                                null,
5291b860509SRico Sonntag                                $max,
5301b860509SRico Sonntag                            ];
5311b860509SRico Sonntag                        }
5321b860509SRico Sonntag                        ?>
5331b860509SRico Sonntag                        <?= view('lists/chart-by-age', ['data' => $deathAgeData, 'title' => I18N::translate('Age related to death year')]) ?>
5341b860509SRico Sonntag                    </div>
5351b860509SRico Sonntag                </div>
5361b860509SRico Sonntag            </div>
5371b860509SRico Sonntag        </div>
538dd6b2bfcSGreg Roach    </div>
539dd6b2bfcSGreg Roach</div>
540