xref: /webtrees/resources/views/family-page-children.phtml (revision 45ebc6c6221f90468111ed2015b8449dca331d93)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Family;
6use Fisharebest\Webtrees\Http\RequestHandlers\AddChildToFamilyPage;
7use Fisharebest\Webtrees\Http\RequestHandlers\ReorderChildrenPage;
8use Fisharebest\Webtrees\I18N;
9
10/**
11 * @var Family $family
12 */
13
14?>
15
16<div class="align-self-center">
17    <div class="badge bg-secondary m-2">
18        <?php if ($family->children()->count() === 0) : ?>
19            <?= I18N::translate('No children') ?>
20        <?php else : ?>
21            <?= I18N::plural('%s child', '%s children', $family->children()->count(), I18N::number($family->children()->count())) ?>
22        <?php endif ?>
23    </div>
24    <?php foreach ($family->children() as $n => $child) : ?>
25        <div class="d-flex">
26            <?= view('chart-box', ['individual' => $child]) ?>
27            <div class="wt-chart-horizontal-spacer">
28                <?php if ($family->children()->count() === 1) : ?>
29                    <div class="wt-chart-horizontal-line"></div>
30                <?php elseif ($n === 0) : ?>
31                    <div class="wt-chart-horizontal-first-child"></div>
32                <?php elseif ($n + 1 === $family->children()->count()) : ?>
33                    <div class="wt-chart-horizontal-last-child"></div>
34                <?php else : ?>
35                    <div class="wt-chart-horizontal-middle-child"><div class="wt-chart-horizontal-line"></div></div>
36                <?php endif ?>
37            </div>
38        </div>
39    <?php endforeach ?>
40    <?php if ($family->canEdit()) : ?>
41        <div class="wt-chart-box">
42            <a class="btn btn-link" href="<?= e(route(AddChildToFamilyPage::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'sex' => 'M'])) ?>">
43                <?= I18N::translate('Add a son') ?>
44            </a>
45            |
46            <a class="btn btn-link" href="<?= e(route(AddChildToFamilyPage::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'sex' => 'F'])) ?>">
47                <?= I18N::translate('Add a daughter') ?>
48            </a>
49            <br>
50            <?php if ($family->numberOfChildren() > 1) : ?>
51                <a class="btn btn-link" href="<?= e(route(ReorderChildrenPage::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>">
52                    <?= I18N::translate('Re-order children') ?>
53                </a>
54            <?php endif ?>
55        </div>
56    <?php endif ?>
57</div>
58<?php if ($family->children()->count() !== 1) : ?>
59    <div class="wt-chart-horizontal-spacer">
60        <div class="wt-chart-horizontal-line"></div>
61    </div>
62<?php endif ?>
63