xref: /webtrees/resources/views/modules/family-book-chart/chart.phtml (revision 10e0649788c8d7d4974d81c048ca2b225df8f22e)
1b7765f6bSGreg Roach<?php
2b7765f6bSGreg Roach
3*10e06497SGreg Roachdeclare(strict_types=1);
4*10e06497SGreg Roach
5b7765f6bSGreg Roachuse Fisharebest\Webtrees\Family;
6b7765f6bSGreg Roachuse Fisharebest\Webtrees\I18N;
7b7765f6bSGreg Roachuse Fisharebest\Webtrees\Individual;
8b7765f6bSGreg Roachuse Illuminate\Support\Collection;
9b7765f6bSGreg Roach
10b7765f6bSGreg Roach/**
11b7765f6bSGreg Roach * @var int        $book_size
12b7765f6bSGreg Roach * @var int        $generations
13b7765f6bSGreg Roach * @var Individual $individual
1471378461SGreg Roach * @var bool       $spouses
15b7765f6bSGreg Roach */
16b7765f6bSGreg Roach
176c2179e2SGreg Roach$children = $individual->spouseFamilies()->map(static function (Family $family): Collection {
186c2179e2SGreg Roach    return $family->children();
196c2179e2SGreg Roach})->flatten();
20b7765f6bSGreg Roach
21b7765f6bSGreg Roach?>
22b7765f6bSGreg Roach
23b7765f6bSGreg Roach<h3><?= I18N::translate('Family of %s', $individual->fullName()) ?></h3>
24b7765f6bSGreg Roach
25b7765f6bSGreg Roach<div class="d-flex wt-chart-family-book">
26b7765f6bSGreg Roach    <?= view('modules/family-book-chart/children', ['children' => $children, 'generations' => $book_size - 1]) ?>
27b7765f6bSGreg Roach    <div class="align-self-center">
28b7765f6bSGreg Roach        <?= view('chart-box', ['individual' => $individual]) ?>
2971378461SGreg Roach        <?php if ($spouses) : ?>
30b7765f6bSGreg Roach            <?php foreach ($individual->spouseFamilies() as $family) : ?>
31b7765f6bSGreg Roach                <?= view('chart-box', ['individual' => $family->spouse($individual)]) ?>
32b7765f6bSGreg Roach            <?php endforeach ?>
33b7765f6bSGreg Roach        <?php endif ?>
34b7765f6bSGreg Roach    </div>
35b7765f6bSGreg Roach    <div class="wt-chart-horizontal-spacer">
36b7765f6bSGreg Roach        <div class="wt-chart-horizontal-line"></div>
37b7765f6bSGreg Roach    </div>
381afbbc50SGreg Roach    <?= view('modules/family-book-chart/parents', ['generations' => $book_size - 1, 'family' => $individual->childFamilies()->first()]) ?>
39b7765f6bSGreg Roach</div>
40b7765f6bSGreg Roach
41b7765f6bSGreg Roach<?php if ($generations > 1) : ?>
42b7765f6bSGreg Roach    <?php foreach ($children as $child) : ?>
43b7765f6bSGreg Roach        <hr class="wt-family-separator">
4471378461SGreg Roach        <?= view('modules/family-book-chart/chart', ['individual' => $child, 'generations' => $generations - 1, 'book_size' => $book_size, 'spouses' => $spouses]) ?>
45b7765f6bSGreg Roach    <?php endforeach ?>
46b7765f6bSGreg Roach<?php endif ?>
47