xref: /webtrees/resources/views/lists/individuals-table.phtml (revision 66ecd01738ea7f89ee5b1944d4d969facd03cb4e)
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\I18N;
10054771e9SGreg Roachuse Fisharebest\Webtrees\Individual;
1187cca37cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleChartInterface;
121b860509SRico Sonntaguse Fisharebest\Webtrees\Module\ModuleInterface;
131b860509SRico Sonntaguse Fisharebest\Webtrees\Module\RelationshipsChartModule;
141b860509SRico Sonntaguse Fisharebest\Webtrees\Services\ModuleService;
15b9597e06SGreg Roachuse Fisharebest\Webtrees\Tree;
161b860509SRico Sonntaguse Fisharebest\Webtrees\View;
17054771e9SGreg Roachuse Illuminate\Support\Collection;
181b860509SRico Sonntaguse Ramsey\Uuid\Uuid;
191b860509SRico Sonntag
20b9597e06SGreg Roach/**
21054771e9SGreg Roach * @var Collection<Individual> $individuals
22054771e9SGreg Roach * @var bool                   $sosa
23b9597e06SGreg Roach * @var Tree                   $tree
24b9597e06SGreg Roach */
25b9597e06SGreg Roach
26dd6b2bfcSGreg Roach// lists requires a unique ID in case there are multiple lists per page
27dd6b2bfcSGreg Roach$table_id = 'table-indi-' . Uuid::uuid4()->toString();
28dd6b2bfcSGreg Roach
29b9597e06SGreg Roach$today_jd          = Carbon::now()->julianDay();
305373aac2SGreg Roach$hundred_years_ago = Carbon::now()->subYears(100)->julianDay();
311b860509SRico Sonntag
32dd6b2bfcSGreg Roach$unique_indis = []; // Don't double-count indis with multiple names.
3384b37362SGreg Roach
34b2a8cedfSGreg Roach$show_estimated_dates = (bool) $tree->getPreference('SHOW_EST_LIST_DATES');
35b2a8cedfSGreg Roach
36054771e9SGreg Roach$today = new Date(strtoupper(date('d M Y')));
37054771e9SGreg Roach
381b860509SRico Sonntag$module = app(ModuleService::class)
3987cca37cSGreg Roach    ->findByComponent(ModuleChartInterface::class, $tree, Auth::user())
400b5fd0a6SGreg Roach    ->first(static function (ModuleInterface $module) {
4190d97cc8SGreg Roach        return $module instanceof RelationshipsChartModule;
4290d97cc8SGreg Roach    });
43dd6b2bfcSGreg Roach?>
44dd6b2bfcSGreg Roach
45dd6b2bfcSGreg Roach<?php View::push('javascript') ?>
46dd6b2bfcSGreg Roach<script>
4732a5dd8dSGreg Roach$("#<?= e($table_id) ?> > .wt-table-individual").dataTable({
48dd6b2bfcSGreg Roach    processing: true,
49dd6b2bfcSGreg Roach    retrieve: true,
50dd6b2bfcSGreg Roach    columns: [
51dd6b2bfcSGreg Roach        /* Given names  */ { type: "text" },
52dd6b2bfcSGreg Roach        /* Surnames     */ { type: "text" },
53728c8c27SGreg Roach        /* SOSA number  */ { type: "num", visible: <?= json_encode($sosa, JSON_THROW_ON_ERROR) ?> },
54dd6b2bfcSGreg Roach        /* Birth date   */ { type: "num" },
55dd6b2bfcSGreg Roach        /* Anniversary  */ { type: "num" },
56dd6b2bfcSGreg Roach        /* Birthplace   */ { type: "text" },
57dd6b2bfcSGreg Roach        /* Children     */ { type: "num" },
58dd6b2bfcSGreg Roach        /* Deate date   */ { type: "num" },
59dd6b2bfcSGreg Roach        /* Anniversary  */ { type: "num" },
60dd6b2bfcSGreg Roach        /* Age          */ { type: "num" },
61dd6b2bfcSGreg Roach        /* Death place  */ { type: "text" },
62728c8c27SGreg Roach        /* Last change  */ { visible: <?= json_encode($tree->getPreference('SHOW_LAST_CHANGE'), JSON_THROW_ON_ERROR) ?> },
63dd6b2bfcSGreg Roach        /* Filter sex   */ { sortable: false },
64dd6b2bfcSGreg Roach        /* Filter birth */ { sortable: false },
65dd6b2bfcSGreg Roach        /* Filter death */ { sortable: false },
66dd6b2bfcSGreg Roach        /* Filter tree  */ { sortable: false }
67dd6b2bfcSGreg Roach    ],
68728c8c27SGreg Roach    sorting: <?= json_encode($sosa ? [[4, 'asc']] : [[1, 'asc']], JSON_THROW_ON_ERROR) ?>
69dd6b2bfcSGreg Roach});
70dd6b2bfcSGreg Roach
71dd6b2bfcSGreg Roach$("#<?= e($table_id) ?>")
72dd6b2bfcSGreg Roach    /* Hide/show parents */
734843b94fSGreg Roach    .on("click", "#btn-toggle-parents", function() {
745e6816beSGreg Roach        $(".wt-individual-list-parents").slideToggle();
75dd6b2bfcSGreg Roach    })
76dd6b2bfcSGreg Roach    /* Hide/show statistics */
774843b94fSGreg Roach    .on("click", "#btn-toggle-statistics", function() {
781b860509SRico Sonntag        $("#individual-charts-<?= e($table_id) ?>").slideToggle({
791b860509SRico Sonntag            complete: function () {
801b860509SRico Sonntag                // Trigger resize to redraw the chart
811b860509SRico Sonntag                $('div[id^="google-chart-"]').resize();
821b860509SRico Sonntag            }
831b860509SRico Sonntag        });
84dd6b2bfcSGreg Roach    })
85dd6b2bfcSGreg Roach    /* Filter buttons in table header */
86604bfd4bSGreg Roach    .on("click", "input[data-filter-column]", function() {
87604bfd4bSGreg Roach        let checkbox = $(this);
881b860509SRico Sonntag
89604bfd4bSGreg Roach        // Deselect other options
903a976702SJonathan Jaubart        let siblings = checkbox.siblings("input[type='checkbox']");
913a976702SJonathan Jaubart        siblings.prop("checked", false).removeAttr("checked");
92604bfd4bSGreg Roach
93604bfd4bSGreg Roach        // Apply (or clear) this filter
94604bfd4bSGreg Roach        let checked = checkbox.prop("checked");
95604bfd4bSGreg Roach        let filter  = checked ? checkbox.data("filter-value") : "";
9632a5dd8dSGreg Roach        let column  = $("#<?= e($table_id) ?> .wt-table-individual").DataTable().column(checkbox.data("filter-column"));
97604bfd4bSGreg Roach        column.search(filter).draw();
98604bfd4bSGreg Roach    });
99dd6b2bfcSGreg Roach</script>
100dd6b2bfcSGreg Roach<?php View::endpush() ?>
101dd6b2bfcSGreg Roach
102dd6b2bfcSGreg Roach<?php
103dd6b2bfcSGreg Roach$max_age = (int) $tree->getPreference('MAX_ALIVE_AGE');
104dd6b2bfcSGreg Roach
10597bf1559SGreg Roach// Initialise chart data
106dd6b2bfcSGreg Roach$deat_by_age = [];
107dd6b2bfcSGreg Roachfor ($age = 0; $age <= $max_age; $age++) {
1081b860509SRico Sonntag    $deat_by_age[$age]['M'] = 0;
1091b860509SRico Sonntag    $deat_by_age[$age]['F'] = 0;
1101b860509SRico Sonntag    $deat_by_age[$age]['U'] = 0;
111dd6b2bfcSGreg Roach}
112dd6b2bfcSGreg Roach$birt_by_decade = [];
113dd6b2bfcSGreg Roach$deat_by_decade = [];
1141b860509SRico Sonntagfor ($year = 1400; $year < 2050; $year += 10) {
1151b860509SRico Sonntag    $birt_by_decade[$year]['M'] = 0;
1161b860509SRico Sonntag    $birt_by_decade[$year]['F'] = 0;
1171b860509SRico Sonntag    $birt_by_decade[$year]['U'] = 0;
1181b860509SRico Sonntag    $deat_by_decade[$year]['M'] = 0;
1191b860509SRico Sonntag    $deat_by_decade[$year]['F'] = 0;
1201b860509SRico Sonntag    $deat_by_decade[$year]['U'] = 0;
121dd6b2bfcSGreg Roach}
1221b860509SRico Sonntag
1231b860509SRico Sonntag$birthData = [
1241b860509SRico Sonntag    [
1251b860509SRico Sonntag        [
1261b860509SRico Sonntag            'label' => I18N::translate('Century'),
1271b860509SRico Sonntag            'type'  => 'date',
1281b860509SRico Sonntag        ], [
1291b860509SRico Sonntag            'label' => I18N::translate('Males'),
1301b860509SRico Sonntag            'type'  => 'number',
1311b860509SRico Sonntag        ], [
1321b860509SRico Sonntag            'label' => I18N::translate('Females'),
1331b860509SRico Sonntag            'type'  => 'number',
1341b860509SRico Sonntag        ],
1351b860509SRico Sonntag    ]
1361b860509SRico Sonntag];
1371b860509SRico Sonntag
1381b860509SRico Sonntag$deathData = [
1391b860509SRico Sonntag    [
1401b860509SRico Sonntag        [
1411b860509SRico Sonntag            'label' => I18N::translate('Century'),
1421b860509SRico Sonntag            'type'  => 'date',
1431b860509SRico Sonntag        ], [
1441b860509SRico Sonntag            'label' => I18N::translate('Males'),
1451b860509SRico Sonntag            'type'  => 'number',
1461b860509SRico Sonntag        ], [
1471b860509SRico Sonntag            'label' => I18N::translate('Females'),
1481b860509SRico Sonntag            'type'  => 'number',
1491b860509SRico Sonntag        ],
1501b860509SRico Sonntag    ]
1511b860509SRico Sonntag];
1521b860509SRico Sonntag
1531b860509SRico Sonntag$deathAgeData = [
1541b860509SRico Sonntag    [
1551b860509SRico Sonntag        I18N::translate('Age'),
1561b860509SRico Sonntag        I18N::translate('Males'),
1571b860509SRico Sonntag        I18N::translate('Females'),
1581b860509SRico Sonntag        I18N::translate('Average age'),
1591b860509SRico Sonntag    ]
1601b860509SRico Sonntag];
1611b860509SRico Sonntag
162dd6b2bfcSGreg Roach?>
163dd6b2bfcSGreg Roach
16432a5dd8dSGreg Roach<div id="<?= e($table_id) ?>">
16532a5dd8dSGreg Roach    <table class="table table-bordered table-sm wt-table-individual"
166b6c326d8SGreg Roach        <?= view('lists/datatables-attributes') ?>
167b6c326d8SGreg Roach    >
168dd6b2bfcSGreg Roach        <thead>
169dd6b2bfcSGreg Roach            <tr>
170dd6b2bfcSGreg Roach                <th colspan="16">
171dd6b2bfcSGreg Roach                    <div class="btn-toolbar d-flex justify-content-between mb-2" role="toolbar">
1723a976702SJonathan Jaubart                        <div class="btn-group btn-group-sm" role="group">
1733a976702SJonathan Jaubart                            <input id="<?= e($table_id) ?>-bg-sex-M" class="btn-check" type="checkbox" data-filter-column="12" data-filter-value="M" autocomplete="off">
1743a976702SJonathan Jaubart                            <label for="<?= e($table_id) ?>-bg-sex-M" class="btn btn-outline-secondary" title="<?= I18N::translate('Show only males.') ?>">
17508362db4SGreg Roach                                <?= view('icons/sex', ['sex' => 'M']) ?>
176604bfd4bSGreg Roach                            </label>
1773a976702SJonathan Jaubart
1783a976702SJonathan Jaubart                            <input id="<?= e($table_id) ?>-bg-sex-F" class="btn-check" type="checkbox" data-filter-column="12" data-filter-value="F" autocomplete="off">
1793a976702SJonathan Jaubart                            <label for="<?= e($table_id) ?>-bg-sex-F" class="btn btn-outline-secondary" title="<?= I18N::translate('Show only females.') ?>">
18008362db4SGreg Roach                                <?= view('icons/sex', ['sex' => 'F']) ?>
181604bfd4bSGreg Roach                            </label>
1823a976702SJonathan Jaubart
1833a976702SJonathan Jaubart                            <input id="<?= e($table_id) ?>-bg-sex-U" class="btn-check" type="checkbox" data-filter-column="12" data-filter-value="U" autocomplete="off">
1843a976702SJonathan Jaubart                            <label for="<?= e($table_id) ?>-bg-sex-U" class="btn btn-outline-secondary" title="<?= I18N::translate('Show only individuals for whom the gender is not known.') ?>">
18508362db4SGreg Roach                                <?= view('icons/sex', ['sex' => 'U']) ?>
186604bfd4bSGreg Roach                            </label>
187dd6b2bfcSGreg Roach                        </div>
188604bfd4bSGreg Roach
1893a976702SJonathan Jaubart                        <div class="btn-group btn-group-sm" role="group">
1903a976702SJonathan Jaubart                            <input id="<?= e($table_id) ?>-bg-dead-N" class="btn-check" type="checkbox" data-filter-column="14" data-filter-value="N" autocomplete="off">
1913a976702SJonathan Jaubart                            <label for="<?= e($table_id) ?>-bg-dead-N" class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals who are alive or couples where both partners are alive.') ?>">
192dd6b2bfcSGreg Roach                                <?= I18N::translate('Alive') ?>
193604bfd4bSGreg Roach                            </label>
1943a976702SJonathan Jaubart
1953a976702SJonathan Jaubart                            <input id="<?= e($table_id) ?>-bg-dead-Y" class="btn-check" type="checkbox" data-filter-column="14" data-filter-value="Y" autocomplete="off">
1963a976702SJonathan Jaubart                            <label for="<?= e($table_id) ?>-bg-dead-Y" class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals who are dead or couples where both partners are dead.') ?>">
197dd6b2bfcSGreg Roach                                <?= I18N::translate('Dead') ?>
198604bfd4bSGreg Roach                            </label>
1993a976702SJonathan Jaubart
2003a976702SJonathan Jaubart                            <input id="<?= e($table_id) ?>-bg-dead-YES" class="btn-check" type="checkbox" data-filter-column="14" data-filter-value="YES" autocomplete="off">
2013a976702SJonathan Jaubart                            <label for="<?= e($table_id) ?>-bg-dead-YES" class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals who died more than 100 years ago.') ?>">
202dd6b2bfcSGreg Roach                                <?= I18N::translate('Death') ?>&gt;100
203604bfd4bSGreg Roach                            </label>
2043a976702SJonathan Jaubart
2053a976702SJonathan Jaubart                            <input id="<?= e($table_id) ?>-bg-alive-Y100" class="btn-check" type="checkbox" data-filter-column="14" data-filter-value="Y100" autocomplete="off">
2063a976702SJonathan Jaubart                            <label for="<?= e($table_id) ?>-bg-alive-Y100" class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals who died within the last 100 years.') ?>">
207392561bbSGreg Roach                                <?= I18N::translate('Death') ?>&lt;=100
208604bfd4bSGreg Roach                            </label>
209dd6b2bfcSGreg Roach                        </div>
210604bfd4bSGreg Roach
2113a976702SJonathan Jaubart                        <div class="btn-group btn-group-sm" role="group">
2123a976702SJonathan Jaubart
2133a976702SJonathan Jaubart                            <input id="<?= e($table_id) ?>-bg-born-YES" class="btn-check" type="checkbox" data-filter-column="13" data-filter-value="YES" autocomplete="off">
2143a976702SJonathan Jaubart                            <label for="<?= e($table_id) ?>-bg-born-YES" class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals born more than 100 years ago.') ?>">
215dd6b2bfcSGreg Roach                                <?= I18N::translate('Birth') ?>&gt;100
216604bfd4bSGreg Roach                            </label>
2173a976702SJonathan Jaubart
2183a976702SJonathan Jaubart                            <input id="<?= e($table_id) ?>-bg-born-Y100" class="btn-check" type="checkbox" data-filter-column="13" data-filter-value="Y100" autocomplete="off">
2193a976702SJonathan Jaubart                            <label for="<?= e($table_id) ?>-bg-born-Y100" class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals born within the last 100 years.') ?>">
220dd6b2bfcSGreg Roach                                <?= I18N::translate('Birth') ?>&lt;=100
221604bfd4bSGreg Roach                            </label>
222dd6b2bfcSGreg Roach                        </div>
223604bfd4bSGreg Roach
2243a976702SJonathan Jaubart                        <div class="btn-group btn-group-sm" role="group">
2253a976702SJonathan Jaubart
2263a976702SJonathan Jaubart                            <input id="<?= e($table_id) ?>-bg-roots-R" class="btn-check" type="checkbox" data-filter-column="15" data-filter-value="R" autocomplete="off">
2273a976702SJonathan Jaubart                            <label for="<?= e($table_id) ?>-bg-roots-R" 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.') ?>">
228dd6b2bfcSGreg Roach                                <?= I18N::translate('Roots') ?>
229604bfd4bSGreg Roach                            </label>
2303a976702SJonathan Jaubart
2313a976702SJonathan Jaubart                            <input id="<?= e($table_id) ?>-bg-roots-L" class="btn-check" type="checkbox" data-filter-column="15" data-filter-value="L" autocomplete="off">
2323a976702SJonathan Jaubart                            <label for="<?= e($table_id) ?>-bg-roots-L" 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.') ?>">
233dd6b2bfcSGreg Roach                                <?= I18N::translate('Leaves') ?>
234604bfd4bSGreg Roach                            </label>
235dd6b2bfcSGreg Roach                        </div>
236dd6b2bfcSGreg Roach                    </div>
237dd6b2bfcSGreg Roach                </th>
238dd6b2bfcSGreg Roach            </tr>
239dd6b2bfcSGreg Roach            <tr>
240dd6b2bfcSGreg Roach                <th><?= I18N::translate('Given names') ?></th>
241dd6b2bfcSGreg Roach                <th><?= I18N::translate('Surname') ?></th>
242dd6b2bfcSGreg Roach                <th><?= /* I18N: Abbreviation for “Sosa-Stradonitz number”. This is an individual’s surname, so may need transliterating into non-latin alphabets. */
243dd6b2bfcSGreg Roach                    I18N::translate('Sosa') ?></th>
244dd6b2bfcSGreg Roach                <th><?= I18N::translate('Birth') ?></th>
245dd6b2bfcSGreg Roach                <th>
246e39fd5c6SGreg Roach                    <span title="<?= I18N::translate('Anniversary') ?>">
247e39fd5c6SGreg Roach                        <?= view('icons/anniversary') ?>
248e39fd5c6SGreg Roach                    </span>
249dd6b2bfcSGreg Roach                </th>
250dd6b2bfcSGreg Roach                <th><?= I18N::translate('Place') ?></th>
251dd6b2bfcSGreg Roach                <th>
252dd6b2bfcSGreg Roach                    <i class="icon-children" title="<?= I18N::translate('Children') ?>"></i>
253dd6b2bfcSGreg Roach                </th>
254dd6b2bfcSGreg Roach                <th><?= I18N::translate('Death') ?></th>
255dd6b2bfcSGreg Roach                <th>
256e39fd5c6SGreg Roach                    <span title="<?= I18N::translate('Anniversary') ?>">
257e39fd5c6SGreg Roach                        <?= view('icons/anniversary') ?>
258e39fd5c6SGreg Roach                    </span>
259dd6b2bfcSGreg Roach                </th>
260dd6b2bfcSGreg Roach                <th><?= I18N::translate('Age') ?></th>
261dd6b2bfcSGreg Roach                <th><?= I18N::translate('Place') ?></th>
262dd6b2bfcSGreg Roach                <th><?= I18N::translate('Last change') ?></th>
263dd6b2bfcSGreg Roach                <th hidden></th>
264dd6b2bfcSGreg Roach                <th hidden></th>
265dd6b2bfcSGreg Roach                <th hidden></th>
266dd6b2bfcSGreg Roach                <th hidden></th>
267dd6b2bfcSGreg Roach            </tr>
268dd6b2bfcSGreg Roach        </thead>
269dd6b2bfcSGreg Roach
270dd6b2bfcSGreg Roach        <tbody>
271dd6b2bfcSGreg Roach            <?php foreach ($individuals as $key => $individual) : ?>
272b16bf9d4SGreg Roach            <tr class="<?= $individual->isPendingAddition() ? 'wt-new' : '' ?> <?= $individual->isPendingDeletion() ? 'wt-old' : '' ?>">
2738fb4e87cSGreg Roach                <td colspan="2" data-sort="<?= e(str_replace([',', Individual::PRAENOMEN_NESCIO, Individual::NOMEN_NESCIO], 'AAAA', implode(',', array_reverse(explode(',', $individual->sortName()))))) ?>">
274dd6b2bfcSGreg Roach                    <?php foreach ($individual->getAllNames() as $num => $name) : ?>
2757a821518SGreg Roach                        <a title="<?= $name['type'] === '_MARNM' ? I18N::translate('Married name') :  '' ?>" href="<?= e($individual->url()) ?>" class="<?= $num === $individual->getPrimaryName() ? '' : 'text-muted' ?>">
276dd6b2bfcSGreg Roach                            <?= $name['full'] ?>
277dd6b2bfcSGreg Roach                        </a>
278dd6b2bfcSGreg Roach                        <?php if ($num === $individual->getPrimaryName()) : ?>
27908362db4SGreg Roach                            <small><?= view('icons/sex', ['sex' => $individual->sex()]) ?></small>
280dd6b2bfcSGreg Roach                        <?php endif ?>
281dd6b2bfcSGreg Roach                        <br>
282dd6b2bfcSGreg Roach                    <?php endforeach ?>
2835e6816beSGreg Roach                    <?= view('lists/individual-table-parents', ['individual' => $individual]) ?>
284dd6b2bfcSGreg Roach                </td>
285dd6b2bfcSGreg Roach
2868fb4e87cSGreg Roach                <td hidden data-sort="<?= e(str_replace([',', Individual::PRAENOMEN_NESCIO, Individual::NOMEN_NESCIO], 'AAAA', $individual->sortName())) ?>"></td>
287dd6b2bfcSGreg Roach
288242a7862SGreg Roach                <td class="text-center" data-sort="<?= $key ?>">
289dd6b2bfcSGreg Roach                    <?php if ($sosa) : ?>
29084b37362SGreg Roach                        <?php if ($module instanceof RelationshipsChartModule) : ?>
29184b37362SGreg Roach                            <a href="<?= e($module->chartUrl($individuals[1], ['xref2' => $individual->xref()])) ?>" rel="nofollow" title="<?= I18N::translate('Relationships') ?>" rel="nofollow">
292dd6b2bfcSGreg Roach                                <?= I18N::number($key) ?>
293dd6b2bfcSGreg Roach                            </a>
29484b37362SGreg Roach                        <?php else : ?>
29584b37362SGreg Roach                            <?= I18N::number($key) ?>
29684b37362SGreg Roach                        <?php endif ?>
297dd6b2bfcSGreg Roach                    <?php endif ?>
298dd6b2bfcSGreg Roach                </td>
299dd6b2bfcSGreg Roach
300dd6b2bfcSGreg Roach                <!-- Birth date -->
301054771e9SGreg Roach                <?php $estimated_birth_date = $individual->getEstimatedBirthDate(); ?>
302054771e9SGreg Roach
303054771e9SGreg Roach                <td data-sort="<?= $estimated_birth_date->julianDay() ?>">
304dd6b2bfcSGreg Roach                    <?php $birth_dates = $individual->getAllBirthDates(); ?>
305dd6b2bfcSGreg Roach
306dd6b2bfcSGreg Roach                    <?php foreach ($birth_dates as $n => $birth_date) : ?>
307*66ecd017SGreg Roach                        <?= $birth_date->display($tree, null, true) ?>
308dd6b2bfcSGreg Roach                        <br>
309dd6b2bfcSGreg Roach                    <?php endforeach ?>
31014147f6fSGreg Roach
311b2a8cedfSGreg Roach                    <?php if (empty($birth_dates) && $show_estimated_dates) : ?>
312*66ecd017SGreg Roach                        <?= $estimated_birth_date->display($tree, null, true) ?>
31314147f6fSGreg Roach                    <?php endif ?>
314dd6b2bfcSGreg Roach                </td>
315dd6b2bfcSGreg Roach
316dd6b2bfcSGreg Roach                <!-- Birth anniversary -->
317c0935879SGreg Roach                <?php if (isset($birth_dates[0]) && $birth_dates[0]->gregorianYear() >= 1550 && $birth_dates[0]->gregorianYear() < 2030 && !isset($unique_indis[$individual->xref()])) : ?>
3181b860509SRico Sonntag                    <?php
3191b860509SRico Sonntag                    ++$birt_by_decade[(int) ($birth_dates[0]->gregorianYear() / 10) * 10][$individual->sex()];
3201b860509SRico Sonntag                    ?>
321dd6b2bfcSGreg Roach                <?php endif ?>
32253432476SGreg Roach                <td class="text-center" data-sort="<?= - $estimated_birth_date->julianDay() ?>">
32353432476SGreg Roach                    <?= (new Age($birth_dates[0] ?? new Date(''), $today))->ageYearsString() ?>
324dd6b2bfcSGreg Roach                </td>
325dd6b2bfcSGreg Roach
326dd6b2bfcSGreg Roach                <!-- Birth place -->
3278c0ff4ddSGreg Roach                <td data-sort="<?= e($individual->getBirthPlace()->gedcomName()) ?>">
328dd6b2bfcSGreg Roach                    <?php foreach ($individual->getAllBirthPlaces() as $n => $birth_place) : ?>
329392561bbSGreg Roach                        <?= $birth_place->shortName(true) ?>
330dd6b2bfcSGreg Roach                        <br>
331dd6b2bfcSGreg Roach                    <?php endforeach ?>
332dd6b2bfcSGreg Roach                </td>
333dd6b2bfcSGreg Roach
334dd6b2bfcSGreg Roach                <!-- Number of children -->
33539ca88baSGreg Roach                <td class="text-center" data-sort="<?= $individual->numberOfChildren() ?>">
33639ca88baSGreg Roach                    <?= I18N::number($individual->numberOfChildren()) ?>
337dd6b2bfcSGreg Roach                </td>
338dd6b2bfcSGreg Roach
339dd6b2bfcSGreg Roach                <!--    Death date -->
340dd6b2bfcSGreg Roach                <?php $death_dates = $individual->getAllDeathDates() ?>
341dd6b2bfcSGreg Roach                <td data-sort="<?= $individual->getEstimatedDeathDate()->julianDay() ?>">
342dd6b2bfcSGreg Roach                    <?php foreach ($death_dates as $num => $death_date) : ?>
343*66ecd017SGreg Roach                        <?= $death_date->display($tree, null, true) ?>
344dd6b2bfcSGreg Roach                    <br>
345dd6b2bfcSGreg Roach                    <?php endforeach ?>
34614147f6fSGreg Roach
347b2a8cedfSGreg Roach                    <?php if (empty($death_dates) && $show_estimated_dates && $individual->getEstimatedDeathDate()->minimumDate()->minimumJulianDay() < $today_jd) : ?>
348*66ecd017SGreg Roach                        <?= $individual->getEstimatedDeathDate()->display($tree, null, true) ?>
34914147f6fSGreg Roach                    <?php endif ?>
350dd6b2bfcSGreg Roach                </td>
351dd6b2bfcSGreg Roach
352dd6b2bfcSGreg Roach                <!-- Death anniversary -->
353c0935879SGreg Roach                <?php if (isset($death_dates[0]) && $death_dates[0]->gregorianYear() >= 1550 && $death_dates[0]->gregorianYear() < 2030 && !isset($unique_indis[$individual->xref()])) : ?>
3541b860509SRico Sonntag                    <?php
3551b860509SRico Sonntag                    ++$deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10][$individual->sex()];
3561b860509SRico Sonntag                    ?>
357dd6b2bfcSGreg Roach                <?php endif ?>
35853432476SGreg Roach                <td class="text-center" data-sort="<?= - $individual->getEstimatedDeathDate()->julianDay() ?>">
35953432476SGreg Roach                    <?= (new Age($death_dates[0] ?? new Date(''), $today))->ageYearsString() ?>
360dd6b2bfcSGreg Roach                </td>
361dd6b2bfcSGreg Roach
362dd6b2bfcSGreg Roach                <!-- Age at death -->
36353432476SGreg Roach                <?php $age = new Age($birth_dates[0] ?? new Date(''), $death_dates[0] ?? new Date('')) ?>
36453432476SGreg Roach                <?php if (!isset($unique_indis[$individual->xref()]) && $age->ageYears() >= 0 && $age->ageYears() <= $max_age) : ?>
36553432476SGreg Roach                    <?php ++$deat_by_age[$age->ageYears()][$individual->sex()] ?>
366dd6b2bfcSGreg Roach                <?php endif ?>
36753432476SGreg Roach                <td class="text-center" data-sort="<?= $age->ageDays() ?>">
36853432476SGreg Roach                    <?= $age->ageYearsString() ?>
369dd6b2bfcSGreg Roach                </td>
370dd6b2bfcSGreg Roach
371dd6b2bfcSGreg Roach                <!-- Death place -->
3728c0ff4ddSGreg Roach                <td data-sort="<?= e($individual->getDeathPlace()->gedcomName()) ?>">
373dd6b2bfcSGreg Roach                    <?php foreach ($individual->getAllDeathPlaces() as $n => $death_place) : ?>
374392561bbSGreg Roach                        <?= $death_place->shortName(true) ?>
375dd6b2bfcSGreg Roach                        <br>
376dd6b2bfcSGreg Roach                    <?php endforeach ?>
377dd6b2bfcSGreg Roach                </td>
378dd6b2bfcSGreg Roach
379dd6b2bfcSGreg Roach                <!-- Last change -->
3804459dc9aSGreg Roach                <td data-sort="<?= $individual->lastChangeTimestamp()->unix() ?>">
3814459dc9aSGreg Roach                    <?= view('components/datetime', ['timestamp' => $individual->lastChangeTimestamp()]) ?>
382dd6b2bfcSGreg Roach                </td>
383dd6b2bfcSGreg Roach
384dd6b2bfcSGreg Roach                <!-- Filter by sex -->
385dd6b2bfcSGreg Roach                <td hidden>
38639ca88baSGreg Roach                    <?= $individual->sex() ?>
387dd6b2bfcSGreg Roach                </td>
388dd6b2bfcSGreg Roach
389dd6b2bfcSGreg Roach                <!-- Filter by birth date -->
390dd6b2bfcSGreg Roach                <td hidden>
391054771e9SGreg Roach                    <?php if ($estimated_birth_date->maximumJulianDay() > $hundred_years_ago && $estimated_birth_date->maximumJulianDay() <= $today_jd) : ?>
392dd6b2bfcSGreg Roach                        Y100
393dd6b2bfcSGreg Roach                    <?php else : ?>
394dd6b2bfcSGreg Roach                        YES
395dd6b2bfcSGreg Roach                    <?php endif ?>
396dd6b2bfcSGreg Roach                </td>
397dd6b2bfcSGreg Roach
398dd6b2bfcSGreg Roach                <!-- Filter by death date -->
399dd6b2bfcSGreg Roach                <td hidden>
400b9597e06SGreg Roach                    <?php if ($individual->getEstimatedDeathDate()->maximumJulianDay() > $hundred_years_ago && $individual->getEstimatedDeathDate()->maximumJulianDay() <= $today_jd) : ?>
401dd6b2bfcSGreg Roach                        Y100
402dd6b2bfcSGreg Roach                    <?php elseif ($individual->isDead()) : ?>
403dd6b2bfcSGreg Roach                        YES
404dd6b2bfcSGreg Roach                    <?php else : ?>
405dd6b2bfcSGreg Roach                        N
406dd6b2bfcSGreg Roach                    <?php endif ?>
407dd6b2bfcSGreg Roach                </td>
408dd6b2bfcSGreg Roach
409dd6b2bfcSGreg Roach                <!-- Filter by roots/leaves -->
410dd6b2bfcSGreg Roach                <td hidden>
41108662657SGreg Roach                    <?php if ($individual->childFamilies()->isEmpty()) : ?>
412dd6b2bfcSGreg Roach                        R
41339ca88baSGreg Roach                    <?php elseif (!$individual->isDead() && $individual->numberOfChildren() < 1) : ?>
414dd6b2bfcSGreg Roach                        L
415dd6b2bfcSGreg Roach                    <?php endif ?>
416dd6b2bfcSGreg Roach                </td>
417dd6b2bfcSGreg Roach            </tr>
418dd6b2bfcSGreg Roach
419c0935879SGreg Roach                <?php $unique_indis[$individual->xref()] = true ?>
420dd6b2bfcSGreg Roach            <?php endforeach ?>
421dd6b2bfcSGreg Roach        </tbody>
4227039fd97SGreg Roach
4237039fd97SGreg Roach        <tfoot>
4247039fd97SGreg Roach            <tr>
4257039fd97SGreg Roach                <th colspan="16">
426604bfd4bSGreg Roach                    <div class="btn-group btn-group-sm">
4272d8276baSGreg Roach                        <input type="checkbox" class="btn-check" id="btn-toggle-parents" autocomplete="off" data-wt-persist="individuals-parents">
4282d8276baSGreg Roach                        <label class="btn btn-secondary" for="btn-toggle-parents">
4297039fd97SGreg Roach                            <?= I18N::translate('Show parents') ?>
4302d8276baSGreg Roach                        </label>
4312d8276baSGreg Roach                        <input type="checkbox" class="btn-check" id="btn-toggle-statistics" autocomplete="off" data-wt-persist="individuals-statistics">
4322d8276baSGreg Roach                        <label class="btn btn-secondary" for="btn-toggle-statistics">
4337039fd97SGreg Roach                            <?= I18N::translate('Show statistics charts') ?>
4342d8276baSGreg Roach                        </label>
4357039fd97SGreg Roach                    </div>
4367039fd97SGreg Roach                </th>
4377039fd97SGreg Roach            </tr>
4387039fd97SGreg Roach        </tfoot>
439dd6b2bfcSGreg Roach    </table>
4401b860509SRico Sonntag</div>
441dd6b2bfcSGreg Roach
4421b860509SRico Sonntag<div id="individual-charts-<?= e($table_id) ?>" style="display: none;">
44361275c55SJonathan Jaubart    <div class="d-grid gap-3 my-3">
44461275c55SJonathan Jaubart        <div class="card">
4451b860509SRico Sonntag            <div class="card-header">
4461b860509SRico Sonntag                <?= I18N::translate('Decade of birth') ?>
4471b860509SRico Sonntag            </div>
4481b860509SRico Sonntag            <div class="card-body">
4491b860509SRico Sonntag                <?php
4501b860509SRico Sonntag                foreach ($birt_by_decade as $century => $values) {
451dd71ff6bSGreg Roach                    if ($values['M'] + $values['F'] > 0) {
4521b860509SRico Sonntag                        $birthData[] = [
4531b860509SRico Sonntag                            [
4541b860509SRico Sonntag                                'v' => 'Date(' . $century . ', 0, 1)',
4551b860509SRico Sonntag                                'f' => $century,
4561b860509SRico Sonntag                            ],
4571b860509SRico Sonntag                            $values['M'],
4581b860509SRico Sonntag                            $values['F'],
4591b860509SRico Sonntag                        ];
4601b860509SRico Sonntag                    }
4611b860509SRico Sonntag                }
4621b860509SRico Sonntag                ?>
4631b860509SRico Sonntag                <?= view('lists/chart-by-decade', ['data' => $birthData, 'title' => I18N::translate('Decade of birth')]) ?>
4641b860509SRico Sonntag            </div>
4651b860509SRico Sonntag        </div>
46661275c55SJonathan Jaubart        <div class="card">
4671b860509SRico Sonntag            <div class="card-header">
4681b860509SRico Sonntag                <?= I18N::translate('Decade of death') ?>
4691b860509SRico Sonntag            </div>
4701b860509SRico Sonntag            <div class="card-body">
4711b860509SRico Sonntag                <?php
4721b860509SRico Sonntag                foreach ($deat_by_decade as $century => $values) {
473dd71ff6bSGreg Roach                    if ($values['M'] + $values['F'] > 0) {
4741b860509SRico Sonntag                        $deathData[] = [
4751b860509SRico Sonntag                            [
4761b860509SRico Sonntag                                'v' => 'Date(' . $century . ', 0, 1)',
4771b860509SRico Sonntag                                'f' => $century,
4781b860509SRico Sonntag                            ],
4791b860509SRico Sonntag                            $values['M'],
4801b860509SRico Sonntag                            $values['F'],
4811b860509SRico Sonntag                        ];
4821b860509SRico Sonntag                    }
4831b860509SRico Sonntag                }
4841b860509SRico Sonntag                ?>
4851b860509SRico Sonntag                <?= view('lists/chart-by-decade', ['data' => $deathData, 'title' => I18N::translate('Decade of death')]) ?>
4861b860509SRico Sonntag            </div>
4871b860509SRico Sonntag        </div>
48861275c55SJonathan Jaubart        <div class="card">
4891b860509SRico Sonntag            <div class="card-header">
4901b860509SRico Sonntag                <?= I18N::translate('Age related to death year') ?>
4911b860509SRico Sonntag            </div>
4921b860509SRico Sonntag            <div class="card-body">
4931b860509SRico Sonntag                <?php
4941b860509SRico Sonntag                    $totalAge = 0;
4951b860509SRico Sonntag                    $totalSum = 0;
4961b860509SRico Sonntag                    $max      = 0;
4971b860509SRico Sonntag
4981b860509SRico Sonntag                foreach ($deat_by_age as $age => $values) {
499dd71ff6bSGreg Roach                    if ($values['M'] + $values['F'] > 0) {
500dd71ff6bSGreg Roach                        if ($values['M'] + $values['F'] > $max) {
5011b860509SRico Sonntag                            $max = $values['M'] + $values['F'];
5021b860509SRico Sonntag                        }
5031b860509SRico Sonntag
5041b860509SRico Sonntag                        $totalAge += $age * ($values['M'] + $values['F']);
5051b860509SRico Sonntag                        $totalSum += $values['M'] + $values['F'];
5061b860509SRico Sonntag
5071b860509SRico Sonntag                        $deathAgeData[] = [
5081b860509SRico Sonntag                            $age,
5091b860509SRico Sonntag                            $values['M'],
5101b860509SRico Sonntag                            $values['F'],
5111b860509SRico Sonntag                            null,
5121b860509SRico Sonntag                        ];
5131b860509SRico Sonntag                    }
5141b860509SRico Sonntag                }
5151b860509SRico Sonntag
5161b860509SRico Sonntag                if ($totalSum > 0) {
5171b860509SRico Sonntag                    $deathAgeData[] = [
5181b860509SRico Sonntag                        round($totalAge / $totalSum, 1),
5191b860509SRico Sonntag                        null,
5201b860509SRico Sonntag                        null,
5211b860509SRico Sonntag                        0,
5221b860509SRico Sonntag                    ];
5231b860509SRico Sonntag
5241b860509SRico Sonntag                    $deathAgeData[] = [
5251b860509SRico Sonntag                        round($totalAge / $totalSum, 1),
5261b860509SRico Sonntag                        null,
5271b860509SRico Sonntag                        null,
5281b860509SRico Sonntag                        $max,
5291b860509SRico Sonntag                    ];
5301b860509SRico Sonntag                }
5311b860509SRico Sonntag                ?>
5321b860509SRico Sonntag                <?= view('lists/chart-by-age', ['data' => $deathAgeData, 'title' => I18N::translate('Age related to death year')]) ?>
5331b860509SRico Sonntag            </div>
5341b860509SRico Sonntag        </div>
5351b860509SRico Sonntag    </div>
5361b860509SRico Sonntag</div>
537