xref: /webtrees/resources/views/lists/individuals-table.phtml (revision 054771e94ab58244acfab4da8ab0752d96fe7fb5)
1dd6b2bfcSGreg Roach<?php
2d70512abSGreg Roach
31b860509SRico Sonntagdeclare(strict_types=1);
41b860509SRico Sonntag
5*054771e9SGreg 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;
11*054771e9SGreg 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;
18*054771e9SGreg Roachuse Illuminate\Support\Collection;
191b860509SRico Sonntaguse Ramsey\Uuid\Uuid;
201b860509SRico Sonntag
21b9597e06SGreg Roach/**
22*054771e9SGreg Roach * @var Collection<Individual> $individuals
23*054771e9SGreg 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
37*054771e9SGreg Roach$today = new Date(strtoupper(date('d M Y')));
38*054771e9SGreg 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
107dd6b2bfcSGreg Roach// Inititialise 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.') ?>">
176604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="12" data-filter-value="M">
17708362db4SGreg Roach                                <?= view('icons/sex', ['sex' => 'M']) ?>
178604bfd4bSGreg Roach                            </label>
179af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show only females.') ?>">
180604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="12" data-filter-value="F">
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.') ?>">
184604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="12" data-filter-value="U">
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.') ?>">
191604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="14" data-filter-value="N">
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.') ?>">
195604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="14" data-filter-value="Y">
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.') ?>">
199604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="14" data-filter-value="YES">
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.') ?>">
203604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="14" data-filter-value="Y100">
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.') ?>">
210604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="13" data-filter-value="YES">
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.') ?>">
214604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="13" data-filter-value="Y100">
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.') ?>">
221604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="15" data-filter-value="R">
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.') ?>">
225604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="15" data-filter-value="L">
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) : ?>
268e840bf40SGreg Roach                        <a title="<?= $name['type'] === 'NAME' ? '' : strip_tags(GedcomTag::getLabel($name['type'], $individual)) ?>" 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 -->
294*054771e9SGreg Roach                <?php $estimated_birth_date = $individual->getEstimatedBirthDate(); ?>
295*054771e9SGreg Roach
296*054771e9SGreg 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) : ?>
305*054771e9SGreg Roach                        <?= $estimated_birth_date->display(true) ?>
30614147f6fSGreg Roach                    <?php endif ?>
307dd6b2bfcSGreg Roach                </td>
308dd6b2bfcSGreg Roach
309dd6b2bfcSGreg Roach                <!-- Birth anniversary -->
310*054771e9SGreg Roach                <td class="text-center" data-sort="<?= - $estimated_birth_date->julianDay() ?>">
311c0935879SGreg Roach                    <?php if (isset($birth_dates[0]) && $birth_dates[0]->gregorianYear() >= 1550 && $birth_dates[0]->gregorianYear() < 2030 && !isset($unique_indis[$individual->xref()])) : ?>
3121b860509SRico Sonntag                        <?php
3131b860509SRico Sonntag                            ++$birt_by_decade[(int) ($birth_dates[0]->gregorianYear() / 10) * 10][$individual->sex()];
3141b860509SRico Sonntag                        ?>
315*054771e9SGreg Roach                        <?= I18N::number((new Age($birth_dates[0], $today))->ageYears()) ?>
316dd6b2bfcSGreg Roach                    <?php endif ?>
317dd6b2bfcSGreg Roach                </td>
318dd6b2bfcSGreg Roach
319dd6b2bfcSGreg Roach                <!-- Birth place -->
320dd6b2bfcSGreg Roach                <td>
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 -->
346242a7862SGreg Roach                <td class="text-center" data-sort="<?= - $individual->getEstimatedDeathDate()->julianDay() ?>">
347c0935879SGreg Roach                    <?php if (isset($death_dates[0]) && $death_dates[0]->gregorianYear() >= 1550 && $death_dates[0]->gregorianYear() < 2030 && !isset($unique_indis[$individual->xref()])) : ?>
3481b860509SRico Sonntag                        <?php
3491b860509SRico Sonntag                            ++$deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10][$individual->sex()];
3501b860509SRico Sonntag                        ?>
351*054771e9SGreg Roach                        <?= I18N::number((new Age($death_dates[0], $today))->ageYears()) ?>
352dd6b2bfcSGreg Roach                    <?php endif ?>
353dd6b2bfcSGreg Roach                </td>
354dd6b2bfcSGreg Roach
355dd6b2bfcSGreg Roach                <!-- Age at death -->
3563cfcc809SGreg Roach                <?php if (isset($birth_dates[0], $death_dates[0])) : ?>
357*054771e9SGreg Roach                    <?php $age_at_death = new Age($birth_dates[0], $death_dates[0]); ?>
358*054771e9SGreg Roach                    <?php $age_at_death_sort = $age_at_death->ageDays(); ?>
359*054771e9SGreg Roach                    <?php $age_at_death_years = $age_at_death->ageYears(); ?>
360*054771e9SGreg Roach                    <?php $age_at_death_display = I18N::number($age_at_death->ageYears()); ?>
3614e96702fSGreg Roach                    <?php if (!isset($unique_indis[$individual->xref()]) && $age_at_death_years >= 0 && $age_at_death_years <= $max_age) : ?>
3621b860509SRico Sonntag                        <?php
3634e96702fSGreg Roach                            ++$deat_by_age[$age_at_death_years][$individual->sex()];
3641b860509SRico Sonntag                        ?>
365dd6b2bfcSGreg Roach                    <?php endif ?>
366dd6b2bfcSGreg Roach                <?php else : ?>
3674e96702fSGreg Roach                    <?php $age_at_death_display = ''; ?>
368dd6b2bfcSGreg Roach                    <?php $age_at_death_sort = PHP_INT_MAX; ?>
369dd6b2bfcSGreg Roach                <?php endif ?>
370*054771e9SGreg Roach                <td class="text-center" data-sort="<?= $age_at_death_sort ?>">
371*054771e9SGreg Roach                    <?= $age_at_death_display ?>
372dd6b2bfcSGreg Roach                </td>
373dd6b2bfcSGreg Roach
374dd6b2bfcSGreg Roach                <!-- Death place -->
375dd6b2bfcSGreg Roach                <td>
376dd6b2bfcSGreg Roach                    <?php foreach ($individual->getAllDeathPlaces() as $n => $death_place) : ?>
377392561bbSGreg Roach                        <?= $death_place->shortName(true) ?>
378dd6b2bfcSGreg Roach                        <br>
379dd6b2bfcSGreg Roach                    <?php endforeach ?>
380dd6b2bfcSGreg Roach                </td>
381dd6b2bfcSGreg Roach
382dd6b2bfcSGreg Roach                <!-- Last change -->
3834459dc9aSGreg Roach                <td data-sort="<?= $individual->lastChangeTimestamp()->unix() ?>">
3844459dc9aSGreg Roach                    <?= view('components/datetime', ['timestamp' => $individual->lastChangeTimestamp()]) ?>
385dd6b2bfcSGreg Roach                </td>
386dd6b2bfcSGreg Roach
387dd6b2bfcSGreg Roach                <!-- Filter by sex -->
388dd6b2bfcSGreg Roach                <td hidden>
38939ca88baSGreg Roach                    <?= $individual->sex() ?>
390dd6b2bfcSGreg Roach                </td>
391dd6b2bfcSGreg Roach
392dd6b2bfcSGreg Roach                <!-- Filter by birth date -->
393dd6b2bfcSGreg Roach                <td hidden>
394*054771e9SGreg Roach                    <?php if ($estimated_birth_date->maximumJulianDay() > $hundred_years_ago && $estimated_birth_date->maximumJulianDay() <= $today_jd) : ?>
395dd6b2bfcSGreg Roach                        Y100
396dd6b2bfcSGreg Roach                    <?php else : ?>
397dd6b2bfcSGreg Roach                        YES
398dd6b2bfcSGreg Roach                    <?php endif ?>
399dd6b2bfcSGreg Roach                </td>
400dd6b2bfcSGreg Roach
401dd6b2bfcSGreg Roach                <!-- Filter by death date -->
402dd6b2bfcSGreg Roach                <td hidden>
403b9597e06SGreg Roach                    <?php if ($individual->getEstimatedDeathDate()->maximumJulianDay() > $hundred_years_ago && $individual->getEstimatedDeathDate()->maximumJulianDay() <= $today_jd) : ?>
404dd6b2bfcSGreg Roach                        Y100
405dd6b2bfcSGreg Roach                    <?php elseif ($individual->isDead()) : ?>
406dd6b2bfcSGreg Roach                        YES
407dd6b2bfcSGreg Roach                    <?php else : ?>
408dd6b2bfcSGreg Roach                        N
409dd6b2bfcSGreg Roach                    <?php endif ?>
410dd6b2bfcSGreg Roach                </td>
411dd6b2bfcSGreg Roach
412dd6b2bfcSGreg Roach                <!-- Filter by roots/leaves -->
413dd6b2bfcSGreg Roach                <td hidden>
41408662657SGreg Roach                    <?php if ($individual->childFamilies()->isEmpty()) : ?>
415dd6b2bfcSGreg Roach                        R
41639ca88baSGreg Roach                    <?php elseif (!$individual->isDead() && $individual->numberOfChildren() < 1) : ?>
417dd6b2bfcSGreg Roach                        L
418dd6b2bfcSGreg Roach                    <?php endif ?>
419dd6b2bfcSGreg Roach                </td>
420dd6b2bfcSGreg Roach            </tr>
421dd6b2bfcSGreg Roach
422c0935879SGreg Roach                <?php $unique_indis[$individual->xref()] = true ?>
423dd6b2bfcSGreg Roach            <?php endforeach ?>
424dd6b2bfcSGreg Roach        </tbody>
4257039fd97SGreg Roach
4267039fd97SGreg Roach        <tfoot>
4277039fd97SGreg Roach            <tr>
4287039fd97SGreg Roach                <th colspan="16">
429604bfd4bSGreg Roach                    <div class="btn-group btn-group-sm">
430af8b52f0SGreg Roach                        <button id="btn-toggle-parents" class="btn btn-outline-secondary" data-toggle="button" data-persist="show-parents">
4317039fd97SGreg Roach                            <?= I18N::translate('Show parents') ?>
4327039fd97SGreg Roach                        </button>
433af8b52f0SGreg Roach                        <button id="btn-toggle-statistics" class="btn btn-outline-secondary" data-toggle="button" data-persist="show-statistics">
4347039fd97SGreg Roach                            <?= I18N::translate('Show statistics charts') ?>
4357039fd97SGreg Roach                        </button>
4367039fd97SGreg Roach                    </div>
4377039fd97SGreg Roach                </th>
4387039fd97SGreg Roach            </tr>
4397039fd97SGreg Roach        </tfoot>
440dd6b2bfcSGreg Roach    </table>
4411b860509SRico Sonntag</div>
442dd6b2bfcSGreg Roach
4431b860509SRico Sonntag<div id="individual-charts-<?= e($table_id) ?>" style="display: none;">
4441b860509SRico Sonntag    <div class="mb-3">
4451b860509SRico Sonntag        <div class="card-deck">
4461b860509SRico Sonntag            <div class="col-lg-12 col-md-12 mb-3">
4471b860509SRico Sonntag                <div class="card m-0">
4481b860509SRico Sonntag                    <div class="card-header">
4491b860509SRico Sonntag                        <?= I18N::translate('Decade of birth') ?>
4501b860509SRico Sonntag                    </div>
4511b860509SRico Sonntag                    <div class="card-body">
4521b860509SRico Sonntag                        <?php
4531b860509SRico Sonntag                        foreach ($birt_by_decade as $century => $values) {
4541b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
4551b860509SRico Sonntag                                $birthData[] = [
4561b860509SRico Sonntag                                    [
4571b860509SRico Sonntag                                        'v' => 'Date(' . $century . ', 0, 1)',
4581b860509SRico Sonntag                                        'f' => $century,
4591b860509SRico Sonntag                                    ],
4601b860509SRico Sonntag                                    $values['M'],
4611b860509SRico Sonntag                                    $values['F'],
4621b860509SRico Sonntag                                ];
4631b860509SRico Sonntag                            }
4641b860509SRico Sonntag                        }
4651b860509SRico Sonntag                        ?>
4661b860509SRico Sonntag                        <?= view('lists/chart-by-decade', ['data' => $birthData, 'title' => I18N::translate('Decade of birth')]) ?>
4671b860509SRico Sonntag                    </div>
4681b860509SRico Sonntag                </div>
4691b860509SRico Sonntag            </div>
4701b860509SRico Sonntag        </div>
4711b860509SRico Sonntag        <div class="card-deck">
4721b860509SRico Sonntag            <div class="col-lg-12 col-md-12 mb-3">
4731b860509SRico Sonntag                <div class="card m-0">
4741b860509SRico Sonntag                    <div class="card-header">
4751b860509SRico Sonntag                        <?= I18N::translate('Decade of death') ?>
4761b860509SRico Sonntag                    </div>
4771b860509SRico Sonntag                    <div class="card-body">
4781b860509SRico Sonntag                        <?php
4791b860509SRico Sonntag                        foreach ($deat_by_decade as $century => $values) {
4801b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
4811b860509SRico Sonntag                                $deathData[] = [
4821b860509SRico Sonntag                                    [
4831b860509SRico Sonntag                                        'v' => 'Date(' . $century . ', 0, 1)',
4841b860509SRico Sonntag                                        'f' => $century,
4851b860509SRico Sonntag                                    ],
4861b860509SRico Sonntag                                    $values['M'],
4871b860509SRico Sonntag                                    $values['F'],
4881b860509SRico Sonntag                                ];
4891b860509SRico Sonntag                            }
4901b860509SRico Sonntag                        }
4911b860509SRico Sonntag                        ?>
4921b860509SRico Sonntag                        <?= view('lists/chart-by-decade', ['data' => $deathData, 'title' => I18N::translate('Decade of death')]) ?>
4931b860509SRico Sonntag                    </div>
4941b860509SRico Sonntag                </div>
4951b860509SRico Sonntag            </div>
4961b860509SRico Sonntag        </div>
4971b860509SRico Sonntag        <div class="card-deck">
4981b860509SRico Sonntag            <div class="col-lg-12 col-md-12 mb-3">
4991b860509SRico Sonntag                <div class="card m-0">
5001b860509SRico Sonntag                    <div class="card-header">
5011b860509SRico Sonntag                        <?= I18N::translate('Age related to death year') ?>
5021b860509SRico Sonntag                    </div>
5031b860509SRico Sonntag                    <div class="card-body">
5041b860509SRico Sonntag                        <?php
5051b860509SRico Sonntag                            $totalAge = 0;
5061b860509SRico Sonntag                            $totalSum = 0;
5071b860509SRico Sonntag                            $max      = 0;
5081b860509SRico Sonntag
5091b860509SRico Sonntag                        foreach ($deat_by_age as $age => $values) {
5101b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
5111b860509SRico Sonntag                                if (($values['M'] + $values['F']) > $max) {
5121b860509SRico Sonntag                                    $max = $values['M'] + $values['F'];
5131b860509SRico Sonntag                                }
5141b860509SRico Sonntag
5151b860509SRico Sonntag                                $totalAge += $age * ($values['M'] + $values['F']);
5161b860509SRico Sonntag                                $totalSum += $values['M'] + $values['F'];
5171b860509SRico Sonntag
5181b860509SRico Sonntag                                $deathAgeData[] = [
5191b860509SRico Sonntag                                    $age,
5201b860509SRico Sonntag                                    $values['M'],
5211b860509SRico Sonntag                                    $values['F'],
5221b860509SRico Sonntag                                    null,
5231b860509SRico Sonntag                                ];
5241b860509SRico Sonntag                            }
5251b860509SRico Sonntag                        }
5261b860509SRico Sonntag
5271b860509SRico Sonntag                        if ($totalSum > 0) {
5281b860509SRico Sonntag                            $deathAgeData[] = [
5291b860509SRico Sonntag                                round($totalAge / $totalSum, 1),
5301b860509SRico Sonntag                                null,
5311b860509SRico Sonntag                                null,
5321b860509SRico Sonntag                                0,
5331b860509SRico Sonntag                            ];
5341b860509SRico Sonntag
5351b860509SRico Sonntag                            $deathAgeData[] = [
5361b860509SRico Sonntag                                round($totalAge / $totalSum, 1),
5371b860509SRico Sonntag                                null,
5381b860509SRico Sonntag                                null,
5391b860509SRico Sonntag                                $max,
5401b860509SRico Sonntag                            ];
5411b860509SRico Sonntag                        }
5421b860509SRico Sonntag                        ?>
5431b860509SRico Sonntag                        <?= view('lists/chart-by-age', ['data' => $deathAgeData, 'title' => I18N::translate('Age related to death year')]) ?>
5441b860509SRico Sonntag                    </div>
5451b860509SRico Sonntag                </div>
5461b860509SRico Sonntag            </div>
5471b860509SRico Sonntag        </div>
548dd6b2bfcSGreg Roach    </div>
549dd6b2bfcSGreg Roach</div>
550