xref: /webtrees/resources/views/lists/individuals-table.phtml (revision 8c0ff4ddd9a921bea0181a3f01de839b3bf0aac7)
1dd6b2bfcSGreg Roach<?php
2d70512abSGreg Roach
31b860509SRico Sonntagdeclare(strict_types=1);
41b860509SRico Sonntag
5054771e9SGreg Roachuse Fisharebest\Webtrees\Age;
61b860509SRico Sonntaguse Fisharebest\Webtrees\Auth;
75373aac2SGreg Roachuse Fisharebest\Webtrees\Carbon;
81b860509SRico Sonntaguse Fisharebest\Webtrees\Date;
91b860509SRico Sonntaguse Fisharebest\Webtrees\GedcomTag;
101b860509SRico Sonntaguse Fisharebest\Webtrees\I18N;
11054771e9SGreg Roachuse Fisharebest\Webtrees\Individual;
1287cca37cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleChartInterface;
131b860509SRico Sonntaguse Fisharebest\Webtrees\Module\ModuleInterface;
141b860509SRico Sonntaguse Fisharebest\Webtrees\Module\RelationshipsChartModule;
151b860509SRico Sonntaguse Fisharebest\Webtrees\Services\ModuleService;
16b9597e06SGreg Roachuse Fisharebest\Webtrees\Tree;
171b860509SRico Sonntaguse Fisharebest\Webtrees\View;
18054771e9SGreg Roachuse Illuminate\Support\Collection;
191b860509SRico Sonntaguse Ramsey\Uuid\Uuid;
201b860509SRico Sonntag
21b9597e06SGreg Roach/**
22054771e9SGreg Roach * @var Collection<Individual> $individuals
23054771e9SGreg Roach * @var bool                   $sosa
24b9597e06SGreg Roach * @var Tree                   $tree
25b9597e06SGreg Roach */
26b9597e06SGreg Roach
27dd6b2bfcSGreg Roach// lists requires a unique ID in case there are multiple lists per page
28dd6b2bfcSGreg Roach$table_id = 'table-indi-' . Uuid::uuid4()->toString();
29dd6b2bfcSGreg Roach
30b9597e06SGreg Roach$today_jd          = Carbon::now()->julianDay();
315373aac2SGreg Roach$hundred_years_ago = Carbon::now()->subYears(100)->julianDay();
321b860509SRico Sonntag
33dd6b2bfcSGreg Roach$unique_indis = []; // Don't double-count indis with multiple names.
3484b37362SGreg Roach
35b2a8cedfSGreg Roach$show_estimated_dates = (bool) $tree->getPreference('SHOW_EST_LIST_DATES');
36b2a8cedfSGreg Roach
37054771e9SGreg Roach$today = new Date(strtoupper(date('d M Y')));
38054771e9SGreg Roach
391b860509SRico Sonntag$module = app(ModuleService::class)
4087cca37cSGreg Roach    ->findByComponent(ModuleChartInterface::class, $tree, Auth::user())
410b5fd0a6SGreg Roach    ->first(static function (ModuleInterface $module) {
4290d97cc8SGreg Roach        return $module instanceof RelationshipsChartModule;
4390d97cc8SGreg Roach    });
44dd6b2bfcSGreg Roach?>
45dd6b2bfcSGreg Roach
46dd6b2bfcSGreg Roach<?php View::push('javascript') ?>
47dd6b2bfcSGreg Roach<script>
4832a5dd8dSGreg Roach$("#<?= e($table_id) ?> > .wt-table-individual").dataTable({
49dd6b2bfcSGreg Roach    processing: true,
50dd6b2bfcSGreg Roach    retrieve: true,
51dd6b2bfcSGreg Roach    columns: [
52dd6b2bfcSGreg Roach        /* Given names  */ { type: "text" },
53dd6b2bfcSGreg Roach        /* Surnames     */ { type: "text" },
5432a5dd8dSGreg Roach        /* SOSA number  */ { type: "num", visible: <?= json_encode($sosa) ?> },
55dd6b2bfcSGreg Roach        /* Birth date   */ { type: "num" },
56dd6b2bfcSGreg Roach        /* Anniversary  */ { type: "num" },
57dd6b2bfcSGreg Roach        /* Birthplace   */ { type: "text" },
58dd6b2bfcSGreg Roach        /* Children     */ { type: "num" },
59dd6b2bfcSGreg Roach        /* Deate date   */ { type: "num" },
60dd6b2bfcSGreg Roach        /* Anniversary  */ { type: "num" },
61dd6b2bfcSGreg Roach        /* Age          */ { type: "num" },
62dd6b2bfcSGreg Roach        /* Death place  */ { type: "text" },
63dd6b2bfcSGreg Roach        /* Last change  */ { visible: <?= json_encode($tree->getPreference('SHOW_LAST_CHANGE')) ?> },
64dd6b2bfcSGreg Roach        /* Filter sex   */ { sortable: false },
65dd6b2bfcSGreg Roach        /* Filter birth */ { sortable: false },
66dd6b2bfcSGreg Roach        /* Filter death */ { sortable: false },
67dd6b2bfcSGreg Roach        /* Filter tree  */ { sortable: false }
68dd6b2bfcSGreg Roach    ],
69b2c011d7SGreg Roach    sorting: <?= json_encode($sosa ? [[4, 'asc']] : [[1, 'asc']]) ?>
70dd6b2bfcSGreg Roach});
71dd6b2bfcSGreg Roach
72dd6b2bfcSGreg Roach$("#<?= e($table_id) ?>")
73dd6b2bfcSGreg Roach    /* Hide/show parents */
744843b94fSGreg Roach    .on("click", "#btn-toggle-parents", function() {
755e6816beSGreg Roach        $(".wt-individual-list-parents").slideToggle();
76dd6b2bfcSGreg Roach    })
77dd6b2bfcSGreg Roach    /* Hide/show statistics */
784843b94fSGreg Roach    .on("click", "#btn-toggle-statistics", function() {
791b860509SRico Sonntag        $("#individual-charts-<?= e($table_id) ?>").slideToggle({
801b860509SRico Sonntag            complete: function () {
811b860509SRico Sonntag                // Trigger resize to redraw the chart
821b860509SRico Sonntag                $('div[id^="google-chart-"]').resize();
831b860509SRico Sonntag            }
841b860509SRico Sonntag        });
85dd6b2bfcSGreg Roach    })
86dd6b2bfcSGreg Roach    /* Filter buttons in table header */
87604bfd4bSGreg Roach    .on("click", "input[data-filter-column]", function() {
88604bfd4bSGreg Roach        let checkbox = $(this);
89604bfd4bSGreg Roach        let siblings = checkbox.parent().siblings();
901b860509SRico Sonntag
91604bfd4bSGreg Roach        // Deselect other options
92604bfd4bSGreg Roach        siblings.children().prop("checked", false).removeAttr("checked");
93604bfd4bSGreg Roach        siblings.removeClass('active');
94604bfd4bSGreg Roach
95604bfd4bSGreg Roach        // Apply (or clear) this filter
96604bfd4bSGreg Roach        let checked = checkbox.prop("checked");
97604bfd4bSGreg Roach        let filter  = checked ? checkbox.data("filter-value") : "";
9832a5dd8dSGreg Roach        let column  = $("#<?= e($table_id) ?> .wt-table-individual").DataTable().column(checkbox.data("filter-column"));
99604bfd4bSGreg Roach        column.search(filter).draw();
100604bfd4bSGreg Roach    });
101dd6b2bfcSGreg Roach</script>
102dd6b2bfcSGreg Roach<?php View::endpush() ?>
103dd6b2bfcSGreg Roach
104dd6b2bfcSGreg Roach<?php
105dd6b2bfcSGreg Roach$max_age = (int) $tree->getPreference('MAX_ALIVE_AGE');
106dd6b2bfcSGreg Roach
10797bf1559SGreg Roach// Initialise chart data
108dd6b2bfcSGreg Roach$deat_by_age = [];
109dd6b2bfcSGreg Roachfor ($age = 0; $age <= $max_age; $age++) {
1101b860509SRico Sonntag    $deat_by_age[$age]['M'] = 0;
1111b860509SRico Sonntag    $deat_by_age[$age]['F'] = 0;
1121b860509SRico Sonntag    $deat_by_age[$age]['U'] = 0;
113dd6b2bfcSGreg Roach}
114dd6b2bfcSGreg Roach$birt_by_decade = [];
115dd6b2bfcSGreg Roach$deat_by_decade = [];
1161b860509SRico Sonntagfor ($year = 1400; $year < 2050; $year += 10) {
1171b860509SRico Sonntag    $birt_by_decade[$year]['M'] = 0;
1181b860509SRico Sonntag    $birt_by_decade[$year]['F'] = 0;
1191b860509SRico Sonntag    $birt_by_decade[$year]['U'] = 0;
1201b860509SRico Sonntag    $deat_by_decade[$year]['M'] = 0;
1211b860509SRico Sonntag    $deat_by_decade[$year]['F'] = 0;
1221b860509SRico Sonntag    $deat_by_decade[$year]['U'] = 0;
123dd6b2bfcSGreg Roach}
1241b860509SRico Sonntag
1251b860509SRico Sonntag$birthData = [
1261b860509SRico Sonntag    [
1271b860509SRico Sonntag        [
1281b860509SRico Sonntag            'label' => I18N::translate('Century'),
1291b860509SRico Sonntag            'type'  => 'date',
1301b860509SRico Sonntag        ], [
1311b860509SRico Sonntag            'label' => I18N::translate('Males'),
1321b860509SRico Sonntag            'type'  => 'number',
1331b860509SRico Sonntag        ], [
1341b860509SRico Sonntag            'label' => I18N::translate('Females'),
1351b860509SRico Sonntag            'type'  => 'number',
1361b860509SRico Sonntag        ],
1371b860509SRico Sonntag    ]
1381b860509SRico Sonntag];
1391b860509SRico Sonntag
1401b860509SRico Sonntag$deathData = [
1411b860509SRico Sonntag    [
1421b860509SRico Sonntag        [
1431b860509SRico Sonntag            'label' => I18N::translate('Century'),
1441b860509SRico Sonntag            'type'  => 'date',
1451b860509SRico Sonntag        ], [
1461b860509SRico Sonntag            'label' => I18N::translate('Males'),
1471b860509SRico Sonntag            'type'  => 'number',
1481b860509SRico Sonntag        ], [
1491b860509SRico Sonntag            'label' => I18N::translate('Females'),
1501b860509SRico Sonntag            'type'  => 'number',
1511b860509SRico Sonntag        ],
1521b860509SRico Sonntag    ]
1531b860509SRico Sonntag];
1541b860509SRico Sonntag
1551b860509SRico Sonntag$deathAgeData = [
1561b860509SRico Sonntag    [
1571b860509SRico Sonntag        I18N::translate('Age'),
1581b860509SRico Sonntag        I18N::translate('Males'),
1591b860509SRico Sonntag        I18N::translate('Females'),
1601b860509SRico Sonntag        I18N::translate('Average age'),
1611b860509SRico Sonntag    ]
1621b860509SRico Sonntag];
1631b860509SRico Sonntag
164dd6b2bfcSGreg Roach?>
165dd6b2bfcSGreg Roach
16632a5dd8dSGreg Roach<div id="<?= e($table_id) ?>">
16732a5dd8dSGreg Roach    <table class="table table-bordered table-sm wt-table-individual"
168b6c326d8SGreg Roach        <?= view('lists/datatables-attributes') ?>
169b6c326d8SGreg Roach    >
170dd6b2bfcSGreg Roach        <thead>
171dd6b2bfcSGreg Roach            <tr>
172dd6b2bfcSGreg Roach                <th colspan="16">
173dd6b2bfcSGreg Roach                    <div class="btn-toolbar d-flex justify-content-between mb-2" role="toolbar">
174604bfd4bSGreg Roach                        <div class="btn-group btn-group-toggle btn-group-sm" data-toggle="buttons">
175af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show only males.') ?>">
17697bf1559SGreg Roach                                <input type="checkbox" data-filter-column="12" data-filter-value="M" autocomplete="off">
17708362db4SGreg Roach                                <?= view('icons/sex', ['sex' => 'M']) ?>
178604bfd4bSGreg Roach                            </label>
179af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show only females.') ?>">
18097bf1559SGreg Roach                                <input type="checkbox" data-filter-column="12" data-filter-value="F" autocomplete="off">
18108362db4SGreg Roach                                <?= view('icons/sex', ['sex' => 'F']) ?>
182604bfd4bSGreg Roach                            </label>
183af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show only individuals for whom the gender is not known.') ?>">
18497bf1559SGreg Roach                                <input type="checkbox" data-filter-column="12" data-filter-value="U" autocomplete="off">
18508362db4SGreg Roach                                <?= view('icons/sex', ['sex' => 'U']) ?>
186604bfd4bSGreg Roach                            </label>
187dd6b2bfcSGreg Roach                        </div>
188604bfd4bSGreg Roach
189604bfd4bSGreg Roach                        <div class="btn-group btn-group-toggle btn-group-sm" data-toggle="buttons">
190af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals who are alive or couples where both partners are alive.') ?>">
19197bf1559SGreg Roach                                <input type="checkbox" data-filter-column="14" data-filter-value="N" autocomplete="off">
192dd6b2bfcSGreg Roach                                <?= I18N::translate('Alive') ?>
193604bfd4bSGreg Roach                            </label>
194af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals who are dead or couples where both partners are dead.') ?>">
19597bf1559SGreg Roach                                <input type="checkbox" data-filter-column="14" data-filter-value="Y" autocomplete="off">
196dd6b2bfcSGreg Roach                                <?= I18N::translate('Dead') ?>
197604bfd4bSGreg Roach                            </label>
198af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals who died more than 100 years ago.') ?>">
19997bf1559SGreg Roach                                <input type="checkbox" data-filter-column="14" data-filter-value="YES" autocomplete="off">
200dd6b2bfcSGreg Roach                                <?= I18N::translate('Death') ?>&gt;100
201604bfd4bSGreg Roach                            </label>
202af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals who died within the last 100 years.') ?>">
20397bf1559SGreg Roach                                <input type="checkbox" data-filter-column="14" data-filter-value="Y100" autocomplete="off">
204392561bbSGreg Roach                                <?= I18N::translate('Death') ?>&lt;=100
205604bfd4bSGreg Roach                            </label>
206dd6b2bfcSGreg Roach                        </div>
207604bfd4bSGreg Roach
208604bfd4bSGreg Roach                        <div class="btn-group btn-group-toggle btn-group-sm" data-toggle="buttons">
209af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals born more than 100 years ago.') ?>">
21097bf1559SGreg Roach                                <input type="checkbox" data-filter-column="13" data-filter-value="YES" autocomplete="off">
211dd6b2bfcSGreg Roach                                <?= I18N::translate('Birth') ?>&gt;100
212604bfd4bSGreg Roach                            </label>
213af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals born within the last 100 years.') ?>">
21497bf1559SGreg Roach                                <input type="checkbox" data-filter-column="13" data-filter-value="Y100" autocomplete="off">
215dd6b2bfcSGreg Roach                                <?= I18N::translate('Birth') ?>&lt;=100
216604bfd4bSGreg Roach                            </label>
217dd6b2bfcSGreg Roach                        </div>
218604bfd4bSGreg Roach
219604bfd4bSGreg Roach                        <div class="btn-group btn-group-toggle btn-group-sm" data-toggle="buttons">
220af8b52f0SGreg 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.') ?>">
22197bf1559SGreg Roach                                <input type="checkbox" data-filter-column="15" data-filter-value="R" autocomplete="off">
222dd6b2bfcSGreg Roach                                <?= I18N::translate('Roots') ?>
223604bfd4bSGreg Roach                            </label>
224af8b52f0SGreg 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.') ?>">
22597bf1559SGreg Roach                                <input type="checkbox" data-filter-column="15" data-filter-value="L" autocomplete="off">
226dd6b2bfcSGreg Roach                                <?= I18N::translate('Leaves') ?>
227604bfd4bSGreg Roach                            </label>
228dd6b2bfcSGreg Roach                        </div>
229dd6b2bfcSGreg Roach                    </div>
230dd6b2bfcSGreg Roach                </th>
231dd6b2bfcSGreg Roach            </tr>
232dd6b2bfcSGreg Roach            <tr>
233dd6b2bfcSGreg Roach                <th><?= I18N::translate('Given names') ?></th>
234dd6b2bfcSGreg Roach                <th><?= I18N::translate('Surname') ?></th>
235dd6b2bfcSGreg Roach                <th><?= /* I18N: Abbreviation for “Sosa-Stradonitz number”. This is an individual’s surname, so may need transliterating into non-latin alphabets. */
236dd6b2bfcSGreg Roach                    I18N::translate('Sosa') ?></th>
237dd6b2bfcSGreg Roach                <th><?= I18N::translate('Birth') ?></th>
238dd6b2bfcSGreg Roach                <th>
239e39fd5c6SGreg Roach                    <span title="<?= I18N::translate('Anniversary') ?>">
240e39fd5c6SGreg Roach                        <?= view('icons/anniversary') ?>
241e39fd5c6SGreg Roach                    </span>
242dd6b2bfcSGreg Roach                </th>
243dd6b2bfcSGreg Roach                <th><?= I18N::translate('Place') ?></th>
244dd6b2bfcSGreg Roach                <th>
245dd6b2bfcSGreg Roach                    <i class="icon-children" title="<?= I18N::translate('Children') ?>"></i>
246dd6b2bfcSGreg Roach                </th>
247dd6b2bfcSGreg Roach                <th><?= I18N::translate('Death') ?></th>
248dd6b2bfcSGreg Roach                <th>
249e39fd5c6SGreg Roach                    <span title="<?= I18N::translate('Anniversary') ?>">
250e39fd5c6SGreg Roach                        <?= view('icons/anniversary') ?>
251e39fd5c6SGreg Roach                    </span>
252dd6b2bfcSGreg Roach                </th>
253dd6b2bfcSGreg Roach                <th><?= I18N::translate('Age') ?></th>
254dd6b2bfcSGreg Roach                <th><?= I18N::translate('Place') ?></th>
255dd6b2bfcSGreg Roach                <th><?= I18N::translate('Last change') ?></th>
256dd6b2bfcSGreg Roach                <th hidden></th>
257dd6b2bfcSGreg Roach                <th hidden></th>
258dd6b2bfcSGreg Roach                <th hidden></th>
259dd6b2bfcSGreg Roach                <th hidden></th>
260dd6b2bfcSGreg Roach            </tr>
261dd6b2bfcSGreg Roach        </thead>
262dd6b2bfcSGreg Roach
263dd6b2bfcSGreg Roach        <tbody>
264dd6b2bfcSGreg Roach            <?php foreach ($individuals as $key => $individual) : ?>
26517dd427eSGreg Roach            <tr class="<?= $individual->isPendingDeletion() ? 'wt-old' : ($individual->isPendingAddition() ? 'wt-new' : '') ?>">
26639ca88baSGreg Roach                <td colspan="2" data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', implode(',', array_reverse(explode(',', $individual->sortName()))))) ?>">
267dd6b2bfcSGreg Roach                    <?php foreach ($individual->getAllNames() as $num => $name) : ?>
26843e7e97aSGreg Roach                        <a title="<?= $name['type'] === 'NAME' ? '' : strip_tags(GedcomTag::getLabel($name['type'])) ?>" href="<?= e($individual->url()) ?>" class="<?= $num === $individual->getPrimaryName() ? 'name2' : '' ?>">
269dd6b2bfcSGreg Roach                            <?= $name['full'] ?>
270dd6b2bfcSGreg Roach                        </a>
271dd6b2bfcSGreg Roach                        <?php if ($num === $individual->getPrimaryName()) : ?>
27208362db4SGreg Roach                            <small><?= view('icons/sex', ['sex' => $individual->sex()]) ?></small>
273dd6b2bfcSGreg Roach                        <?php endif ?>
274dd6b2bfcSGreg Roach                        <br>
275dd6b2bfcSGreg Roach                    <?php endforeach ?>
2765e6816beSGreg Roach                    <?= view('lists/individual-table-parents', ['individual' => $individual]) ?>
277dd6b2bfcSGreg Roach                </td>
278dd6b2bfcSGreg Roach
27939ca88baSGreg Roach                <td hidden data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', $individual->sortName())) ?>"></td>
280dd6b2bfcSGreg Roach
281242a7862SGreg Roach                <td class="text-center" data-sort="<?= $key ?>">
282dd6b2bfcSGreg Roach                    <?php if ($sosa) : ?>
28384b37362SGreg Roach                        <?php if ($module instanceof RelationshipsChartModule) : ?>
28484b37362SGreg Roach                            <a href="<?= e($module->chartUrl($individuals[1], ['xref2' => $individual->xref()])) ?>" rel="nofollow" title="<?= I18N::translate('Relationships') ?>" rel="nofollow">
285dd6b2bfcSGreg Roach                                <?= I18N::number($key) ?>
286dd6b2bfcSGreg Roach                            </a>
28784b37362SGreg Roach                        <?php else : ?>
28884b37362SGreg Roach                            <?= I18N::number($key) ?>
28984b37362SGreg Roach                        <?php endif ?>
290dd6b2bfcSGreg Roach                    <?php endif ?>
291dd6b2bfcSGreg Roach                </td>
292dd6b2bfcSGreg Roach
293dd6b2bfcSGreg Roach                <!-- Birth date -->
294054771e9SGreg Roach                <?php $estimated_birth_date = $individual->getEstimatedBirthDate(); ?>
295054771e9SGreg Roach
296054771e9SGreg Roach                <td data-sort="<?= $estimated_birth_date->julianDay() ?>">
297dd6b2bfcSGreg Roach                    <?php $birth_dates = $individual->getAllBirthDates(); ?>
298dd6b2bfcSGreg Roach
299dd6b2bfcSGreg Roach                    <?php foreach ($birth_dates as $n => $birth_date) : ?>
300dd6b2bfcSGreg Roach                        <?= $birth_date->display(true) ?>
301dd6b2bfcSGreg Roach                        <br>
302dd6b2bfcSGreg Roach                    <?php endforeach ?>
30314147f6fSGreg Roach
304b2a8cedfSGreg Roach                    <?php if (empty($birth_dates) && $show_estimated_dates) : ?>
305054771e9SGreg Roach                        <?= $estimated_birth_date->display(true) ?>
30614147f6fSGreg Roach                    <?php endif ?>
307dd6b2bfcSGreg Roach                </td>
308dd6b2bfcSGreg Roach
309dd6b2bfcSGreg Roach                <!-- Birth anniversary -->
310c0935879SGreg Roach                <?php if (isset($birth_dates[0]) && $birth_dates[0]->gregorianYear() >= 1550 && $birth_dates[0]->gregorianYear() < 2030 && !isset($unique_indis[$individual->xref()])) : ?>
3111b860509SRico Sonntag                    <?php
3121b860509SRico Sonntag                    ++$birt_by_decade[(int) ($birth_dates[0]->gregorianYear() / 10) * 10][$individual->sex()];
3131b860509SRico Sonntag                    ?>
314dd6b2bfcSGreg Roach                <?php endif ?>
31553432476SGreg Roach                <td class="text-center" data-sort="<?= - $estimated_birth_date->julianDay() ?>">
31653432476SGreg Roach                    <?= (new Age($birth_dates[0] ?? new Date(''), $today))->ageYearsString() ?>
317dd6b2bfcSGreg Roach                </td>
318dd6b2bfcSGreg Roach
319dd6b2bfcSGreg Roach                <!-- Birth place -->
320*8c0ff4ddSGreg Roach                <td data-sort="<?= e($individual->getBirthPlace()->gedcomName()) ?>">
321dd6b2bfcSGreg Roach                    <?php foreach ($individual->getAllBirthPlaces() as $n => $birth_place) : ?>
322392561bbSGreg Roach                        <?= $birth_place->shortName(true) ?>
323dd6b2bfcSGreg Roach                        <br>
324dd6b2bfcSGreg Roach                    <?php endforeach ?>
325dd6b2bfcSGreg Roach                </td>
326dd6b2bfcSGreg Roach
327dd6b2bfcSGreg Roach                <!-- Number of children -->
32839ca88baSGreg Roach                <td class="text-center" data-sort="<?= $individual->numberOfChildren() ?>">
32939ca88baSGreg Roach                    <?= I18N::number($individual->numberOfChildren()) ?>
330dd6b2bfcSGreg Roach                </td>
331dd6b2bfcSGreg Roach
332dd6b2bfcSGreg Roach                <!--    Death date -->
333dd6b2bfcSGreg Roach                <?php $death_dates = $individual->getAllDeathDates() ?>
334dd6b2bfcSGreg Roach                <td data-sort="<?= $individual->getEstimatedDeathDate()->julianDay() ?>">
335dd6b2bfcSGreg Roach                    <?php foreach ($death_dates as $num => $death_date) : ?>
336dd6b2bfcSGreg Roach                        <?= $death_date->display(true) ?>
337dd6b2bfcSGreg Roach                    <br>
338dd6b2bfcSGreg Roach                    <?php endforeach ?>
33914147f6fSGreg Roach
340b2a8cedfSGreg Roach                    <?php if (empty($death_dates) && $show_estimated_dates && $individual->getEstimatedDeathDate()->minimumDate()->minimumJulianDay() < $today_jd) : ?>
34114147f6fSGreg Roach                        <?= $individual->getEstimatedDeathDate()->display(true) ?>
34214147f6fSGreg Roach                    <?php endif ?>
343dd6b2bfcSGreg Roach                </td>
344dd6b2bfcSGreg Roach
345dd6b2bfcSGreg Roach                <!-- Death anniversary -->
346c0935879SGreg Roach                <?php if (isset($death_dates[0]) && $death_dates[0]->gregorianYear() >= 1550 && $death_dates[0]->gregorianYear() < 2030 && !isset($unique_indis[$individual->xref()])) : ?>
3471b860509SRico Sonntag                    <?php
3481b860509SRico Sonntag                    ++$deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10][$individual->sex()];
3491b860509SRico Sonntag                    ?>
350dd6b2bfcSGreg Roach                <?php endif ?>
35153432476SGreg Roach                <td class="text-center" data-sort="<?= - $individual->getEstimatedDeathDate()->julianDay() ?>">
35253432476SGreg Roach                    <?= (new Age($death_dates[0] ?? new Date(''), $today))->ageYearsString() ?>
353dd6b2bfcSGreg Roach                </td>
354dd6b2bfcSGreg Roach
355dd6b2bfcSGreg Roach                <!-- Age at death -->
35653432476SGreg Roach                <?php $age = new Age($birth_dates[0] ?? new Date(''), $death_dates[0] ?? new Date('')) ?>
35753432476SGreg Roach                <?php if (!isset($unique_indis[$individual->xref()]) && $age->ageYears() >= 0 && $age->ageYears() <= $max_age) : ?>
35853432476SGreg Roach                    <?php ++$deat_by_age[$age->ageYears()][$individual->sex()] ?>
359dd6b2bfcSGreg Roach                <?php endif ?>
36053432476SGreg Roach                <td class="text-center" data-sort="<?= $age->ageDays() ?>">
36153432476SGreg Roach                    <?= $age->ageYearsString() ?>
362dd6b2bfcSGreg Roach                </td>
363dd6b2bfcSGreg Roach
364dd6b2bfcSGreg Roach                <!-- Death place -->
365*8c0ff4ddSGreg Roach                <td data-sort="<?= e($individual->getDeathPlace()->gedcomName()) ?>">
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>
384054771e9SGreg Roach                    <?php if ($estimated_birth_date->maximumJulianDay() > $hundred_years_ago && $estimated_birth_date->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">
420af8b52f0SGreg 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>
423af8b52f0SGreg 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