xref: /webtrees/resources/views/lists/families-table.phtml (revision e840bf40ea7a0381dfe6da3774108dbcf895d4ca)
1dd6b2bfcSGreg Roach<?php
2d70512abSGreg Roach
31b860509SRico Sonntagdeclare(strict_types=1);
41b860509SRico Sonntag
55373aac2SGreg Roachuse Fisharebest\Webtrees\Carbon;
61b860509SRico Sonntaguse Fisharebest\Webtrees\Date;
71b860509SRico Sonntaguse Fisharebest\Webtrees\Gedcom;
81b860509SRico Sonntaguse Fisharebest\Webtrees\GedcomTag;
91b860509SRico Sonntaguse Fisharebest\Webtrees\I18N;
101b860509SRico Sonntaguse Fisharebest\Webtrees\Individual;
111b860509SRico Sonntaguse Fisharebest\Webtrees\View;
121b860509SRico Sonntaguse Ramsey\Uuid\Uuid;
131b860509SRico Sonntag
14dd6b2bfcSGreg Roach$table_id = 'table-fam-' . Uuid::uuid4()->toString(); // lists requires a unique ID in case there are multiple lists per page
151b860509SRico Sonntag
165373aac2SGreg Roach$hundred_years_ago = Carbon::now()->subYears(100)->julianDay();
175373aac2SGreg Roach
18dd6b2bfcSGreg Roach?>
19dd6b2bfcSGreg Roach
20dd6b2bfcSGreg Roach<?php View::push('javascript') ?>
21dd6b2bfcSGreg Roach<script>
221b860509SRico Sonntag
23dd6b2bfcSGreg Roach$("#<?= e($table_id) ?>").dataTable({
24dd6b2bfcSGreg Roach    dom: '<"H"<"filtersH_<?= e($table_id) ?>"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_<?= e($table_id) ?>">>',
25dd6b2bfcSGreg Roach    autoWidth: false,
26dd6b2bfcSGreg Roach    processing: true,
27dd6b2bfcSGreg Roach    retrieve: true,
28dd6b2bfcSGreg Roach    columns: [
29dd6b2bfcSGreg Roach        /* Given names       */ { type: "text" },
30dd6b2bfcSGreg Roach        /* Surnames          */ { type: "text" },
31dd6b2bfcSGreg Roach        /* Age               */ { type: "num" },
32dd6b2bfcSGreg Roach        /* Given names       */ { type: "text" },
33dd6b2bfcSGreg Roach        /* Surnames          */ { type: "text" },
34dd6b2bfcSGreg Roach        /* Age               */ { type: "num" },
35dd6b2bfcSGreg Roach        /* Marriage date     */ { type: "num" },
36dd6b2bfcSGreg Roach        /* Anniversary       */ { type: "num" },
37dd6b2bfcSGreg Roach        /* Marriage place    */ { type: "text" },
38dd6b2bfcSGreg Roach        /* Children          */ { type: "num" },
39dd6b2bfcSGreg Roach        /* Last change       */ { visible: <?= json_encode((bool) $tree->getPreference('SHOW_LAST_CHANGE')) ?> },
40dd6b2bfcSGreg Roach        /* Filter marriage   */ { sortable: false },
41dd6b2bfcSGreg Roach        /* Filter alive/dead */ { sortable: false },
42dd6b2bfcSGreg Roach        /* Filter tree       */ { sortable: false }
43dd6b2bfcSGreg Roach    ],
441b860509SRico Sonntag    sorting: [
451b860509SRico Sonntag        [1, "asc"]
46b6c326d8SGreg Roach    ]
471b860509SRico Sonntag});
481b860509SRico Sonntag
491b860509SRico Sonntag$("#<?= e($table_id) ?>")
50dd6b2bfcSGreg Roach    /* Hide/show parents */
514843b94fSGreg Roach    .on("click", "#btn-toggle-parents", function() {
525e6816beSGreg Roach        $(".wt-individual-list-parents").slideToggle();
53dd6b2bfcSGreg Roach    })
54dd6b2bfcSGreg Roach    /* Hide/show statistics */
554843b94fSGreg Roach    .on("click", "#btn-toggle-statistics", function() {
561b860509SRico Sonntag        $("#family-charts-<?= e($table_id) ?>").slideToggle({
571b860509SRico Sonntag            complete: function () {
581b860509SRico Sonntag                // Trigger resize to redraw the chart
591b860509SRico Sonntag                $('div[id^="google-chart-"]').resize();
601b860509SRico Sonntag            }
611b860509SRico Sonntag        });
62dd6b2bfcSGreg Roach    })
63dd6b2bfcSGreg Roach    /* Filter buttons in table header */
64dd6b2bfcSGreg Roach    .on("click", "button[data-filter-column]", function() {
65dd6b2bfcSGreg Roach        var btn = $(this);
66dd6b2bfcSGreg Roach        // De-activate the other buttons in this button group
67dd6b2bfcSGreg Roach        btn.siblings().removeClass("active");
68dd6b2bfcSGreg Roach        // Apply (or clear) this filter
69dd6b2bfcSGreg Roach        var col = $("#<?= e($table_id) ?>").DataTable().column(btn.data("filter-column"));
70dd6b2bfcSGreg Roach        if (btn.hasClass("active")) {
71dd6b2bfcSGreg Roach            col.search("").draw();
72dd6b2bfcSGreg Roach        } else {
73dd6b2bfcSGreg Roach            col.search(btn.data("filter-value")).draw();
74dd6b2bfcSGreg Roach        }
75dd6b2bfcSGreg Roach    });
761b860509SRico Sonntag
77dd6b2bfcSGreg Roach</script>
78dd6b2bfcSGreg Roach<?php View::endpush() ?>
79dd6b2bfcSGreg Roach
80dd6b2bfcSGreg Roach<?php
81dd6b2bfcSGreg Roach$max_age = (int) $tree->getPreference('MAX_ALIVE_AGE');
82dd6b2bfcSGreg Roach
83dd6b2bfcSGreg Roach// init chart data
84dd6b2bfcSGreg Roach$marr_by_age = [];
85dd6b2bfcSGreg Roachfor ($age = 0; $age <= $max_age; $age++) {
861b860509SRico Sonntag    $marr_by_age[$age]['M'] = 0;
871b860509SRico Sonntag    $marr_by_age[$age]['F'] = 0;
881b860509SRico Sonntag    $marr_by_age[$age]['U'] = 0;
89dd6b2bfcSGreg Roach}
90dd6b2bfcSGreg Roach$birt_by_decade = [];
91dd6b2bfcSGreg Roach$marr_by_decade = [];
921b860509SRico Sonntagfor ($year = 1400; $year < 2050; $year += 10) {
931b860509SRico Sonntag    $birt_by_decade[$year]['M'] = 0;
941b860509SRico Sonntag    $birt_by_decade[$year]['F'] = 0;
951b860509SRico Sonntag    $birt_by_decade[$year]['U'] = 0;
961b860509SRico Sonntag    $marr_by_decade[$year]['M'] = 0;
971b860509SRico Sonntag    $marr_by_decade[$year]['F'] = 0;
981b860509SRico Sonntag    $marr_by_decade[$year]['U'] = 0;
99dd6b2bfcSGreg Roach}
1001b860509SRico Sonntag
1011b860509SRico Sonntag$birthData = [
1021b860509SRico Sonntag    [
1031b860509SRico Sonntag        [
1041b860509SRico Sonntag            'label' => I18N::translate('Century'),
1051b860509SRico Sonntag            'type'  => 'date',
1061b860509SRico Sonntag        ], [
1071b860509SRico Sonntag            'label' => I18N::translate('Males'),
1081b860509SRico Sonntag            'type'  => 'number',
1091b860509SRico Sonntag        ], [
1101b860509SRico Sonntag            'label' => I18N::translate('Females'),
1111b860509SRico Sonntag            'type'  => 'number',
1121b860509SRico Sonntag        ],
1131b860509SRico Sonntag    ]
1141b860509SRico Sonntag];
1151b860509SRico Sonntag
1161b860509SRico Sonntag$marriageData = [
1171b860509SRico Sonntag    [
1181b860509SRico Sonntag        [
1191b860509SRico Sonntag            'label' => I18N::translate('Century'),
1201b860509SRico Sonntag            'type'  => 'date',
1211b860509SRico Sonntag        ], [
1221b860509SRico Sonntag            'label' => I18N::translate('Males'),
1231b860509SRico Sonntag            'type'  => 'number',
1241b860509SRico Sonntag        ], [
1251b860509SRico Sonntag            'label' => I18N::translate('Females'),
1261b860509SRico Sonntag            'type'  => 'number',
1271b860509SRico Sonntag        ],
1281b860509SRico Sonntag    ]
1291b860509SRico Sonntag];
1301b860509SRico Sonntag
1311b860509SRico Sonntag$marriageAgeData = [
1321b860509SRico Sonntag    [
1331b860509SRico Sonntag        I18N::translate('Age'),
1341b860509SRico Sonntag        I18N::translate('Males'),
1351b860509SRico Sonntag        I18N::translate('Females'),
1361b860509SRico Sonntag        I18N::translate('Average age'),
1371b860509SRico Sonntag    ]
1381b860509SRico Sonntag];
1391b860509SRico Sonntag
140dd6b2bfcSGreg Roach?>
141dd6b2bfcSGreg Roach
142dd6b2bfcSGreg Roach<div class="fam-list">
1435529b85eSGreg Roach    <table id="<?= e($table_id) ?>" class="table-bordered table-sm"
144b6c326d8SGreg Roach        <?= view('lists/datatables-attributes') ?>
145b6c326d8SGreg Roach    >
146dd6b2bfcSGreg Roach        <thead>
147dd6b2bfcSGreg Roach            <tr>
148dd6b2bfcSGreg Roach                <th colspan="14">
149dd6b2bfcSGreg Roach                    <div class="btn-toolbar d-flex justify-content-between mb-2">
150dd6b2bfcSGreg Roach                        <div class="btn-group" data-toggle="buttons">
151dd6b2bfcSGreg Roach                            <button
152dd6b2bfcSGreg Roach                                class="btn btn-secondary"
153dd6b2bfcSGreg Roach                                data-filter-column="12"
154dd6b2bfcSGreg Roach                                data-filter-value="N"
155dd6b2bfcSGreg Roach                                title="' . I18N::translate('Show individuals who are alive or couples where both partners are alive.') ?>"
156dd6b2bfcSGreg Roach                            >
157dd6b2bfcSGreg Roach                                <?= I18N::translate('Both alive') ?>
158dd6b2bfcSGreg Roach                            </button>
159dd6b2bfcSGreg Roach                            <button
160dd6b2bfcSGreg Roach                                class="btn btn-secondary"
161dd6b2bfcSGreg Roach                                data-filter-column="12"
162dd6b2bfcSGreg Roach                                data-filter-value="W"
163dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show couples where only the female partner is dead.') ?>"
164dd6b2bfcSGreg Roach                            >
165dd6b2bfcSGreg Roach                                <?= I18N::translate('Widower') ?>
166dd6b2bfcSGreg Roach                            </button>
167dd6b2bfcSGreg Roach                            <button
168dd6b2bfcSGreg Roach                                class="btn btn-secondary"
169dd6b2bfcSGreg Roach                                data-filter-column="12"
170dd6b2bfcSGreg Roach                                data-filter-value="H"
171dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show couples where only the male partner is dead.') ?>"
172dd6b2bfcSGreg Roach                            >
173dd6b2bfcSGreg Roach                                <?= I18N::translate('Widow') ?>
174dd6b2bfcSGreg Roach                            </button>
175dd6b2bfcSGreg Roach                            <button
176dd6b2bfcSGreg Roach                                class="btn btn-secondary"
177dd6b2bfcSGreg Roach                                data-filter-column="12"
178dd6b2bfcSGreg Roach                                data-filter-value="Y"
179dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show individuals who are dead or couples where both partners are dead.') ?>"
180dd6b2bfcSGreg Roach                            >
181dd6b2bfcSGreg Roach                                <?= I18N::translate('Both dead') ?>
182dd6b2bfcSGreg Roach                            </button>
183dd6b2bfcSGreg Roach                        </div>
184dd6b2bfcSGreg Roach                        <div class="btn-group" data-toggle="buttons">
185dd6b2bfcSGreg Roach                            <button
186dd6b2bfcSGreg Roach                                class="btn btn-secondary"
187dd6b2bfcSGreg Roach                                data-filter-column="13"
188dd6b2bfcSGreg Roach                                data-filter-value="R"
189dd6b2bfcSGreg 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.') ?>"
190dd6b2bfcSGreg Roach                            >
191dd6b2bfcSGreg Roach                                <?= I18N::translate('Roots') ?>
192dd6b2bfcSGreg Roach                            </button>
193dd6b2bfcSGreg Roach                            <button
194dd6b2bfcSGreg Roach                                class="btn btn-secondary"
195dd6b2bfcSGreg Roach                                data-filter-column="13"
196dd6b2bfcSGreg Roach                                data-filter-value="L"
197dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show “leaves” couples or individuals. These are individuals who are alive but have no children recorded in the database.') ?>"
198dd6b2bfcSGreg Roach                            >
199dd6b2bfcSGreg Roach                                <?= I18N::translate('Leaves') ?>
200dd6b2bfcSGreg Roach                            </button>
201dd6b2bfcSGreg Roach                        </div>
202dd6b2bfcSGreg Roach                        <div class="btn-group" data-toggle="buttons">
203dd6b2bfcSGreg Roach                            <button
204dd6b2bfcSGreg Roach                                class="btn btn-secondary"
205dd6b2bfcSGreg Roach                                data-filter-column="11"
206dd6b2bfcSGreg Roach                                data-filter-value="U"
207dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show couples with an unknown marriage date.') ?>"
208dd6b2bfcSGreg Roach                            >
209dd6b2bfcSGreg Roach                                <?= I18N::translate('Marriage') ?>
210dd6b2bfcSGreg Roach                            </button>
211dd6b2bfcSGreg Roach                            <button
212dd6b2bfcSGreg Roach                                class="btn btn-secondary"
213dd6b2bfcSGreg Roach                                data-filter-column="11"
214dd6b2bfcSGreg Roach                                data-filter-value="YES"
215dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show couples who married more than 100 years ago.') ?>"
216dd6b2bfcSGreg Roach                            >
217dd6b2bfcSGreg Roach                                <?= I18N::translate('Marriage') ?>&gt;100
218dd6b2bfcSGreg Roach                            </button>
219dd6b2bfcSGreg Roach                            <button
220dd6b2bfcSGreg Roach                                class="btn btn-secondary"
221dd6b2bfcSGreg Roach                                data-filter-column="11"
222dd6b2bfcSGreg Roach                                data-filter-value="Y100"
223dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show couples who married within the last 100 years.') ?>"
224dd6b2bfcSGreg Roach                            >
225dd6b2bfcSGreg Roach                                <?= I18N::translate('Marriage') ?>&lt;=100
226dd6b2bfcSGreg Roach                            </button>
227dd6b2bfcSGreg Roach                            <button
228dd6b2bfcSGreg Roach                                class="btn btn-secondary"
229dd6b2bfcSGreg Roach                                data-filter-column="11"
230dd6b2bfcSGreg Roach                                data-filter-value="D"
231dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show divorced couples.') ?>"
232dd6b2bfcSGreg Roach                            >
233dd6b2bfcSGreg Roach                                <?= I18N::translate('Divorce') ?>
234dd6b2bfcSGreg Roach                            </button>
235dd6b2bfcSGreg Roach                            <button
236dd6b2bfcSGreg Roach                                class="btn btn-secondary"
237dd6b2bfcSGreg Roach                                data-filter-column="11"
238dd6b2bfcSGreg Roach                                data-filter-value="M"
239dd6b2bfcSGreg Roach                                title="<?= I18N::translate('Show couples where either partner married more than once.') ?>"
240dd6b2bfcSGreg Roach                            >
241dd6b2bfcSGreg Roach                                <?= I18N::translate('Multiple marriages') ?>
242dd6b2bfcSGreg Roach                            </button>
243dd6b2bfcSGreg Roach                        </div>
244dd6b2bfcSGreg Roach                    </div>
245dd6b2bfcSGreg Roach                </th>
246dd6b2bfcSGreg Roach            </tr>
247dd6b2bfcSGreg Roach            <tr>
248dd6b2bfcSGreg Roach                <th><?= I18N::translate('Given names') ?></th>
249dd6b2bfcSGreg Roach                <th><?= I18N::translate('Surname') ?></th>
250dd6b2bfcSGreg Roach                <th><?= I18N::translate('Age') ?></th>
251dd6b2bfcSGreg Roach                <th><?= I18N::translate('Given names') ?></th>
252dd6b2bfcSGreg Roach                <th><?= I18N::translate('Surname') ?></th>
253dd6b2bfcSGreg Roach                <th><?= I18N::translate('Age') ?></th>
254dd6b2bfcSGreg Roach                <th><?= I18N::translate('Marriage') ?></th>
255e39fd5c6SGreg Roach                <th>
256e39fd5c6SGreg Roach                    <span title="<?= I18N::translate('Anniversary') ?>">
257e39fd5c6SGreg Roach                        <?= view('icons/anniversary') ?>
258e39fd5c6SGreg Roach                    </span>
259e39fd5c6SGreg Roach                </th>
260dd6b2bfcSGreg Roach                <th><?= I18N::translate('Place') ?></th>
261dd6b2bfcSGreg Roach                <th><i class="icon-children" title="<?= I18N::translate('Children') ?>"></i></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            </tr>
267dd6b2bfcSGreg Roach        </thead>
268dd6b2bfcSGreg Roach
269dd6b2bfcSGreg Roach        <tfoot>
270dd6b2bfcSGreg Roach            <tr>
271dd6b2bfcSGreg Roach                <th colspan="14">
2724843b94fSGreg Roach                    <div class="btn-group m-1">
2734843b94fSGreg Roach                        <button id="btn-toggle-parents" class="btn btn-secondary" data-toggle="button" data-persist="show-parents">
274dd6b2bfcSGreg Roach                            <?= I18N::translate('Show parents') ?>
275dd6b2bfcSGreg Roach                        </button>
2764843b94fSGreg Roach                        <button id="btn-toggle-statistics" class="btn btn-secondary" data-toggle="button" data-persist="show-statistics">
277dd6b2bfcSGreg Roach                            <?= I18N::translate('Show statistics charts') ?>
278dd6b2bfcSGreg Roach                        </button>
279dd6b2bfcSGreg Roach                    </div>
280dd6b2bfcSGreg Roach                </th>
281dd6b2bfcSGreg Roach            </tr>
282dd6b2bfcSGreg Roach        </tfoot>
283dd6b2bfcSGreg Roach        <tbody>
284dd6b2bfcSGreg Roach
285dd6b2bfcSGreg Roach        <?php foreach ($families as $family) : ?>
28639ca88baSGreg Roach            <?php $husb = $family->husband() ?? new Individual('H', '0 @H@ INDI', null, $family->tree()) ?>
28739ca88baSGreg Roach            <?php $wife = $family->wife() ?? new Individual('W', '0 @W@ INDI', null, $family->tree()) ?>
288dd6b2bfcSGreg Roach
28917dd427eSGreg Roach            <tr class="<?= $family->isPendingDeletion() ? 'wt-old' : ($family->isPendingAddition() ? 'wt-new' : '') ?>">
290dd6b2bfcSGreg Roach                <!-- Husband name -->
29139ca88baSGreg Roach                <td colspan="2" data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', implode(',', array_reverse(explode(',', $husb->sortName()))))) ?>">
292dd6b2bfcSGreg Roach                    <?php foreach ($husb->getAllNames() as $num => $name) : ?>
29322d65e5aSGreg Roach                        <?php if ($name['type'] !== '_MARNM' || $num == $husb->getPrimaryName()) : ?>
294*e840bf40SGreg Roach                        <a title="<?= $name['type'] === 'NAME' ? '' : strip_tags(GedcomTag::getLabel($name['type'], $husb)) ?>" href="<?= e($family->url()) ?>" class="<?= $num === $husb->getPrimaryName() ? 'name2' : '' ?>">
295dd6b2bfcSGreg Roach                            <?= $name['full'] ?>
296dd6b2bfcSGreg Roach                        </a>
297dd6b2bfcSGreg Roach                            <?php if ($num === $husb->getPrimaryName()) : ?>
29808362db4SGreg Roach                                <small><?= view('icons/sex', ['sex' => $husb->sex()]) ?></small>
299dd6b2bfcSGreg Roach                            <?php endif ?>
300dd6b2bfcSGreg Roach                        <br>
301dd6b2bfcSGreg Roach                        <?php endif ?>
302dd6b2bfcSGreg Roach                    <?php endforeach ?>
3035e6816beSGreg Roach                    <?= view('lists/individual-table-parents', ['individual' => $husb]) ?>
304dd6b2bfcSGreg Roach                </td>
305dd6b2bfcSGreg Roach
30639ca88baSGreg Roach                <td hidden data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', $husb->sortName())) ?>"></td>
307dd6b2bfcSGreg Roach
308dd6b2bfcSGreg Roach                <!-- Husband age -->
309dd6b2bfcSGreg Roach                <?php
310dd6b2bfcSGreg Roach                $mdate = $family->getMarriageDate();
311dd6b2bfcSGreg Roach                $hdate = $husb->getBirthDate();
312dd6b2bfcSGreg Roach                if ($hdate->isOK() && $mdate->isOK()) {
313dd6b2bfcSGreg Roach                    if ($hdate->gregorianYear() >= 1550 && $hdate->gregorianYear() < 2030) {
3141b860509SRico Sonntag                        ++$birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10][$husb->sex()];
315dd6b2bfcSGreg Roach                    }
316dd6b2bfcSGreg Roach                    $hage = Date::getAgeYears($hdate, $mdate);
317dd6b2bfcSGreg Roach                    if ($hage >= 0 && $hage <= $max_age) {
3181b860509SRico Sonntag                        ++$marr_by_age[$hage][$husb->sex()];
319dd6b2bfcSGreg Roach                    }
320dd6b2bfcSGreg Roach                }
321dd6b2bfcSGreg Roach                ?>
322242a7862SGreg Roach                <td class="text-center" data-sort="<?= Date::getAgeDays($hdate, $mdate) ?>">
323dd6b2bfcSGreg Roach                    <?= Date::getAge($hdate, $mdate) ?>
324dd6b2bfcSGreg Roach                </td>
325dd6b2bfcSGreg Roach
326dd6b2bfcSGreg Roach                <!-- Wife name -->
32739ca88baSGreg Roach                <td colspan="2" data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', implode(',', array_reverse(explode(',', $wife->sortName()))))) ?>">
328dd6b2bfcSGreg Roach                    <?php foreach ($wife->getAllNames() as $num => $name) : ?>
32922d65e5aSGreg Roach                        <?php if ($name['type'] !== '_MARNM' || $num == $wife->getPrimaryName()) : ?>
330*e840bf40SGreg Roach                            <a title="<?= $name['type'] === 'NAME' ? '' : strip_tags(GedcomTag::getLabel($name['type'], $wife)) ?>" href="<?= e($family->url()) ?>" class="<?= $num === $wife->getPrimaryName() ? 'name2' : '' ?>">
331dd6b2bfcSGreg Roach                                <?= $name['full'] ?>
332dd6b2bfcSGreg Roach                            </a>
333dd6b2bfcSGreg Roach                            <?php if ($num === $wife->getPrimaryName()) : ?>
33408362db4SGreg Roach                                <small><?= view('icons/sex', ['sex' => $wife->sex()]) ?></small>
335dd6b2bfcSGreg Roach                            <?php endif ?>
336dd6b2bfcSGreg Roach                            <br>
337dd6b2bfcSGreg Roach                        <?php endif ?>
338dd6b2bfcSGreg Roach                    <?php endforeach ?>
3395e6816beSGreg Roach                    <?= view('lists/individual-table-parents', ['individual' => $wife]) ?>
340dd6b2bfcSGreg Roach                </td>
341dd6b2bfcSGreg Roach
34239ca88baSGreg Roach                <td hidden data-sort="<?= e(str_replace([',', '@P.N.', '@N.N.'], 'AAAA', $wife->sortName())) ?>"></td>
343dd6b2bfcSGreg Roach
344dd6b2bfcSGreg Roach                <!-- Wife age -->
345dd6b2bfcSGreg Roach                <?php
346dd6b2bfcSGreg Roach                $wdate = $wife->getBirthDate();
347dd6b2bfcSGreg Roach                if ($wdate->isOK() && $mdate->isOK()) {
348dd6b2bfcSGreg Roach                    if ($wdate->gregorianYear() >= 1550 && $wdate->gregorianYear() < 2030) {
3491b860509SRico Sonntag                        ++$birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10][$wife->sex()];
350dd6b2bfcSGreg Roach                    }
351dd6b2bfcSGreg Roach                    $wage = Date::getAgeYears($wdate, $mdate);
352dd6b2bfcSGreg Roach                    if ($wage >= 0 && $wage <= $max_age) {
3531b860509SRico Sonntag                        ++$marr_by_age[$wage][$wife->sex()];
354dd6b2bfcSGreg Roach                    }
355dd6b2bfcSGreg Roach                }
356dd6b2bfcSGreg Roach                ?>
357dd6b2bfcSGreg Roach
358242a7862SGreg Roach                <td class="text-center" data-sort="<?= Date::getAgeDays($wdate, $mdate) ?>">
359dd6b2bfcSGreg Roach                    <?= Date::getAge($wdate, $mdate) ?>
360dd6b2bfcSGreg Roach                </td>
361dd6b2bfcSGreg Roach
362dd6b2bfcSGreg Roach                <!-- Marriage date -->
363dd6b2bfcSGreg Roach                <td data-sort="<?= $family->getMarriageDate()->julianDay() ?>">
364dd6b2bfcSGreg Roach                    <?php if ($marriage_dates = $family->getAllMarriageDates()) : ?>
365dd6b2bfcSGreg Roach                        <?php foreach ($marriage_dates as $n => $marriage_date) : ?>
366dd6b2bfcSGreg Roach                            <div><?= $marriage_date->display(true) ?></div>
367dd6b2bfcSGreg Roach                        <?php endforeach ?>
368dd6b2bfcSGreg Roach                        <?php if ($marriage_dates[0]->gregorianYear() >= 1550 && $marriage_dates[0]->gregorianYear() < 2030) : ?>
3691b860509SRico Sonntag                            <?php
3701b860509SRico Sonntag                                ++$marr_by_decade[(int) ($marriage_dates[0]->gregorianYear() / 10) * 10][$husb->sex()];
3711b860509SRico Sonntag                                ++$marr_by_decade[(int) ($marriage_dates[0]->gregorianYear() / 10) * 10][$wife->sex()];
3721b860509SRico Sonntag                            ?>
373dd6b2bfcSGreg Roach                        <?php endif ?>
37439ca88baSGreg Roach                    <?php elseif ($family->facts(['_NMR'])->isNotEmpty()) : ?>
375dd6b2bfcSGreg Roach                        <?= I18N::translate('no') ?>
37639ca88baSGreg Roach                    <?php elseif ($family->facts(['MARR'])->isNotEmpty()) : ?>
377dd6b2bfcSGreg Roach                            <?= I18N::translate('yes') ?>
378dd6b2bfcSGreg Roach                    <?php endif ?>
379dd6b2bfcSGreg Roach                </td>
380dd6b2bfcSGreg Roach
381dd6b2bfcSGreg Roach                <!-- Marriage anniversary -->
382242a7862SGreg Roach                <td class="text-center" data-sort="<?= - $family->getMarriageDate()->julianDay() ?>">
383dd6b2bfcSGreg Roach                    <?= Date::getAge($family->getMarriageDate(), null) ?>
384dd6b2bfcSGreg Roach                </td>
385dd6b2bfcSGreg Roach
386dd6b2bfcSGreg Roach                <!-- Marriage place -->
387dd6b2bfcSGreg Roach                <td>
388dd6b2bfcSGreg Roach                    <?php foreach ($family->getAllMarriagePlaces() as $n => $marriage_place) : ?>
389392561bbSGreg Roach                        <?= $marriage_place->shortName(true) ?>
390dd6b2bfcSGreg Roach                        <br>
391dd6b2bfcSGreg Roach                    <?php endforeach ?>
392dd6b2bfcSGreg Roach                </td>
393dd6b2bfcSGreg Roach
394dd6b2bfcSGreg Roach                <!-- Number of children -->
39539ca88baSGreg Roach                <td class="text-center" data-sort="<?= $family->numberOfChildren() ?>">
39639ca88baSGreg Roach                    <?= I18N::number($family->numberOfChildren()) ?>
397dd6b2bfcSGreg Roach                </td>
398dd6b2bfcSGreg Roach
399dd6b2bfcSGreg Roach                <!-- Last change -->
4004459dc9aSGreg Roach                <td data-sort="<?= $family->lastChangeTimestamp()->unix() ?>">
4014459dc9aSGreg Roach                    <?= view('components/datetime', ['timestamp' => $family->lastChangeTimestamp()]) ?>
402dd6b2bfcSGreg Roach                </td>
403dd6b2bfcSGreg Roach
404dd6b2bfcSGreg Roach                <!-- Filter by marriage date -->
405dd6b2bfcSGreg Roach                <td hidden>
406dd6b2bfcSGreg Roach                    <?php if (!$family->canShow() || !$mdate->isOK()) : ?>
407dd6b2bfcSGreg Roach                        U
4085373aac2SGreg Roach                    <?php elseif ($mdate->maximumJulianDay() > $hundred_years_ago) : ?>
409dd6b2bfcSGreg Roach                        Y100
410dd6b2bfcSGreg Roach                    <?php else : ?>
411dd6b2bfcSGreg Roach                        YES
412dd6b2bfcSGreg Roach                    <?php endif ?>
41339ca88baSGreg Roach                    <?php if ($family->facts(Gedcom::DIVORCE_EVENTS)->isNotEmpty()) : ?>
414dd6b2bfcSGreg Roach                        D
415dd6b2bfcSGreg Roach                    <?php endif ?>
41639ca88baSGreg Roach                    <?php if (count($husb->spouseFamilies()) > 1 || count($wife->spouseFamilies()) > 1) : ?>
417dd6b2bfcSGreg Roach                        M
418dd6b2bfcSGreg Roach                    <?php endif ?>
419dd6b2bfcSGreg Roach                </td>
420dd6b2bfcSGreg Roach
421dd6b2bfcSGreg Roach                <!-- Filter by alive/dead -->
422dd6b2bfcSGreg Roach                <td hidden>
423dd6b2bfcSGreg Roach                    <?php if ($husb->isDead() && $wife->isDead()) : ?>
424dd6b2bfcSGreg Roach                        Y
425dd6b2bfcSGreg Roach                    <?php endif ?>
426dd6b2bfcSGreg Roach                    <?php if ($husb->isDead() && !$wife->isDead()) : ?>
42722d65e5aSGreg Roach                        <?php if ($wife->sex() === 'F') : ?>
428dd6b2bfcSGreg Roach                            H
429dd6b2bfcSGreg Roach                        <?php endif ?>
43022d65e5aSGreg Roach                        <?php if ($wife->sex() === 'M') : ?>
431dd6b2bfcSGreg Roach                            W
432dd6b2bfcSGreg Roach                        <?php endif ?>
433dd6b2bfcSGreg Roach                    <?php endif ?>
434dd6b2bfcSGreg Roach                    <?php if (!$husb->isDead() && $wife->isDead()) : ?>
43522d65e5aSGreg Roach                        <?php if ($husb->sex() === 'M') : ?>
436dd6b2bfcSGreg Roach                            W
437dd6b2bfcSGreg Roach                        <?php endif ?>
43822d65e5aSGreg Roach                        <?php if ($husb->sex() === 'F') : ?>
439dd6b2bfcSGreg Roach                            H
440dd6b2bfcSGreg Roach                        <?php endif ?>
441dd6b2bfcSGreg Roach                    <?php endif ?>
442dd6b2bfcSGreg Roach                    <?php if (!$husb->isDead() && !$wife->isDead()) : ?>
443dd6b2bfcSGreg Roach                        N
444dd6b2bfcSGreg Roach                    <?php endif ?>
445dd6b2bfcSGreg Roach                </td>
446dd6b2bfcSGreg Roach
447dd6b2bfcSGreg Roach                <!-- Filter by roots/leaves -->
448dd6b2bfcSGreg Roach                <td hidden>
44939ca88baSGreg Roach                    <?php if (!$husb->childFamilies() && !$wife->childFamilies()) : ?>
450dd6b2bfcSGreg Roach                        R
45139ca88baSGreg Roach                    <?php elseif (!$husb->isDead() && !$wife->isDead() && $family->numberOfChildren() === 0) : ?>
452dd6b2bfcSGreg Roach                        L
453dd6b2bfcSGreg Roach                    <?php endif ?>
454dd6b2bfcSGreg Roach                </td>
455dd6b2bfcSGreg Roach            </tr>
456dd6b2bfcSGreg Roach        <?php endforeach ?>
457dd6b2bfcSGreg Roach        </tbody>
458dd6b2bfcSGreg Roach    </table>
4591b860509SRico Sonntag</div>
460dd6b2bfcSGreg Roach
4611b860509SRico Sonntag<div id="family-charts-<?= e($table_id) ?>" style="display: none;">
4621b860509SRico Sonntag    <div class="mb-3">
4631b860509SRico Sonntag        <div class="card-deck">
4641b860509SRico Sonntag            <div class="col-lg-12 col-md-12 mb-3">
4651b860509SRico Sonntag                <div class="card m-0">
4661b860509SRico Sonntag                    <div class="card-header">
4671b860509SRico Sonntag                        <?= I18N::translate('Decade of birth') ?>
4681b860509SRico Sonntag                    </div><div class="card-body">
4691b860509SRico Sonntag                        <?php
4701b860509SRico Sonntag                        foreach ($birt_by_decade as $century => $values) {
4711b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
4721b860509SRico Sonntag                                $birthData[] = [
4731b860509SRico Sonntag                                    [
4741b860509SRico Sonntag                                        'v' => 'Date(' . $century . ', 0, 1)',
4751b860509SRico Sonntag                                        'f' => $century,
4761b860509SRico Sonntag                                    ],
4771b860509SRico Sonntag                                    $values['M'],
4781b860509SRico Sonntag                                    $values['F'],
4791b860509SRico Sonntag                                ];
4801b860509SRico Sonntag                            }
4811b860509SRico Sonntag                        }
4821b860509SRico Sonntag                        ?>
4831b860509SRico Sonntag                        <?= view('lists/chart-by-decade', ['data' => $birthData, 'title' => I18N::translate('Decade of birth')]) ?>
4841b860509SRico Sonntag                    </div>
4851b860509SRico Sonntag                </div>
4861b860509SRico Sonntag            </div>
4871b860509SRico Sonntag        </div>
4881b860509SRico Sonntag        <div class="card-deck">
4891b860509SRico Sonntag            <div class="col-lg-12 col-md-12 mb-3">
4901b860509SRico Sonntag                <div class="card m-0">
4911b860509SRico Sonntag                    <div class="card-header">
4921b860509SRico Sonntag                        <?= I18N::translate('Decade of marriage') ?>
4931b860509SRico Sonntag                    </div><div class="card-body">
4941b860509SRico Sonntag                        <?php
4951b860509SRico Sonntag                        foreach ($marr_by_decade as $century => $values) {
4961b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
4971b860509SRico Sonntag                                $marriageData[] = [
4981b860509SRico Sonntag                                    [
4991b860509SRico Sonntag                                        'v' => 'Date(' . $century . ', 0, 1)',
5001b860509SRico Sonntag                                        'f' => $century,
5011b860509SRico Sonntag                                    ],
5021b860509SRico Sonntag                                    $values['M'],
5031b860509SRico Sonntag                                    $values['F'],
5041b860509SRico Sonntag                                ];
5051b860509SRico Sonntag                            }
5061b860509SRico Sonntag                        }
5071b860509SRico Sonntag                        ?>
5081b860509SRico Sonntag                        <?= view('lists/chart-by-decade', ['data' => $marriageData, 'title' => I18N::translate('Decade of marriage')]) ?>
5091b860509SRico Sonntag                    </div>
5101b860509SRico Sonntag                </div>
5111b860509SRico Sonntag            </div>
5121b860509SRico Sonntag        </div>
5131b860509SRico Sonntag        <div class="card-deck">
5141b860509SRico Sonntag            <div class="col-lg-12 col-md-12 mb-3">
5151b860509SRico Sonntag                <div class="card m-0">
5161b860509SRico Sonntag                    <div class="card-header">
5171b860509SRico Sonntag                        <?= I18N::translate('Age in year of marriage') ?>
5181b860509SRico Sonntag                    </div>
5191b860509SRico Sonntag                    <div class="card-body">
5201b860509SRico Sonntag                        <?php
5211b860509SRico Sonntag                            $totalAge = 0;
5221b860509SRico Sonntag                            $totalSum = 0;
5231b860509SRico Sonntag                            $max      = 0;
5241b860509SRico Sonntag
5251b860509SRico Sonntag                        foreach ($marr_by_age as $age => $values) {
5261b860509SRico Sonntag                            if (($values['M'] + $values['F']) > 0) {
5271b860509SRico Sonntag                                if (($values['M'] + $values['F']) > $max) {
5281b860509SRico Sonntag                                    $max = $values['M'] + $values['F'];
5291b860509SRico Sonntag                                }
5301b860509SRico Sonntag
5311b860509SRico Sonntag                                $totalAge += $age * ($values['M'] + $values['F']);
5321b860509SRico Sonntag                                $totalSum += $values['M'] + $values['F'];
5331b860509SRico Sonntag
5341b860509SRico Sonntag                                $marriageAgeData[] = [
5351b860509SRico Sonntag                                    $age,
5361b860509SRico Sonntag                                    $values['M'],
5371b860509SRico Sonntag                                    $values['F'],
5381b860509SRico Sonntag                                    null,
5391b860509SRico Sonntag                                ];
5401b860509SRico Sonntag                            }
5411b860509SRico Sonntag                        }
5421b860509SRico Sonntag
5431b860509SRico Sonntag                        if ($totalSum > 0) {
5441b860509SRico Sonntag                            $marriageAgeData[] = [
5451b860509SRico Sonntag                                round($totalAge / $totalSum, 1),
5461b860509SRico Sonntag                                null,
5471b860509SRico Sonntag                                null,
5481b860509SRico Sonntag                                0,
5491b860509SRico Sonntag                            ];
5501b860509SRico Sonntag
5511b860509SRico Sonntag                            $marriageAgeData[] = [
5521b860509SRico Sonntag                                round($totalAge / $totalSum, 1),
5531b860509SRico Sonntag                                null,
5541b860509SRico Sonntag                                null,
5551b860509SRico Sonntag                                $max,
5561b860509SRico Sonntag                            ];
5571b860509SRico Sonntag                        }
5581b860509SRico Sonntag                        ?>
5591b860509SRico Sonntag                        <?= view('lists/chart-by-age', ['data' => $marriageAgeData, 'title' => I18N::translate('Age in year of marriage')]) ?>
5601b860509SRico Sonntag                    </div>
5611b860509SRico Sonntag                </div>
5621b860509SRico Sonntag            </div>
5631b860509SRico Sonntag        </div>
564dd6b2bfcSGreg Roach    </div>
565dd6b2bfcSGreg Roach</div>
566