xref: /webtrees/resources/views/lists/families-table.phtml (revision a091ac74647eab281b25090b737835eeea14ae10)
1dd6b2bfcSGreg Roach<?php
2d70512abSGreg Roach
31b860509SRico Sonntagdeclare(strict_types=1);
41b860509SRico Sonntag
5054771e9SGreg Roachuse Fisharebest\Webtrees\Age;
65373aac2SGreg Roachuse Fisharebest\Webtrees\Carbon;
71b860509SRico Sonntaguse Fisharebest\Webtrees\Date;
8*a091ac74SGreg Roachuse Fisharebest\Webtrees\Factory;
9054771e9SGreg Roachuse Fisharebest\Webtrees\Family;
101b860509SRico Sonntaguse Fisharebest\Webtrees\GedcomTag;
111b860509SRico Sonntaguse Fisharebest\Webtrees\I18N;
12054771e9SGreg Roachuse Fisharebest\Webtrees\Tree;
131b860509SRico Sonntaguse Fisharebest\Webtrees\View;
14054771e9SGreg Roachuse Illuminate\Support\Collection;
151b860509SRico Sonntaguse Ramsey\Uuid\Uuid;
161b860509SRico Sonntag
17dd6b2bfcSGreg Roach$table_id = 'table-fam-' . Uuid::uuid4()->toString(); // lists requires a unique ID in case there are multiple lists per page
181b860509SRico Sonntag
1953432476SGreg Roach$today             = new Date(strtoupper(date('d M Y')));
20b9597e06SGreg Roach$today_jd          = Carbon::now()->julianDay();
215373aac2SGreg Roach$hundred_years_ago = Carbon::now()->subYears(100)->julianDay();
225373aac2SGreg Roach
23054771e9SGreg Roach/**
24054771e9SGreg Roach * @var Tree               $tree
25054771e9SGreg Roach * @var Collection<Family> $families
26054771e9SGreg Roach */
27054771e9SGreg Roach
28dd6b2bfcSGreg Roach?>
29dd6b2bfcSGreg Roach
30dd6b2bfcSGreg Roach<?php View::push('javascript') ?>
31dd6b2bfcSGreg Roach<script>
3232a5dd8dSGreg Roach$("#<?= e($table_id) ?> > .wt-table-family").dataTable({
33dd6b2bfcSGreg Roach    processing: true,
34dd6b2bfcSGreg Roach    retrieve: true,
35dd6b2bfcSGreg Roach    columns: [
36dd6b2bfcSGreg Roach        /* Given names       */ { type: "text" },
37dd6b2bfcSGreg Roach        /* Surnames          */ { type: "text" },
38dd6b2bfcSGreg Roach        /* Age               */ { type: "num" },
39dd6b2bfcSGreg Roach        /* Given names       */ { type: "text" },
40dd6b2bfcSGreg Roach        /* Surnames          */ { type: "text" },
41dd6b2bfcSGreg Roach        /* Age               */ { type: "num" },
42dd6b2bfcSGreg Roach        /* Marriage date     */ { type: "num" },
43dd6b2bfcSGreg Roach        /* Anniversary       */ { type: "num" },
44dd6b2bfcSGreg Roach        /* Marriage place    */ { type: "text" },
45dd6b2bfcSGreg Roach        /* Children          */ { type: "num" },
46dd6b2bfcSGreg Roach        /* Last change       */ { visible: <?= json_encode((bool) $tree->getPreference('SHOW_LAST_CHANGE')) ?> },
47dd6b2bfcSGreg Roach        /* Filter marriage   */ { sortable: false },
48dd6b2bfcSGreg Roach        /* Filter alive/dead */ { sortable: false },
49dd6b2bfcSGreg Roach        /* Filter tree       */ { sortable: false }
50dd6b2bfcSGreg Roach    ],
511b860509SRico Sonntag    sorting: [
521b860509SRico Sonntag        [1, "asc"]
53b6c326d8SGreg Roach    ]
541b860509SRico Sonntag});
551b860509SRico Sonntag
561b860509SRico Sonntag$("#<?= e($table_id) ?>")
57dd6b2bfcSGreg Roach    /* Hide/show parents */
584843b94fSGreg Roach    .on("click", "#btn-toggle-parents", function() {
595e6816beSGreg Roach        $(".wt-individual-list-parents").slideToggle();
60dd6b2bfcSGreg Roach    })
61dd6b2bfcSGreg Roach    /* Hide/show statistics */
624843b94fSGreg Roach    .on("click", "#btn-toggle-statistics", function() {
631b860509SRico Sonntag        $("#family-charts-<?= e($table_id) ?>").slideToggle({
641b860509SRico Sonntag            complete: function () {
651b860509SRico Sonntag                // Trigger resize to redraw the chart
661b860509SRico Sonntag                $('div[id^="google-chart-"]').resize();
671b860509SRico Sonntag            }
681b860509SRico Sonntag        });
69dd6b2bfcSGreg Roach    })
70dd6b2bfcSGreg Roach    /* Filter buttons in table header */
71604bfd4bSGreg Roach    .on("click", "input[data-filter-column]", function() {
72604bfd4bSGreg Roach        let checkbox = $(this);
73604bfd4bSGreg Roach        let siblings = checkbox.parent().siblings();
741b860509SRico Sonntag
75604bfd4bSGreg Roach        // Deselect other options
76604bfd4bSGreg Roach        siblings.children().prop("checked", false).removeAttr("checked");
77604bfd4bSGreg Roach        siblings.removeClass('active');
78604bfd4bSGreg Roach
79604bfd4bSGreg Roach        // Apply (or clear) this filter
80604bfd4bSGreg Roach        let checked = checkbox.prop("checked");
81604bfd4bSGreg Roach        let filter  = checked ? checkbox.data("filter-value") : "";
8232a5dd8dSGreg Roach        let column  = $("#<?= e($table_id) ?> .wt-table-family").DataTable().column(checkbox.data("filter-column"));
83604bfd4bSGreg Roach        column.search(filter).draw();
84604bfd4bSGreg Roach    });
85dd6b2bfcSGreg Roach</script>
86dd6b2bfcSGreg Roach<?php View::endpush() ?>
87dd6b2bfcSGreg Roach
88dd6b2bfcSGreg Roach<?php
89dd6b2bfcSGreg Roach$max_age = (int) $tree->getPreference('MAX_ALIVE_AGE');
90dd6b2bfcSGreg Roach
91dd6b2bfcSGreg Roach// init chart data
92dd6b2bfcSGreg Roach$marr_by_age = [];
93dd6b2bfcSGreg Roachfor ($age = 0; $age <= $max_age; $age++) {
941b860509SRico Sonntag    $marr_by_age[$age]['M'] = 0;
951b860509SRico Sonntag    $marr_by_age[$age]['F'] = 0;
961b860509SRico Sonntag    $marr_by_age[$age]['U'] = 0;
97dd6b2bfcSGreg Roach}
98dd6b2bfcSGreg Roach$birt_by_decade = [];
99dd6b2bfcSGreg Roach$marr_by_decade = [];
1001b860509SRico Sonntagfor ($year = 1400; $year < 2050; $year += 10) {
1011b860509SRico Sonntag    $birt_by_decade[$year]['M'] = 0;
1021b860509SRico Sonntag    $birt_by_decade[$year]['F'] = 0;
1031b860509SRico Sonntag    $birt_by_decade[$year]['U'] = 0;
1041b860509SRico Sonntag    $marr_by_decade[$year]['M'] = 0;
1051b860509SRico Sonntag    $marr_by_decade[$year]['F'] = 0;
1061b860509SRico Sonntag    $marr_by_decade[$year]['U'] = 0;
107dd6b2bfcSGreg Roach}
1081b860509SRico Sonntag
1091b860509SRico Sonntag$birthData = [
1101b860509SRico Sonntag    [
1111b860509SRico Sonntag        [
1121b860509SRico Sonntag            'label' => I18N::translate('Century'),
1131b860509SRico Sonntag            'type'  => 'date',
1141b860509SRico Sonntag        ], [
1151b860509SRico Sonntag            'label' => I18N::translate('Males'),
1161b860509SRico Sonntag            'type'  => 'number',
1171b860509SRico Sonntag        ], [
1181b860509SRico Sonntag            'label' => I18N::translate('Females'),
1191b860509SRico Sonntag            'type'  => 'number',
1201b860509SRico Sonntag        ],
1211b860509SRico Sonntag    ]
1221b860509SRico Sonntag];
1231b860509SRico Sonntag
1241b860509SRico Sonntag$marriageData = [
1251b860509SRico Sonntag    [
1261b860509SRico Sonntag        [
1271b860509SRico Sonntag            'label' => I18N::translate('Century'),
1281b860509SRico Sonntag            'type'  => 'date',
1291b860509SRico Sonntag        ], [
1301b860509SRico Sonntag            'label' => I18N::translate('Males'),
1311b860509SRico Sonntag            'type'  => 'number',
1321b860509SRico Sonntag        ], [
1331b860509SRico Sonntag            'label' => I18N::translate('Females'),
1341b860509SRico Sonntag            'type'  => 'number',
1351b860509SRico Sonntag        ],
1361b860509SRico Sonntag    ]
1371b860509SRico Sonntag];
1381b860509SRico Sonntag
1391b860509SRico Sonntag$marriageAgeData = [
1401b860509SRico Sonntag    [
1411b860509SRico Sonntag        I18N::translate('Age'),
1421b860509SRico Sonntag        I18N::translate('Males'),
1431b860509SRico Sonntag        I18N::translate('Females'),
1441b860509SRico Sonntag        I18N::translate('Average age'),
1451b860509SRico Sonntag    ]
1461b860509SRico Sonntag];
1471b860509SRico Sonntag
148dd6b2bfcSGreg Roach?>
149dd6b2bfcSGreg Roach
15032a5dd8dSGreg Roach<div id="<?= e($table_id) ?>">
15132a5dd8dSGreg Roach    <table class="table table-bordered table-sm wt-table-family"
152b6c326d8SGreg Roach        <?= view('lists/datatables-attributes') ?>
153b6c326d8SGreg Roach    >
154dd6b2bfcSGreg Roach        <thead>
155dd6b2bfcSGreg Roach            <tr>
156dd6b2bfcSGreg Roach                <th colspan="14">
157dd6b2bfcSGreg Roach                    <div class="btn-toolbar d-flex justify-content-between mb-2">
158604bfd4bSGreg Roach                        <div class="btn-group btn-group-toggle btn-group-sm" data-toggle="buttons">
159af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary btn-sm" title="' . I18N::translate('Show individuals who are alive or couples where both partners are alive.') ?>">
160604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="12" data-filter-value="N">
161dd6b2bfcSGreg Roach                                <?= I18N::translate('Both alive') ?>
162604bfd4bSGreg Roach                            </label>
163af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show couples where only the female partner is dead.') ?>">
164604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="12" data-filter-value="W">
165dd6b2bfcSGreg Roach                                <?= I18N::translate('Widower') ?>
166604bfd4bSGreg Roach                            </label>
167af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show couples where only the male partner is dead.') ?>">
168604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="12" data-filter-value="H">
169dd6b2bfcSGreg Roach                                <?= I18N::translate('Widow') ?>
170604bfd4bSGreg Roach                            </label>
171af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show individuals who are dead or couples where both partners are dead.') ?>">
172604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="12" data-filter-value="Y">
173dd6b2bfcSGreg Roach                                <?= I18N::translate('Both dead') ?>
174604bfd4bSGreg Roach                            </label>
175dd6b2bfcSGreg Roach                        </div>
176604bfd4bSGreg Roach
177604bfd4bSGreg Roach                        <div class="btn-group btn-group-toggle btn-group-sm" data-toggle="buttons">
178af8b52f0SGreg 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.') ?>">
179604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="13" data-filter-value="R">
180dd6b2bfcSGreg Roach                                <?= I18N::translate('Roots') ?>
181604bfd4bSGreg Roach                            </label>
182af8b52f0SGreg 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.') ?>">
183604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="13" data-filter-value="L">
184dd6b2bfcSGreg Roach                                <?= I18N::translate('Leaves') ?>
185604bfd4bSGreg Roach                            </label>
186dd6b2bfcSGreg Roach                        </div>
187604bfd4bSGreg Roach
188604bfd4bSGreg Roach                        <div class="btn-group btn-group-toggle btn-group-sm" data-toggle="buttons">
189af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show couples with an unknown marriage date.') ?>">
190604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="11" data-filter-value="U">
191b9597e06SGreg Roach                                <?= I18N::translate('Not married') ?>
192604bfd4bSGreg Roach                            </label>
193af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show couples who married more than 100 years ago.') ?>">
194604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="11" data-filter-value="YES">
195dd6b2bfcSGreg Roach                                <?= I18N::translate('Marriage') ?>&gt;100
196604bfd4bSGreg Roach                            </label>
197af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show couples who married within the last 100 years.') ?>">
198604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="11" data-filter-value="Y100">
199dd6b2bfcSGreg Roach                                <?= I18N::translate('Marriage') ?>&lt;=100
200604bfd4bSGreg Roach                            </label>
201af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show divorced couples.') ?>">
202604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="11" data-filter-value="D">
203dd6b2bfcSGreg Roach                                <?= I18N::translate('Divorce') ?>
204604bfd4bSGreg Roach                            </label>
205af8b52f0SGreg Roach                            <label class="btn btn-outline-secondary" title="<?= I18N::translate('Show couples where either partner married more than once.') ?>">
206604bfd4bSGreg Roach                                <input type="checkbox" data-filter-column="11" data-filter-value="M">
207dd6b2bfcSGreg Roach                                <?= I18N::translate('Multiple marriages') ?>
208604bfd4bSGreg Roach                            </label>
209dd6b2bfcSGreg Roach                        </div>
210dd6b2bfcSGreg Roach                    </div>
211dd6b2bfcSGreg Roach                </th>
212dd6b2bfcSGreg Roach            </tr>
213dd6b2bfcSGreg Roach            <tr>
214dd6b2bfcSGreg Roach                <th><?= I18N::translate('Given names') ?></th>
215dd6b2bfcSGreg Roach                <th><?= I18N::translate('Surname') ?></th>
216dd6b2bfcSGreg Roach                <th><?= I18N::translate('Age') ?></th>
217dd6b2bfcSGreg Roach                <th><?= I18N::translate('Given names') ?></th>
218dd6b2bfcSGreg Roach                <th><?= I18N::translate('Surname') ?></th>
219dd6b2bfcSGreg Roach                <th><?= I18N::translate('Age') ?></th>
220dd6b2bfcSGreg Roach                <th><?= I18N::translate('Marriage') ?></th>
221e39fd5c6SGreg Roach                <th>
222e39fd5c6SGreg Roach                    <span title="<?= I18N::translate('Anniversary') ?>">
223e39fd5c6SGreg Roach                        <?= view('icons/anniversary') ?>
224e39fd5c6SGreg Roach                    </span>
225e39fd5c6SGreg Roach                </th>
226dd6b2bfcSGreg Roach                <th><?= I18N::translate('Place') ?></th>
227dd6b2bfcSGreg Roach                <th><i class="icon-children" title="<?= I18N::translate('Children') ?>"></i></th>
228dd6b2bfcSGreg Roach                <th><?= I18N::translate('Last change') ?></th>
229dd6b2bfcSGreg Roach                <th hidden></th>
230dd6b2bfcSGreg Roach                <th hidden></th>
231dd6b2bfcSGreg Roach                <th hidden></th>
232dd6b2bfcSGreg Roach            </tr>
233dd6b2bfcSGreg Roach        </thead>
234dd6b2bfcSGreg Roach
235dd6b2bfcSGreg Roach        <tbody>
236dd6b2bfcSGreg Roach        <?php foreach ($families as $family) : ?>
237*a091ac74SGreg Roach            <?php $husb = $family->husband() ?? Factory::individual()->new('H', '0 @H@ INDI', null, $family->tree()) ?>
238*a091ac74SGreg Roach            <?php $wife = $family->wife() ?? Factory::individual()->new('W', '0 @W@ INDI', null, $family->tree()) ?>
239dd6b2bfcSGreg Roach
24017dd427eSGreg Roach            <tr class="<?= $family->isPendingDeletion() ? 'wt-old' : ($family->isPendingAddition() ? 'wt-new' : '') ?>">
241dd6b2bfcSGreg Roach                <!-- Husband name -->
24239ca88baSGreg Roach                <td colspan="2" data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', implode(',', array_reverse(explode(',', $husb->sortName()))))) ?>">
243dd6b2bfcSGreg Roach                    <?php foreach ($husb->getAllNames() as $num => $name) : ?>
24422d65e5aSGreg Roach                        <?php if ($name['type'] !== '_MARNM' || $num == $husb->getPrimaryName()) : ?>
245e840bf40SGreg Roach                        <a title="<?= $name['type'] === 'NAME' ? '' : strip_tags(GedcomTag::getLabel($name['type'], $husb)) ?>" href="<?= e($family->url()) ?>" class="<?= $num === $husb->getPrimaryName() ? 'name2' : '' ?>">
246dd6b2bfcSGreg Roach                            <?= $name['full'] ?>
247dd6b2bfcSGreg Roach                        </a>
248dd6b2bfcSGreg Roach                            <?php if ($num === $husb->getPrimaryName()) : ?>
24908362db4SGreg Roach                                <small><?= view('icons/sex', ['sex' => $husb->sex()]) ?></small>
250dd6b2bfcSGreg Roach                            <?php endif ?>
251dd6b2bfcSGreg Roach                        <br>
252dd6b2bfcSGreg Roach                        <?php endif ?>
253dd6b2bfcSGreg Roach                    <?php endforeach ?>
2545e6816beSGreg Roach                    <?= view('lists/individual-table-parents', ['individual' => $husb]) ?>
255dd6b2bfcSGreg Roach                </td>
256dd6b2bfcSGreg Roach
25739ca88baSGreg Roach                <td hidden data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', $husb->sortName())) ?>"></td>
258dd6b2bfcSGreg Roach
259dd6b2bfcSGreg Roach                <!-- Husband age -->
260dd6b2bfcSGreg Roach                <?php
26153432476SGreg Roach                $age  = new Age($husb->getBirthDate(), $family->getMarriageDate());
26253432476SGreg Roach                $year = $wife->getBirthDate()->gregorianYear();
263054771e9SGreg Roach
26453432476SGreg Roach                if ($year >= 1550 && $year < 2030) {
26553432476SGreg Roach                    ++$birt_by_decade[(int) ($year / 10) * 10][$husb->sex()];
266dd6b2bfcSGreg Roach                }
267054771e9SGreg Roach
26853432476SGreg Roach                if ($age->ageYears() >= 0 && $age->ageYears() <= $max_age) {
26953432476SGreg Roach                    ++$marr_by_age[$age->ageYears()][$husb->sex()];
270dd6b2bfcSGreg Roach                }
271dd6b2bfcSGreg Roach                ?>
27253432476SGreg Roach                <td class="text-center" data-sort="<?= $age->ageDays() ?>">
27353432476SGreg Roach                    <?= $age->ageYearsString() ?>
274dd6b2bfcSGreg Roach                </td>
275dd6b2bfcSGreg Roach
276dd6b2bfcSGreg Roach                <!-- Wife name -->
27739ca88baSGreg Roach                <td colspan="2" data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', implode(',', array_reverse(explode(',', $wife->sortName()))))) ?>">
278dd6b2bfcSGreg Roach                    <?php foreach ($wife->getAllNames() as $num => $name) : ?>
27922d65e5aSGreg Roach                        <?php if ($name['type'] !== '_MARNM' || $num == $wife->getPrimaryName()) : ?>
280e840bf40SGreg Roach                            <a title="<?= $name['type'] === 'NAME' ? '' : strip_tags(GedcomTag::getLabel($name['type'], $wife)) ?>" href="<?= e($family->url()) ?>" class="<?= $num === $wife->getPrimaryName() ? 'name2' : '' ?>">
281dd6b2bfcSGreg Roach                                <?= $name['full'] ?>
282dd6b2bfcSGreg Roach                            </a>
283dd6b2bfcSGreg Roach                            <?php if ($num === $wife->getPrimaryName()) : ?>
28408362db4SGreg Roach                                <small><?= view('icons/sex', ['sex' => $wife->sex()]) ?></small>
285dd6b2bfcSGreg Roach                            <?php endif ?>
286dd6b2bfcSGreg Roach                            <br>
287dd6b2bfcSGreg Roach                        <?php endif ?>
288dd6b2bfcSGreg Roach                    <?php endforeach ?>
2895e6816beSGreg Roach                    <?= view('lists/individual-table-parents', ['individual' => $wife]) ?>
290dd6b2bfcSGreg Roach                </td>
291dd6b2bfcSGreg Roach
29239ca88baSGreg Roach                <td hidden data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', $wife->sortName())) ?>"></td>
293dd6b2bfcSGreg Roach
294dd6b2bfcSGreg Roach                <!-- Wife age -->
295dd6b2bfcSGreg Roach                <?php
29653432476SGreg Roach                $age  = new Age($wife->getBirthDate(), $family->getMarriageDate());
29753432476SGreg Roach                $year = $wife->getBirthDate()->gregorianYear();
298054771e9SGreg Roach
29953432476SGreg Roach                if ($year >= 1550 && $year < 2030) {
30053432476SGreg Roach                    ++$birt_by_decade[(int) ($year / 10) * 10][$wife->sex()];
301dd6b2bfcSGreg Roach                }
302054771e9SGreg Roach
30353432476SGreg Roach                if ($age->ageYears() >= 0 && $age->ageYears() <= $max_age) {
30453432476SGreg Roach                    ++$marr_by_age[$age->ageYears()][$wife->sex()];
305dd6b2bfcSGreg Roach                }
306dd6b2bfcSGreg Roach                ?>
30753432476SGreg Roach                <td class="text-center" data-sort="<?= $age->ageDays() ?>">
30853432476SGreg Roach                    <?= $age->ageYearsString() ?>
309dd6b2bfcSGreg Roach                </td>
310dd6b2bfcSGreg Roach
311dd6b2bfcSGreg Roach                <!-- Marriage date -->
312dd6b2bfcSGreg Roach                <td data-sort="<?= $family->getMarriageDate()->julianDay() ?>">
313dd6b2bfcSGreg Roach                    <?php if ($marriage_dates = $family->getAllMarriageDates()) : ?>
314dd6b2bfcSGreg Roach                        <?php foreach ($marriage_dates as $n => $marriage_date) : ?>
315dd6b2bfcSGreg Roach                            <div><?= $marriage_date->display(true) ?></div>
316dd6b2bfcSGreg Roach                        <?php endforeach ?>
317dd6b2bfcSGreg Roach                        <?php if ($marriage_dates[0]->gregorianYear() >= 1550 && $marriage_dates[0]->gregorianYear() < 2030) : ?>
3181b860509SRico Sonntag                            <?php
3191b860509SRico Sonntag                                ++$marr_by_decade[(int) ($marriage_dates[0]->gregorianYear() / 10) * 10][$husb->sex()];
3201b860509SRico Sonntag                                ++$marr_by_decade[(int) ($marriage_dates[0]->gregorianYear() / 10) * 10][$wife->sex()];
3211b860509SRico Sonntag                            ?>
322dd6b2bfcSGreg Roach                        <?php endif ?>
32339ca88baSGreg Roach                    <?php elseif ($family->facts(['_NMR'])->isNotEmpty()) : ?>
324dd6b2bfcSGreg Roach                        <?= I18N::translate('no') ?>
32539ca88baSGreg Roach                    <?php elseif ($family->facts(['MARR'])->isNotEmpty()) : ?>
326dd6b2bfcSGreg Roach                            <?= I18N::translate('yes') ?>
327dd6b2bfcSGreg Roach                    <?php endif ?>
328dd6b2bfcSGreg Roach                </td>
329dd6b2bfcSGreg Roach
330dd6b2bfcSGreg Roach                <!-- Marriage anniversary -->
33153432476SGreg Roach                <?php $age = new Age($family->getMarriageDate(), $today) ?>
33253432476SGreg Roach                <td class="text-center" data-sort="<?= $age->ageDays() ?>">
33353432476SGreg Roach                    <?= $age->ageYearsString() ?>
334dd6b2bfcSGreg Roach                </td>
335dd6b2bfcSGreg Roach
336dd6b2bfcSGreg Roach                <!-- Marriage place -->
337dd6b2bfcSGreg Roach                <td>
338dd6b2bfcSGreg Roach                    <?php foreach ($family->getAllMarriagePlaces() as $n => $marriage_place) : ?>
339392561bbSGreg Roach                        <?= $marriage_place->shortName(true) ?>
340dd6b2bfcSGreg Roach                        <br>
341dd6b2bfcSGreg Roach                    <?php endforeach ?>
342dd6b2bfcSGreg Roach                </td>
343dd6b2bfcSGreg Roach
344dd6b2bfcSGreg Roach                <!-- Number of children -->
34539ca88baSGreg Roach                <td class="text-center" data-sort="<?= $family->numberOfChildren() ?>">
34639ca88baSGreg Roach                    <?= I18N::number($family->numberOfChildren()) ?>
347dd6b2bfcSGreg Roach                </td>
348dd6b2bfcSGreg Roach
349dd6b2bfcSGreg Roach                <!-- Last change -->
3504459dc9aSGreg Roach                <td data-sort="<?= $family->lastChangeTimestamp()->unix() ?>">
3514459dc9aSGreg Roach                    <?= view('components/datetime', ['timestamp' => $family->lastChangeTimestamp()]) ?>
352dd6b2bfcSGreg Roach                </td>
353dd6b2bfcSGreg Roach
354dd6b2bfcSGreg Roach                <!-- Filter by marriage date -->
355dd6b2bfcSGreg Roach                <td hidden>
35653432476SGreg Roach                    <?php if ($family->getMarriageDate()->maximumJulianDay() > $hundred_years_ago && $family->getMarriageDate()->maximumJulianDay() <= $today_jd) : ?>
357dd6b2bfcSGreg Roach                        Y100
358b9597e06SGreg Roach                    <?php elseif ($family->facts(['MARR'])->isNotEmpty()) : ?>
359dd6b2bfcSGreg Roach                        YES
360b9597e06SGreg Roach                    <?php else : ?>
361b9597e06SGreg Roach                        U
362dd6b2bfcSGreg Roach                    <?php endif ?>
363b9597e06SGreg Roach                    <?php if ($family->facts(['DIV'])->isNotEmpty()) : ?>
364dd6b2bfcSGreg Roach                        D
365dd6b2bfcSGreg Roach                    <?php endif ?>
36639ca88baSGreg Roach                    <?php if (count($husb->spouseFamilies()) > 1 || count($wife->spouseFamilies()) > 1) : ?>
367dd6b2bfcSGreg Roach                        M
368dd6b2bfcSGreg Roach                    <?php endif ?>
369dd6b2bfcSGreg Roach                </td>
370dd6b2bfcSGreg Roach
371dd6b2bfcSGreg Roach                <!-- Filter by alive/dead -->
372dd6b2bfcSGreg Roach                <td hidden>
373dd6b2bfcSGreg Roach                    <?php if ($husb->isDead() && $wife->isDead()) : ?>
374dd6b2bfcSGreg Roach                        Y
375dd6b2bfcSGreg Roach                    <?php endif ?>
376dd6b2bfcSGreg Roach                    <?php if ($husb->isDead() && !$wife->isDead()) : ?>
37722d65e5aSGreg Roach                        <?php if ($wife->sex() === 'F') : ?>
378dd6b2bfcSGreg Roach                            H
379dd6b2bfcSGreg Roach                        <?php endif ?>
38022d65e5aSGreg Roach                        <?php if ($wife->sex() === 'M') : ?>
381dd6b2bfcSGreg Roach                            W
382dd6b2bfcSGreg Roach                        <?php endif ?>
383dd6b2bfcSGreg Roach                    <?php endif ?>
384dd6b2bfcSGreg Roach                    <?php if (!$husb->isDead() && $wife->isDead()) : ?>
38522d65e5aSGreg Roach                        <?php if ($husb->sex() === 'M') : ?>
386dd6b2bfcSGreg Roach                            W
387dd6b2bfcSGreg Roach                        <?php endif ?>
38822d65e5aSGreg Roach                        <?php if ($husb->sex() === 'F') : ?>
389dd6b2bfcSGreg Roach                            H
390dd6b2bfcSGreg Roach                        <?php endif ?>
391dd6b2bfcSGreg Roach                    <?php endif ?>
392dd6b2bfcSGreg Roach                    <?php if (!$husb->isDead() && !$wife->isDead()) : ?>
393dd6b2bfcSGreg Roach                        N
394dd6b2bfcSGreg Roach                    <?php endif ?>
395dd6b2bfcSGreg Roach                </td>
396dd6b2bfcSGreg Roach
397dd6b2bfcSGreg Roach                <!-- Filter by roots/leaves -->
398dd6b2bfcSGreg Roach                <td hidden>
39939ca88baSGreg Roach                    <?php if (!$husb->childFamilies() && !$wife->childFamilies()) : ?>
400dd6b2bfcSGreg Roach                        R
40139ca88baSGreg Roach                    <?php elseif (!$husb->isDead() && !$wife->isDead() && $family->numberOfChildren() === 0) : ?>
402dd6b2bfcSGreg Roach                        L
403dd6b2bfcSGreg Roach                    <?php endif ?>
404dd6b2bfcSGreg Roach                </td>
405dd6b2bfcSGreg Roach            </tr>
406dd6b2bfcSGreg Roach        <?php endforeach ?>
407dd6b2bfcSGreg Roach        </tbody>
4087039fd97SGreg Roach
4097039fd97SGreg Roach        <tfoot>
4107039fd97SGreg Roach            <tr>
4117039fd97SGreg Roach                <th colspan="14">
412604bfd4bSGreg Roach                    <div class="btn-group btn-group-sm">
413af8b52f0SGreg Roach                        <button id="btn-toggle-parents" class="btn btn-outline-secondary" data-toggle="button" data-persist="show-parents">
4147039fd97SGreg Roach                            <?= I18N::translate('Show parents') ?>
4157039fd97SGreg Roach                        </button>
416af8b52f0SGreg Roach                        <button id="btn-toggle-statistics" class="btn btn-outline-secondary" data-toggle="button" data-persist="show-statistics">
4177039fd97SGreg Roach                            <?= I18N::translate('Show statistics charts') ?>
4187039fd97SGreg Roach                        </button>
4197039fd97SGreg Roach                    </div>
4207039fd97SGreg Roach                </th>
4217039fd97SGreg Roach            </tr>
4227039fd97SGreg Roach        </tfoot>
423dd6b2bfcSGreg Roach    </table>
4241b860509SRico Sonntag</div>
425dd6b2bfcSGreg Roach
4261b860509SRico Sonntag<div id="family-charts-<?= e($table_id) ?>" style="display: none;">
4271b860509SRico Sonntag    <div class="mb-3">
4281b860509SRico Sonntag        <div class="card-deck">
4291b860509SRico Sonntag            <div class="col-lg-12 col-md-12 mb-3">
4301b860509SRico Sonntag                <div class="card m-0">
4311b860509SRico Sonntag                    <div class="card-header">
4321b860509SRico Sonntag                        <?= I18N::translate('Decade of birth') ?>
4331b860509SRico Sonntag                    </div><div class="card-body">
4341b860509SRico Sonntag                        <?php
4351b860509SRico Sonntag                        foreach ($birt_by_decade as $century => $values) {
4361b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
4371b860509SRico Sonntag                                $birthData[] = [
4381b860509SRico Sonntag                                    [
4391b860509SRico Sonntag                                        'v' => 'Date(' . $century . ', 0, 1)',
4401b860509SRico Sonntag                                        'f' => $century,
4411b860509SRico Sonntag                                    ],
4421b860509SRico Sonntag                                    $values['M'],
4431b860509SRico Sonntag                                    $values['F'],
4441b860509SRico Sonntag                                ];
4451b860509SRico Sonntag                            }
4461b860509SRico Sonntag                        }
4471b860509SRico Sonntag                        ?>
4481b860509SRico Sonntag                        <?= view('lists/chart-by-decade', ['data' => $birthData, 'title' => I18N::translate('Decade of birth')]) ?>
4491b860509SRico Sonntag                    </div>
4501b860509SRico Sonntag                </div>
4511b860509SRico Sonntag            </div>
4521b860509SRico Sonntag        </div>
4531b860509SRico Sonntag        <div class="card-deck">
4541b860509SRico Sonntag            <div class="col-lg-12 col-md-12 mb-3">
4551b860509SRico Sonntag                <div class="card m-0">
4561b860509SRico Sonntag                    <div class="card-header">
4571b860509SRico Sonntag                        <?= I18N::translate('Decade of marriage') ?>
4581b860509SRico Sonntag                    </div><div class="card-body">
4591b860509SRico Sonntag                        <?php
4601b860509SRico Sonntag                        foreach ($marr_by_decade as $century => $values) {
4611b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
4621b860509SRico Sonntag                                $marriageData[] = [
4631b860509SRico Sonntag                                    [
4641b860509SRico Sonntag                                        'v' => 'Date(' . $century . ', 0, 1)',
4651b860509SRico Sonntag                                        'f' => $century,
4661b860509SRico Sonntag                                    ],
4671b860509SRico Sonntag                                    $values['M'],
4681b860509SRico Sonntag                                    $values['F'],
4691b860509SRico Sonntag                                ];
4701b860509SRico Sonntag                            }
4711b860509SRico Sonntag                        }
4721b860509SRico Sonntag                        ?>
4731b860509SRico Sonntag                        <?= view('lists/chart-by-decade', ['data' => $marriageData, 'title' => I18N::translate('Decade of marriage')]) ?>
4741b860509SRico Sonntag                    </div>
4751b860509SRico Sonntag                </div>
4761b860509SRico Sonntag            </div>
4771b860509SRico Sonntag        </div>
4781b860509SRico Sonntag        <div class="card-deck">
4791b860509SRico Sonntag            <div class="col-lg-12 col-md-12 mb-3">
4801b860509SRico Sonntag                <div class="card m-0">
4811b860509SRico Sonntag                    <div class="card-header">
4821b860509SRico Sonntag                        <?= I18N::translate('Age in year of marriage') ?>
4831b860509SRico Sonntag                    </div>
4841b860509SRico Sonntag                    <div class="card-body">
4851b860509SRico Sonntag                        <?php
4861b860509SRico Sonntag                            $totalAge = 0;
4871b860509SRico Sonntag                            $totalSum = 0;
4881b860509SRico Sonntag                            $max      = 0;
4891b860509SRico Sonntag
4901b860509SRico Sonntag                        foreach ($marr_by_age as $age => $values) {
4911b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
4921b860509SRico Sonntag                                if (($values['M'] + $values['F']) > $max) {
4931b860509SRico Sonntag                                    $max = $values['M'] + $values['F'];
4941b860509SRico Sonntag                                }
4951b860509SRico Sonntag
4961b860509SRico Sonntag                                $totalAge += $age * ($values['M'] + $values['F']);
4971b860509SRico Sonntag                                $totalSum += $values['M'] + $values['F'];
4981b860509SRico Sonntag
4991b860509SRico Sonntag                                $marriageAgeData[] = [
5001b860509SRico Sonntag                                    $age,
5011b860509SRico Sonntag                                    $values['M'],
5021b860509SRico Sonntag                                    $values['F'],
5031b860509SRico Sonntag                                    null,
5041b860509SRico Sonntag                                ];
5051b860509SRico Sonntag                            }
5061b860509SRico Sonntag                        }
5071b860509SRico Sonntag
5081b860509SRico Sonntag                        if ($totalSum > 0) {
5091b860509SRico Sonntag                            $marriageAgeData[] = [
5101b860509SRico Sonntag                                round($totalAge / $totalSum, 1),
5111b860509SRico Sonntag                                null,
5121b860509SRico Sonntag                                null,
5131b860509SRico Sonntag                                0,
5141b860509SRico Sonntag                            ];
5151b860509SRico Sonntag
5161b860509SRico Sonntag                            $marriageAgeData[] = [
5171b860509SRico Sonntag                                round($totalAge / $totalSum, 1),
5181b860509SRico Sonntag                                null,
5191b860509SRico Sonntag                                null,
5201b860509SRico Sonntag                                $max,
5211b860509SRico Sonntag                            ];
5221b860509SRico Sonntag                        }
5231b860509SRico Sonntag                        ?>
5241b860509SRico Sonntag                        <?= view('lists/chart-by-age', ['data' => $marriageAgeData, 'title' => I18N::translate('Age in year of marriage')]) ?>
5251b860509SRico Sonntag                    </div>
5261b860509SRico Sonntag                </div>
5271b860509SRico Sonntag            </div>
5281b860509SRico Sonntag        </div>
529dd6b2bfcSGreg Roach    </div>
530dd6b2bfcSGreg Roach</div>
531