xref: /webtrees/resources/views/lists/individuals-table.phtml (revision e840bf40ea7a0381dfe6da3774108dbcf895d4ca)
1dd6b2bfcSGreg Roach<?php
2d70512abSGreg Roach
31b860509SRico Sonntagdeclare(strict_types=1);
41b860509SRico Sonntag
51b860509SRico Sonntaguse Fisharebest\Webtrees\Auth;
65373aac2SGreg Roachuse Fisharebest\Webtrees\Carbon;
71b860509SRico Sonntaguse Fisharebest\Webtrees\Date;
81b860509SRico Sonntaguse Fisharebest\Webtrees\GedcomTag;
91b860509SRico Sonntaguse Fisharebest\Webtrees\I18N;
1087cca37cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleChartInterface;
111b860509SRico Sonntaguse Fisharebest\Webtrees\Module\ModuleInterface;
121b860509SRico Sonntaguse Fisharebest\Webtrees\Module\RelationshipsChartModule;
131b860509SRico Sonntaguse Fisharebest\Webtrees\Services\ModuleService;
141b860509SRico Sonntaguse Fisharebest\Webtrees\View;
151b860509SRico Sonntaguse Ramsey\Uuid\Uuid;
161b860509SRico Sonntag
17dd6b2bfcSGreg Roach// lists requires a unique ID in case there are multiple lists per page
18dd6b2bfcSGreg Roach$table_id = 'table-indi-' . Uuid::uuid4()->toString();
19dd6b2bfcSGreg Roach
205373aac2SGreg Roach$hundred_years_ago = Carbon::now()->subYears(100)->julianDay();
211b860509SRico Sonntag
22dd6b2bfcSGreg Roach$unique_indis = []; // Don't double-count indis with multiple names.
2384b37362SGreg Roach
24b2a8cedfSGreg Roach$today_jd             = unixtojd();
25b2a8cedfSGreg Roach$show_estimated_dates = (bool) $tree->getPreference('SHOW_EST_LIST_DATES');
26b2a8cedfSGreg Roach
271b860509SRico Sonntag$module = app(ModuleService::class)
2887cca37cSGreg Roach    ->findByComponent(ModuleChartInterface::class, $tree, Auth::user())
290b5fd0a6SGreg Roach    ->first(static function (ModuleInterface $module) {
3090d97cc8SGreg Roach        return $module instanceof RelationshipsChartModule;
3190d97cc8SGreg Roach    });
32dd6b2bfcSGreg Roach?>
33dd6b2bfcSGreg Roach
34dd6b2bfcSGreg Roach<?php View::push('javascript') ?>
35dd6b2bfcSGreg Roach<script>
361b860509SRico Sonntag
37dd6b2bfcSGreg Roach$("#<?= e($table_id) ?>").dataTable({
38dd6b2bfcSGreg Roach    dom: '<"H"<"filtersH_<?= e($table_id) ?>">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_<?= e($table_id) ?>">>',
39dd6b2bfcSGreg Roach    autoWidth: false,
40dd6b2bfcSGreg Roach    processing: true,
41dd6b2bfcSGreg Roach    retrieve: true,
42dd6b2bfcSGreg Roach    columns: [
43dd6b2bfcSGreg Roach        /* Given names  */ { type: "text" },
44dd6b2bfcSGreg Roach        /* Surnames     */ { type: "text" },
45dd6b2bfcSGreg Roach        /* SOSA numnber */ { type: "num", visible: <?= json_encode($sosa) ?> },
46dd6b2bfcSGreg Roach        /* Birth date   */ { type: "num" },
47dd6b2bfcSGreg Roach        /* Anniversary  */ { type: "num" },
48dd6b2bfcSGreg Roach        /* Birthplace   */ { type: "text" },
49dd6b2bfcSGreg Roach        /* Children     */ { type: "num" },
50dd6b2bfcSGreg Roach        /* Deate date   */ { type: "num" },
51dd6b2bfcSGreg Roach        /* Anniversary  */ { type: "num" },
52dd6b2bfcSGreg Roach        /* Age          */ { type: "num" },
53dd6b2bfcSGreg Roach        /* Death place  */ { type: "text" },
54dd6b2bfcSGreg Roach        /* Last change  */ { visible: <?= json_encode($tree->getPreference('SHOW_LAST_CHANGE')) ?> },
55dd6b2bfcSGreg Roach        /* Filter sex   */ { sortable: false },
56dd6b2bfcSGreg Roach        /* Filter birth */ { sortable: false },
57dd6b2bfcSGreg Roach        /* Filter death */ { sortable: false },
58dd6b2bfcSGreg Roach        /* Filter tree  */ { sortable: false }
59dd6b2bfcSGreg Roach    ],
60b2c011d7SGreg Roach    sorting: <?= json_encode($sosa ? [[4, 'asc']] : [[1, 'asc']]) ?>
61dd6b2bfcSGreg Roach});
62dd6b2bfcSGreg Roach
63dd6b2bfcSGreg Roach$("#<?= e($table_id) ?>")
64dd6b2bfcSGreg Roach    /* Hide/show parents */
654843b94fSGreg Roach    .on("click", "#btn-toggle-parents", function() {
665e6816beSGreg Roach        $(".wt-individual-list-parents").slideToggle();
67dd6b2bfcSGreg Roach    })
68dd6b2bfcSGreg Roach    /* Hide/show statistics */
694843b94fSGreg Roach    .on("click", "#btn-toggle-statistics", function() {
701b860509SRico Sonntag        $("#individual-charts-<?= e($table_id) ?>").slideToggle({
711b860509SRico Sonntag            complete: function () {
721b860509SRico Sonntag                // Trigger resize to redraw the chart
731b860509SRico Sonntag                $('div[id^="google-chart-"]').resize();
741b860509SRico Sonntag            }
751b860509SRico Sonntag        });
76dd6b2bfcSGreg Roach    })
77dd6b2bfcSGreg Roach    /* Filter buttons in table header */
78dd6b2bfcSGreg Roach    .on("click", "button[data-filter-column]", function() {
79dd6b2bfcSGreg Roach        var btn = $(this);
80dd6b2bfcSGreg Roach        // De-activate the other buttons in this button group
81dd6b2bfcSGreg Roach        btn.siblings().removeClass("active");
82dd6b2bfcSGreg Roach        // Apply (or clear) this filter
83dd6b2bfcSGreg Roach        var col = $("#<?= e($table_id) ?>").DataTable().column(btn.data("filter-column"));
84dd6b2bfcSGreg Roach        if (btn.hasClass("active")) {
85dd6b2bfcSGreg Roach            col.search("").draw();
86dd6b2bfcSGreg Roach        } else {
87dd6b2bfcSGreg Roach            col.search(btn.data("filter-value")).draw();
88dd6b2bfcSGreg Roach        }
89dd6b2bfcSGreg Roach    });
901b860509SRico Sonntag
91dd6b2bfcSGreg Roach</script>
92dd6b2bfcSGreg Roach<?php View::endpush() ?>
93dd6b2bfcSGreg Roach
94dd6b2bfcSGreg Roach<?php
95dd6b2bfcSGreg Roach$max_age = (int) $tree->getPreference('MAX_ALIVE_AGE');
96dd6b2bfcSGreg Roach
97dd6b2bfcSGreg Roach// Inititialise chart data
98dd6b2bfcSGreg Roach$deat_by_age = [];
99dd6b2bfcSGreg Roachfor ($age = 0; $age <= $max_age; $age++) {
1001b860509SRico Sonntag    $deat_by_age[$age]['M'] = 0;
1011b860509SRico Sonntag    $deat_by_age[$age]['F'] = 0;
1021b860509SRico Sonntag    $deat_by_age[$age]['U'] = 0;
103dd6b2bfcSGreg Roach}
104dd6b2bfcSGreg Roach$birt_by_decade = [];
105dd6b2bfcSGreg Roach$deat_by_decade = [];
1061b860509SRico Sonntagfor ($year = 1400; $year < 2050; $year += 10) {
1071b860509SRico Sonntag    $birt_by_decade[$year]['M'] = 0;
1081b860509SRico Sonntag    $birt_by_decade[$year]['F'] = 0;
1091b860509SRico Sonntag    $birt_by_decade[$year]['U'] = 0;
1101b860509SRico Sonntag    $deat_by_decade[$year]['M'] = 0;
1111b860509SRico Sonntag    $deat_by_decade[$year]['F'] = 0;
1121b860509SRico Sonntag    $deat_by_decade[$year]['U'] = 0;
113dd6b2bfcSGreg Roach}
1141b860509SRico Sonntag
1151b860509SRico Sonntag$birthData = [
1161b860509SRico Sonntag    [
1171b860509SRico Sonntag        [
1181b860509SRico Sonntag            'label' => I18N::translate('Century'),
1191b860509SRico Sonntag            'type'  => 'date',
1201b860509SRico Sonntag        ], [
1211b860509SRico Sonntag            'label' => I18N::translate('Males'),
1221b860509SRico Sonntag            'type'  => 'number',
1231b860509SRico Sonntag        ], [
1241b860509SRico Sonntag            'label' => I18N::translate('Females'),
1251b860509SRico Sonntag            'type'  => 'number',
1261b860509SRico Sonntag        ],
1271b860509SRico Sonntag    ]
1281b860509SRico Sonntag];
1291b860509SRico Sonntag
1301b860509SRico Sonntag$deathData = [
1311b860509SRico Sonntag    [
1321b860509SRico Sonntag        [
1331b860509SRico Sonntag            'label' => I18N::translate('Century'),
1341b860509SRico Sonntag            'type'  => 'date',
1351b860509SRico Sonntag        ], [
1361b860509SRico Sonntag            'label' => I18N::translate('Males'),
1371b860509SRico Sonntag            'type'  => 'number',
1381b860509SRico Sonntag        ], [
1391b860509SRico Sonntag            'label' => I18N::translate('Females'),
1401b860509SRico Sonntag            'type'  => 'number',
1411b860509SRico Sonntag        ],
1421b860509SRico Sonntag    ]
1431b860509SRico Sonntag];
1441b860509SRico Sonntag
1451b860509SRico Sonntag$deathAgeData = [
1461b860509SRico Sonntag    [
1471b860509SRico Sonntag        I18N::translate('Age'),
1481b860509SRico Sonntag        I18N::translate('Males'),
1491b860509SRico Sonntag        I18N::translate('Females'),
1501b860509SRico Sonntag        I18N::translate('Average age'),
1511b860509SRico Sonntag    ]
1521b860509SRico Sonntag];
1531b860509SRico Sonntag
154dd6b2bfcSGreg Roach?>
155dd6b2bfcSGreg Roach
156dd6b2bfcSGreg Roach<div class="indi-list">
1575529b85eSGreg Roach    <table id="<?= e($table_id) ?>" class="table-bordered"
158b6c326d8SGreg Roach        <?= view('lists/datatables-attributes') ?>
159b6c326d8SGreg Roach    >
160dd6b2bfcSGreg Roach        <thead>
161dd6b2bfcSGreg Roach            <tr>
162dd6b2bfcSGreg Roach                <th colspan="16">
163dd6b2bfcSGreg Roach                    <div class="btn-toolbar d-flex justify-content-between mb-2" role="toolbar">
164dd6b2bfcSGreg Roach                        <div class="btn-group" data-toggle="buttons">
165dd6b2bfcSGreg Roach                            <button
166dd6b2bfcSGreg Roach                                class="btn btn-secondary"
167dd6b2bfcSGreg Roach                                data-filter-column="12"
168dd6b2bfcSGreg Roach                                data-filter-value="M"
169dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show only males.') ?>"
170dd6b2bfcSGreg Roach                            >
17108362db4SGreg Roach                                <?= view('icons/sex', ['sex' => 'M']) ?>
172dd6b2bfcSGreg Roach                            </button>
173dd6b2bfcSGreg Roach                            <button
174dd6b2bfcSGreg Roach                                class="btn btn-secondary"
175dd6b2bfcSGreg Roach                                data-filter-column="12"
176dd6b2bfcSGreg Roach                                data-filter-value="F"
177dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show only females.') ?>"
178dd6b2bfcSGreg Roach                            >
17908362db4SGreg Roach                                <?= view('icons/sex', ['sex' => 'F']) ?>
180dd6b2bfcSGreg Roach                            </button>
181dd6b2bfcSGreg Roach                            <button
182dd6b2bfcSGreg Roach                                class="btn btn-secondary"
183dd6b2bfcSGreg Roach                                data-filter-column="12"
184dd6b2bfcSGreg Roach                                data-filter-value="U"
185dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show only individuals for whom the gender is not known.') ?>"
186dd6b2bfcSGreg Roach                            >
18708362db4SGreg Roach                                <?= view('icons/sex', ['sex' => 'U']) ?>
188dd6b2bfcSGreg Roach                            </button>
189dd6b2bfcSGreg Roach                        </div>
190dd6b2bfcSGreg Roach                        <div class="btn-group" data-toggle="buttons">
191dd6b2bfcSGreg Roach                            <button
192dd6b2bfcSGreg Roach                                class="btn btn-secondary"
193dd6b2bfcSGreg Roach                                data-filter-column="14"
194dd6b2bfcSGreg Roach                                data-filter-value="N"
195dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show individuals who are alive or couples where both partners are alive.') ?>"
196dd6b2bfcSGreg Roach                            >
197dd6b2bfcSGreg Roach                                <?= I18N::translate('Alive') ?>
198dd6b2bfcSGreg Roach                            </button>
199dd6b2bfcSGreg Roach                            <button
200dd6b2bfcSGreg Roach                                class="btn btn-secondary"
201dd6b2bfcSGreg Roach                                data-filter-column="14"
202dd6b2bfcSGreg Roach                                data-filter-value="Y"
203dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show individuals who are dead or couples where both partners are dead.') ?>"
204dd6b2bfcSGreg Roach                            >
205dd6b2bfcSGreg Roach                                <?= I18N::translate('Dead') ?>
206dd6b2bfcSGreg Roach                            </button>
207dd6b2bfcSGreg Roach                            <button
208dd6b2bfcSGreg Roach                                class="btn btn-secondary"
209dd6b2bfcSGreg Roach                                data-filter-column="14"
210dd6b2bfcSGreg Roach                                data-filter-value="YES"
211dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show individuals who died more than 100 years ago.') ?>"
212dd6b2bfcSGreg Roach                            >
213dd6b2bfcSGreg Roach                                <?= I18N::translate('Death') ?>&gt;100
214dd6b2bfcSGreg Roach                            </button>
215dd6b2bfcSGreg Roach                            <button
216dd6b2bfcSGreg Roach                                class="btn btn-secondary"
217dd6b2bfcSGreg Roach                                data-filter-column="14"
218dd6b2bfcSGreg Roach                                data-filter-value="Y100"
219dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show individuals who died within the last 100 years.') ?>"
220dd6b2bfcSGreg Roach                            >
221392561bbSGreg Roach                                <?= I18N::translate('Death') ?>&lt;=100
222dd6b2bfcSGreg Roach                            </button>
223dd6b2bfcSGreg Roach                        </div>
224dd6b2bfcSGreg Roach                        <div class="btn-group" data-toggle="buttons">
225dd6b2bfcSGreg Roach                            <button
226dd6b2bfcSGreg Roach                                class="btn btn-secondary"
227dd6b2bfcSGreg Roach                                data-filter-column="13"
228dd6b2bfcSGreg Roach                                data-filter-value="YES"
229dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show individuals born more than 100 years ago.') ?>"
230dd6b2bfcSGreg Roach                            >
231dd6b2bfcSGreg Roach                                <?= I18N::translate('Birth') ?>&gt;100
232dd6b2bfcSGreg Roach                            </button>
233dd6b2bfcSGreg Roach                            <button
234dd6b2bfcSGreg Roach                                class="btn btn-secondary"
235dd6b2bfcSGreg Roach                                data-filter-column="13"
236dd6b2bfcSGreg Roach                                data-filter-value="Y100"
237dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show individuals born within the last 100 years.') ?>"
238dd6b2bfcSGreg Roach                            >
239dd6b2bfcSGreg Roach                                <?= I18N::translate('Birth') ?>&lt;=100
240dd6b2bfcSGreg Roach                            </button>
241dd6b2bfcSGreg Roach                        </div>
242dd6b2bfcSGreg Roach                        <div class="btn-group" data-toggle="buttons">
243dd6b2bfcSGreg Roach                            <button
244dd6b2bfcSGreg Roach                                class="btn btn-secondary"
245dd6b2bfcSGreg Roach                                data-filter-column="15"
246dd6b2bfcSGreg Roach                                data-filter-value="R"
247dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show “roots” couples or individuals. These individuals may also be called “patriarchs”. They are individuals who have no parents recorded in the database.') ?>"
248dd6b2bfcSGreg Roach                            >
249dd6b2bfcSGreg Roach                                <?= I18N::translate('Roots') ?>
250dd6b2bfcSGreg Roach                            </button>
251dd6b2bfcSGreg Roach                            <button
252dd6b2bfcSGreg Roach                                class="btn btn-secondary"
253dd6b2bfcSGreg Roach                                data-filter-column="15"
254dd6b2bfcSGreg Roach                                data-filter-value="L"
255dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show “leaves” couples or individuals. These are individuals who are alive but have no children recorded in the database.') ?>"
256dd6b2bfcSGreg Roach                            >
257dd6b2bfcSGreg Roach                                <?= I18N::translate('Leaves') ?>
258dd6b2bfcSGreg Roach                            </button>
259dd6b2bfcSGreg Roach                        </div>
260dd6b2bfcSGreg Roach                    </div>
261dd6b2bfcSGreg Roach                </th>
262dd6b2bfcSGreg Roach            </tr>
263dd6b2bfcSGreg Roach            <tr>
264dd6b2bfcSGreg Roach                <th><?= I18N::translate('Given names') ?></th>
265dd6b2bfcSGreg Roach                <th><?= I18N::translate('Surname') ?></th>
266dd6b2bfcSGreg Roach                <th><?= /* I18N: Abbreviation for “Sosa-Stradonitz number”. This is an individual’s surname, so may need transliterating into non-latin alphabets. */
267dd6b2bfcSGreg Roach                    I18N::translate('Sosa') ?></th>
268dd6b2bfcSGreg Roach                <th><?= I18N::translate('Birth') ?></th>
269dd6b2bfcSGreg Roach                <th>
270e39fd5c6SGreg Roach                    <span title="<?= I18N::translate('Anniversary') ?>">
271e39fd5c6SGreg Roach                        <?= view('icons/anniversary') ?>
272e39fd5c6SGreg Roach                    </span>
273dd6b2bfcSGreg Roach                </th>
274dd6b2bfcSGreg Roach                <th><?= I18N::translate('Place') ?></th>
275dd6b2bfcSGreg Roach                <th>
276dd6b2bfcSGreg Roach                    <i class="icon-children" title="<?= I18N::translate('Children') ?>"></i>
277dd6b2bfcSGreg Roach                </th>
278dd6b2bfcSGreg Roach                <th><?= I18N::translate('Death') ?></th>
279dd6b2bfcSGreg Roach                <th>
280e39fd5c6SGreg Roach                    <span title="<?= I18N::translate('Anniversary') ?>">
281e39fd5c6SGreg Roach                        <?= view('icons/anniversary') ?>
282e39fd5c6SGreg Roach                    </span>
283dd6b2bfcSGreg Roach                </th>
284dd6b2bfcSGreg Roach                <th><?= I18N::translate('Age') ?></th>
285dd6b2bfcSGreg Roach                <th><?= I18N::translate('Place') ?></th>
286dd6b2bfcSGreg Roach                <th><?= I18N::translate('Last change') ?></th>
287dd6b2bfcSGreg Roach                <th hidden></th>
288dd6b2bfcSGreg Roach                <th hidden></th>
289dd6b2bfcSGreg Roach                <th hidden></th>
290dd6b2bfcSGreg Roach                <th hidden></th>
291dd6b2bfcSGreg Roach            </tr>
292dd6b2bfcSGreg Roach        </thead>
293dd6b2bfcSGreg Roach        <tfoot>
294dd6b2bfcSGreg Roach            <tr>
295dd6b2bfcSGreg Roach                <th colspan="16">
2964843b94fSGreg Roach                    <div class="btn-group m-1">
2974843b94fSGreg Roach                        <button id="btn-toggle-parents" class="btn btn-secondary" data-toggle="button" data-persist="show-parents">
298dd6b2bfcSGreg Roach                            <?= I18N::translate('Show parents') ?>
299dd6b2bfcSGreg Roach                        </button>
3004843b94fSGreg Roach                        <button id="btn-toggle-statistics" class="btn btn-secondary" data-toggle="button" data-persist="show-statistics">
301dd6b2bfcSGreg Roach                            <?= I18N::translate('Show statistics charts') ?>
302dd6b2bfcSGreg Roach                        </button>
303dd6b2bfcSGreg Roach                    </div>
304dd6b2bfcSGreg Roach                </th>
305dd6b2bfcSGreg Roach            </tr>
306dd6b2bfcSGreg Roach        </tfoot>
307dd6b2bfcSGreg Roach
308dd6b2bfcSGreg Roach        <tbody>
309dd6b2bfcSGreg Roach            <?php foreach ($individuals as $key => $individual) : ?>
31017dd427eSGreg Roach            <tr class="<?= $individual->isPendingDeletion() ? 'wt-old' : ($individual->isPendingAddition() ? 'wt-new' : '') ?>">
31139ca88baSGreg Roach                <td colspan="2" data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', implode(',', array_reverse(explode(',', $individual->sortName()))))) ?>">
312dd6b2bfcSGreg Roach                    <?php foreach ($individual->getAllNames() as $num => $name) : ?>
313*e840bf40SGreg Roach                        <a title="<?= $name['type'] === 'NAME' ? '' : strip_tags(GedcomTag::getLabel($name['type'], $individual)) ?>" href="<?= e($individual->url()) ?>" class="<?= $num === $individual->getPrimaryName() ? 'name2' : '' ?>">
314dd6b2bfcSGreg Roach                            <?= $name['full'] ?>
315dd6b2bfcSGreg Roach                        </a>
316dd6b2bfcSGreg Roach                        <?php if ($num === $individual->getPrimaryName()) : ?>
31708362db4SGreg Roach                            <small><?= view('icons/sex', ['sex' => $individual->sex()]) ?></small>
318dd6b2bfcSGreg Roach                        <?php endif ?>
319dd6b2bfcSGreg Roach                        <br>
320dd6b2bfcSGreg Roach                    <?php endforeach ?>
3215e6816beSGreg Roach                    <?= view('lists/individual-table-parents', ['individual' => $individual]) ?>
322dd6b2bfcSGreg Roach                </td>
323dd6b2bfcSGreg Roach
32439ca88baSGreg Roach                <td hidden data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', $individual->sortName())) ?>"></td>
325dd6b2bfcSGreg Roach
326242a7862SGreg Roach                <td class="text-center" data-sort="<?= $key ?>">
327dd6b2bfcSGreg Roach                    <?php if ($sosa) : ?>
32884b37362SGreg Roach                        <?php if ($module instanceof RelationshipsChartModule) : ?>
32984b37362SGreg Roach                            <a href="<?= e($module->chartUrl($individuals[1], ['xref2' => $individual->xref()])) ?>" rel="nofollow" title="<?= I18N::translate('Relationships') ?>" rel="nofollow">
330dd6b2bfcSGreg Roach                                <?= I18N::number($key) ?>
331dd6b2bfcSGreg Roach                            </a>
33284b37362SGreg Roach                        <?php else : ?>
33384b37362SGreg Roach                            <?= I18N::number($key) ?>
33484b37362SGreg Roach                        <?php endif ?>
335dd6b2bfcSGreg Roach                    <?php endif ?>
336dd6b2bfcSGreg Roach                </td>
337dd6b2bfcSGreg Roach
338dd6b2bfcSGreg Roach                <!-- Birth date -->
339dd6b2bfcSGreg Roach                <td data-sort="<?= $individual->getEstimatedBirthDate()->julianDay() ?>">
340dd6b2bfcSGreg Roach                    <?php $birth_dates = $individual->getAllBirthDates(); ?>
341dd6b2bfcSGreg Roach
342dd6b2bfcSGreg Roach                    <?php foreach ($birth_dates as $n => $birth_date) : ?>
343dd6b2bfcSGreg Roach                        <?= $birth_date->display(true) ?>
344dd6b2bfcSGreg Roach                        <br>
345dd6b2bfcSGreg Roach                    <?php endforeach ?>
34614147f6fSGreg Roach
347b2a8cedfSGreg Roach                    <?php if (empty($birth_dates) && $show_estimated_dates) : ?>
34814147f6fSGreg Roach                        <?= $individual->getEstimatedBirthDate()->display(true) ?>
34914147f6fSGreg Roach                    <?php endif ?>
350dd6b2bfcSGreg Roach                </td>
351dd6b2bfcSGreg Roach
352dd6b2bfcSGreg Roach                <!-- Birth anniversary -->
353242a7862SGreg Roach                <td class="text-center" data-sort="<?= - $individual->getEstimatedBirthDate()->julianDay() ?>">
354c0935879SGreg Roach                    <?php if (isset($birth_dates[0]) && $birth_dates[0]->gregorianYear() >= 1550 && $birth_dates[0]->gregorianYear() < 2030 && !isset($unique_indis[$individual->xref()])) : ?>
3551b860509SRico Sonntag                        <?php
3561b860509SRico Sonntag                            ++$birt_by_decade[(int) ($birth_dates[0]->gregorianYear() / 10) * 10][$individual->sex()];
3571b860509SRico Sonntag                        ?>
3581b860509SRico Sonntag                        <?= Date::getAge($birth_dates[0]) ?>
359dd6b2bfcSGreg Roach                    <?php endif ?>
360dd6b2bfcSGreg Roach                </td>
361dd6b2bfcSGreg Roach
362dd6b2bfcSGreg Roach                <!-- Birth place -->
363dd6b2bfcSGreg Roach                <td>
364dd6b2bfcSGreg Roach                    <?php foreach ($individual->getAllBirthPlaces() as $n => $birth_place) : ?>
365392561bbSGreg Roach                        <?= $birth_place->shortName(true) ?>
366dd6b2bfcSGreg Roach                        <br>
367dd6b2bfcSGreg Roach                    <?php endforeach ?>
368dd6b2bfcSGreg Roach                </td>
369dd6b2bfcSGreg Roach
370dd6b2bfcSGreg Roach                <!-- Number of children -->
37139ca88baSGreg Roach                <td class="text-center" data-sort="<?= $individual->numberOfChildren() ?>">
37239ca88baSGreg Roach                    <?= I18N::number($individual->numberOfChildren()) ?>
373dd6b2bfcSGreg Roach                </td>
374dd6b2bfcSGreg Roach
375dd6b2bfcSGreg Roach                <!--    Death date -->
376dd6b2bfcSGreg Roach                <?php $death_dates = $individual->getAllDeathDates() ?>
377dd6b2bfcSGreg Roach                <td data-sort="<?= $individual->getEstimatedDeathDate()->julianDay() ?>">
378dd6b2bfcSGreg Roach                    <?php foreach ($death_dates as $num => $death_date) : ?>
379dd6b2bfcSGreg Roach                        <?= $death_date->display(true) ?>
380dd6b2bfcSGreg Roach                    <br>
381dd6b2bfcSGreg Roach                    <?php endforeach ?>
38214147f6fSGreg Roach
383b2a8cedfSGreg Roach                    <?php if (empty($death_dates) && $show_estimated_dates && $individual->getEstimatedDeathDate()->minimumDate()->minimumJulianDay() < $today_jd) : ?>
38414147f6fSGreg Roach                        <?= $individual->getEstimatedDeathDate()->display(true) ?>
38514147f6fSGreg Roach                    <?php endif ?>
386dd6b2bfcSGreg Roach                </td>
387dd6b2bfcSGreg Roach
388dd6b2bfcSGreg Roach                <!-- Death anniversary -->
389242a7862SGreg Roach                <td class="text-center" data-sort="<?= - $individual->getEstimatedDeathDate()->julianDay() ?>">
390c0935879SGreg Roach                    <?php if (isset($death_dates[0]) && $death_dates[0]->gregorianYear() >= 1550 && $death_dates[0]->gregorianYear() < 2030 && !isset($unique_indis[$individual->xref()])) : ?>
3911b860509SRico Sonntag                        <?php
3921b860509SRico Sonntag                            ++$deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10][$individual->sex()];
3931b860509SRico Sonntag                        ?>
3941b860509SRico Sonntag                        <?= Date::getAge($death_dates[0]) ?>
395dd6b2bfcSGreg Roach                    <?php endif ?>
396dd6b2bfcSGreg Roach                </td>
397dd6b2bfcSGreg Roach
398dd6b2bfcSGreg Roach                <!-- Age at death -->
3993cfcc809SGreg Roach                <?php if (isset($birth_dates[0], $death_dates[0])) : ?>
40057ab2231SGreg Roach                    <?php $age_at_death_years = Date::getAgeYears($birth_dates[0], $death_dates[0]); ?>
401dd6b2bfcSGreg Roach                    <?php $age_at_death_sort = Date::getAge($birth_dates[0], $death_dates[0]); ?>
4024e96702fSGreg Roach                    <?php $age_at_death_display = I18N::number($age_at_death_years); ?>
4034e96702fSGreg Roach                    <?php if (!isset($unique_indis[$individual->xref()]) && $age_at_death_years >= 0 && $age_at_death_years <= $max_age) : ?>
4041b860509SRico Sonntag                        <?php
4054e96702fSGreg Roach                            ++$deat_by_age[$age_at_death_years][$individual->sex()];
4061b860509SRico Sonntag                        ?>
407dd6b2bfcSGreg Roach                    <?php endif ?>
408dd6b2bfcSGreg Roach                <?php else : ?>
4094e96702fSGreg Roach                    <?php $age_at_death_display = ''; ?>
410dd6b2bfcSGreg Roach                    <?php $age_at_death_sort = PHP_INT_MAX; ?>
411dd6b2bfcSGreg Roach                <?php endif ?>
412242a7862SGreg Roach                <td class="text-center" data-sort="<?= e($age_at_death_sort) ?>">
4134e96702fSGreg Roach                    <?= e($age_at_death_display) ?>
414dd6b2bfcSGreg Roach                </td>
415dd6b2bfcSGreg Roach
416dd6b2bfcSGreg Roach                <!-- Death place -->
417dd6b2bfcSGreg Roach                <td>
418dd6b2bfcSGreg Roach                    <?php foreach ($individual->getAllDeathPlaces() as $n => $death_place) : ?>
419392561bbSGreg Roach                        <?= $death_place->shortName(true) ?>
420dd6b2bfcSGreg Roach                        <br>
421dd6b2bfcSGreg Roach                    <?php endforeach ?>
422dd6b2bfcSGreg Roach                </td>
423dd6b2bfcSGreg Roach
424dd6b2bfcSGreg Roach                <!-- Last change -->
4254459dc9aSGreg Roach                <td data-sort="<?= $individual->lastChangeTimestamp()->unix() ?>">
4264459dc9aSGreg Roach                    <?= view('components/datetime', ['timestamp' => $individual->lastChangeTimestamp()]) ?>
427dd6b2bfcSGreg Roach                </td>
428dd6b2bfcSGreg Roach
429dd6b2bfcSGreg Roach                <!-- Filter by sex -->
430dd6b2bfcSGreg Roach                <td hidden>
43139ca88baSGreg Roach                    <?= $individual->sex() ?>
432dd6b2bfcSGreg Roach                </td>
433dd6b2bfcSGreg Roach
434dd6b2bfcSGreg Roach                <!-- Filter by birth date -->
435dd6b2bfcSGreg Roach                <td hidden>
4365373aac2SGreg Roach                    <?php if (!$individual->canShow() || $individual->getEstimatedBirthDate()->maximumJulianDay() > $hundred_years_ago) : ?>
437dd6b2bfcSGreg Roach                        Y100
438dd6b2bfcSGreg Roach                    <?php else : ?>
439dd6b2bfcSGreg Roach                        YES
440dd6b2bfcSGreg Roach                    <?php endif ?>
441dd6b2bfcSGreg Roach                </td>
442dd6b2bfcSGreg Roach
443dd6b2bfcSGreg Roach                <!-- Filter by death date -->
444dd6b2bfcSGreg Roach                <td hidden>
4455373aac2SGreg Roach                    <?php if ($individual->getEstimatedDeathDate()->maximumJulianDay() > $hundred_years_ago) : ?>
446dd6b2bfcSGreg Roach                        Y100
447dd6b2bfcSGreg Roach                    <?php elseif ($individual->isDead()) : ?>
448dd6b2bfcSGreg Roach                        YES
449dd6b2bfcSGreg Roach                    <?php else : ?>
450dd6b2bfcSGreg Roach                        N
451dd6b2bfcSGreg Roach                    <?php endif ?>
452dd6b2bfcSGreg Roach                </td>
453dd6b2bfcSGreg Roach
454dd6b2bfcSGreg Roach                <!-- Filter by roots/leaves -->
455dd6b2bfcSGreg Roach                <td hidden>
45608662657SGreg Roach                    <?php if ($individual->childFamilies()->isEmpty()) : ?>
457dd6b2bfcSGreg Roach                        R
45839ca88baSGreg Roach                    <?php elseif (!$individual->isDead() && $individual->numberOfChildren() < 1) : ?>
459dd6b2bfcSGreg Roach                        L
460dd6b2bfcSGreg Roach                    <?php endif ?>
461dd6b2bfcSGreg Roach                </td>
462dd6b2bfcSGreg Roach            </tr>
463dd6b2bfcSGreg Roach
464c0935879SGreg Roach                <?php $unique_indis[$individual->xref()] = true ?>
465dd6b2bfcSGreg Roach            <?php endforeach ?>
466dd6b2bfcSGreg Roach        </tbody>
467dd6b2bfcSGreg Roach    </table>
4681b860509SRico Sonntag</div>
469dd6b2bfcSGreg Roach
4701b860509SRico Sonntag<div id="individual-charts-<?= e($table_id) ?>" style="display: none;">
4711b860509SRico Sonntag    <div class="mb-3">
4721b860509SRico Sonntag        <div class="card-deck">
4731b860509SRico Sonntag            <div class="col-lg-12 col-md-12 mb-3">
4741b860509SRico Sonntag                <div class="card m-0">
4751b860509SRico Sonntag                    <div class="card-header">
4761b860509SRico Sonntag                        <?= I18N::translate('Decade of birth') ?>
4771b860509SRico Sonntag                    </div>
4781b860509SRico Sonntag                    <div class="card-body">
4791b860509SRico Sonntag                        <?php
4801b860509SRico Sonntag                        foreach ($birt_by_decade as $century => $values) {
4811b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
4821b860509SRico Sonntag                                $birthData[] = [
4831b860509SRico Sonntag                                    [
4841b860509SRico Sonntag                                        'v' => 'Date(' . $century . ', 0, 1)',
4851b860509SRico Sonntag                                        'f' => $century,
4861b860509SRico Sonntag                                    ],
4871b860509SRico Sonntag                                    $values['M'],
4881b860509SRico Sonntag                                    $values['F'],
4891b860509SRico Sonntag                                ];
4901b860509SRico Sonntag                            }
4911b860509SRico Sonntag                        }
4921b860509SRico Sonntag                        ?>
4931b860509SRico Sonntag                        <?= view('lists/chart-by-decade', ['data' => $birthData, 'title' => I18N::translate('Decade of birth')]) ?>
4941b860509SRico Sonntag                    </div>
4951b860509SRico Sonntag                </div>
4961b860509SRico Sonntag            </div>
4971b860509SRico Sonntag        </div>
4981b860509SRico Sonntag        <div class="card-deck">
4991b860509SRico Sonntag            <div class="col-lg-12 col-md-12 mb-3">
5001b860509SRico Sonntag                <div class="card m-0">
5011b860509SRico Sonntag                    <div class="card-header">
5021b860509SRico Sonntag                        <?= I18N::translate('Decade of death') ?>
5031b860509SRico Sonntag                    </div>
5041b860509SRico Sonntag                    <div class="card-body">
5051b860509SRico Sonntag                        <?php
5061b860509SRico Sonntag                        foreach ($deat_by_decade as $century => $values) {
5071b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
5081b860509SRico Sonntag                                $deathData[] = [
5091b860509SRico Sonntag                                    [
5101b860509SRico Sonntag                                        'v' => 'Date(' . $century . ', 0, 1)',
5111b860509SRico Sonntag                                        'f' => $century,
5121b860509SRico Sonntag                                    ],
5131b860509SRico Sonntag                                    $values['M'],
5141b860509SRico Sonntag                                    $values['F'],
5151b860509SRico Sonntag                                ];
5161b860509SRico Sonntag                            }
5171b860509SRico Sonntag                        }
5181b860509SRico Sonntag                        ?>
5191b860509SRico Sonntag                        <?= view('lists/chart-by-decade', ['data' => $deathData, 'title' => I18N::translate('Decade of death')]) ?>
5201b860509SRico Sonntag                    </div>
5211b860509SRico Sonntag                </div>
5221b860509SRico Sonntag            </div>
5231b860509SRico Sonntag        </div>
5241b860509SRico Sonntag        <div class="card-deck">
5251b860509SRico Sonntag            <div class="col-lg-12 col-md-12 mb-3">
5261b860509SRico Sonntag                <div class="card m-0">
5271b860509SRico Sonntag                    <div class="card-header">
5281b860509SRico Sonntag                        <?= I18N::translate('Age related to death year') ?>
5291b860509SRico Sonntag                    </div>
5301b860509SRico Sonntag                    <div class="card-body">
5311b860509SRico Sonntag                        <?php
5321b860509SRico Sonntag                            $totalAge = 0;
5331b860509SRico Sonntag                            $totalSum = 0;
5341b860509SRico Sonntag                            $max      = 0;
5351b860509SRico Sonntag
5361b860509SRico Sonntag                        foreach ($deat_by_age as $age => $values) {
5371b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
5381b860509SRico Sonntag                                if (($values['M'] + $values['F']) > $max) {
5391b860509SRico Sonntag                                    $max = $values['M'] + $values['F'];
5401b860509SRico Sonntag                                }
5411b860509SRico Sonntag
5421b860509SRico Sonntag                                $totalAge += $age * ($values['M'] + $values['F']);
5431b860509SRico Sonntag                                $totalSum += $values['M'] + $values['F'];
5441b860509SRico Sonntag
5451b860509SRico Sonntag                                $deathAgeData[] = [
5461b860509SRico Sonntag                                    $age,
5471b860509SRico Sonntag                                    $values['M'],
5481b860509SRico Sonntag                                    $values['F'],
5491b860509SRico Sonntag                                    null,
5501b860509SRico Sonntag                                ];
5511b860509SRico Sonntag                            }
5521b860509SRico Sonntag                        }
5531b860509SRico Sonntag
5541b860509SRico Sonntag                        if ($totalSum > 0) {
5551b860509SRico Sonntag                            $deathAgeData[] = [
5561b860509SRico Sonntag                                round($totalAge / $totalSum, 1),
5571b860509SRico Sonntag                                null,
5581b860509SRico Sonntag                                null,
5591b860509SRico Sonntag                                0,
5601b860509SRico Sonntag                            ];
5611b860509SRico Sonntag
5621b860509SRico Sonntag                            $deathAgeData[] = [
5631b860509SRico Sonntag                                round($totalAge / $totalSum, 1),
5641b860509SRico Sonntag                                null,
5651b860509SRico Sonntag                                null,
5661b860509SRico Sonntag                                $max,
5671b860509SRico Sonntag                            ];
5681b860509SRico Sonntag                        }
5691b860509SRico Sonntag                        ?>
5701b860509SRico Sonntag                        <?= view('lists/chart-by-age', ['data' => $deathAgeData, 'title' => I18N::translate('Age related to death year')]) ?>
5711b860509SRico Sonntag                    </div>
5721b860509SRico Sonntag                </div>
5731b860509SRico Sonntag            </div>
5741b860509SRico Sonntag        </div>
575dd6b2bfcSGreg Roach    </div>
576dd6b2bfcSGreg Roach</div>
577