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