xref: /webtrees/resources/views/modules/relationships-chart/page.phtml (revision 56d475424b46df195a76f2a149ee5a07327497e8)
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    <?= csrf_field() ?>
30
31    <div class="row form-group">
32        <label class="col-sm-3 col-form-label wt-page-options-label" for="xref">
33            <?= I18N::translate('Individual 1') ?>
34        </label>
35        <div class="col-sm-9 wt-page-options-value">
36            <?= view('components/select-individual', ['name' => 'xref', 'individual' => $individual1, 'tree' => $tree, 'required' => true]) ?>
37        </div>
38    </div>
39
40    <div class="row form-group">
41        <label class="col-sm-3 col-form-label wt-page-options-label" for="xref2">
42            <?= I18N::translate('Individual 2') ?>
43        </label>
44        <div class="col-sm-9 wt-page-options-value">
45            <?= view('components/select-individual', ['name' => 'xref2', 'individual' => $individual2, 'tree' => $tree, 'required' => true]) ?>
46        </div>
47    </div>
48
49    <fieldset class="form-group">
50        <div class="row">
51            <legend class="col-form-label col-sm-3 wt-page-options-label">
52            </legend>
53            <div class="col-sm-9 wt-page-options-value">
54                <?php if ($ancestors_only) : ?>
55                    <input type="hidden" name="ancestors" value="1">
56                    <?= I18N::translate('Find relationships via ancestors') ?>
57                <?php else : ?>
58                    <?= view('components/radios', ['name' => 'ancestors', 'options' => $ancestors_options, 'selected' => $ancestors]) ?>
59                <?php endif ?>
60            </div>
61        </div>
62    </fieldset>
63
64    <fieldset class="form-group">
65        <div class="row">
66            <legend class="col-form-label col-sm-3 wt-page-options-label">
67            </legend>
68            <div class="col-sm-9 wt-page-options-value">
69                <?php if ($max_recursion === 0) : ?>
70                    <?= I18N::translate('Find the closest relationships') ?>
71                    <input type="hidden" name="recursion" value="0">
72                <?php else : ?>
73                    <?= view('components/radios', ['name' => 'recursion', 'options' => $recursion_options, 'selected' => $recursion]) ?>
74                <?php endif ?>
75            </div>
76        </div>
77    </fieldset>
78
79    <div class="row form-group">
80        <div class="col-form-label col-sm-3 wt-page-options-label"></div>
81        <div class="col-sm-9 wt-page-options-value">
82            <button class="btn btn-primary" type="submit">
83                <?= /* I18N: A button label. */ I18N::translate('view') ?>
84            </button>
85
86            <button class="btn btn-link" id="btn-swap-individuals" type="button">
87                <?= /* I18N: Reverse the order of two individuals */
88                I18N::translate('Swap individuals') ?>
89            </button>
90        </div>
91    </div>
92</form>
93
94<?php if ($individual1 !== null && $individual2 !== null) : ?>
95    <div class="wt-ajax-load wt-page-content wt-chart wt-chart-relationships" data-ajax-url="<?= e($ajax_url) ?>"></div>
96<?php endif ?>
97
98<?php View::push('javascript') ?>
99<script>
100  $('#btn-swap-individuals').click(function () {
101      // Swap the name attributes
102      document.getElementById("xref").name = "xref2";
103      document.getElementById("xref2").name = "xref";
104      document.querySelector(".wt-page-options-relationships-chart").submit();
105  });
106</script>
107<?php View::endpush() ?>
108