xref: /webtrees/resources/views/modules/relationships-chart/page.phtml (revision ca50fb84724cb523ca8f4be8abd453a667296dcf)
1<?php
2
3use Fisharebest\Webtrees\I18N;
4use Fisharebest\Webtrees\View;
5
6?>
7
8<h2 class="wt-page-title">
9    <?= $title ?>
10</h2>
11
12<form method="post" class="wt-page-options wt-page-options-relationships-chart d-print-none">
13    <?= csrf_field() ?>
14
15    <div class="row form-group">
16        <label class="col-sm-3 col-form-label wt-page-options-label" for="xref">
17            <?= I18N::translate('Individual 1') ?>
18        </label>
19        <div class="col-sm-9 wt-page-options-value">
20            <?= view('components/select-individual', ['name' => 'xref', 'individual' => $individual1, 'tree' => $tree, 'required' => true]) ?>
21        </div>
22    </div>
23
24    <div class="row form-group">
25        <label class="col-sm-3 col-form-label wt-page-options-label" for="xref2">
26            <?= I18N::translate('Individual 2') ?>
27        </label>
28        <div class="col-sm-9 wt-page-options-value">
29            <?= view('components/select-individual', ['name' => 'xref2', 'individual' => $individual2, 'tree' => $tree, 'required' => true]) ?>
30        </div>
31    </div>
32
33    <fieldset class="form-group">
34        <div class="row">
35            <legend class="col-form-label col-sm-3 wt-page-options-label">
36            </legend>
37            <div class="col-sm-9 wt-page-options-value">
38                <?php if ($ancestors_only) : ?>
39                    <input type="hidden" name="ancestors" value="1">
40                    <?= I18N::translate('Find relationships via ancestors') ?>
41                <?php else : ?>
42                    <?= view('components/radios', ['name' => 'ancestors', 'options' => $ancestors_options, 'selected' => $ancestors]) ?>
43                <?php endif ?>
44            </div>
45        </div>
46    </fieldset>
47
48    <fieldset class="form-group">
49        <div class="row">
50            <legend class="col-form-label col-sm-3 wt-page-options-label">
51            </legend>
52            <div class="col-sm-9 wt-page-options-value">
53                <?php if ($max_recursion === 0) : ?>
54                    <?= I18N::translate('Find the closest relationships') ?>
55                    <input type="hidden" name="recursion" value="0">
56                <?php else : ?>
57                    <?= view('components/radios', ['name' => 'recursion', 'options' => $recursion_options, 'selected' => $recursion]) ?>
58                <?php endif ?>
59            </div>
60        </div>
61    </fieldset>
62
63    <div class="row form-group">
64        <div class="col-form-label col-sm-3 wt-page-options-label"></div>
65        <div class="col-sm-9 wt-page-options-value">
66            <button class="btn btn-primary" type="submit">
67                <?= /* I18N: A button label. */ I18N::translate('view') ?>
68            </button>
69
70            <button class="btn btn-link" id="btn-swap-individuals" type="button">
71                <?= /* I18N: Reverse the order of two individuals */
72                I18N::translate('Swap individuals') ?>
73            </button>
74        </div>
75    </div>
76</form>
77
78<?php if ($individual1 !== null && $individual2 !== null) : ?>
79    <div class="wt-ajax-load wt-page-content wt-chart wt-chart-relationships" data-ajax-url="<?= e($ajax_url) ?>"></div>
80<?php endif ?>
81
82<?php View::push('javascript') ?>
83<script>
84  $('#btn-swap-individuals').click(function () {
85      // Swap the name attributes
86      document.getElementById("xref").name = "xref2";
87      document.getElementById("xref2").name = "xref";
88      document.querySelector(".wt-page-options-relationships-chart").submit();
89  });
90</script>
91<?php View::endpush() ?>
92