xref: /webtrees/resources/views/modules/relationships-chart/page.phtml (revision a8b39ba2d349525974d59077419f7a8ea8802aaa)
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="row form-group">
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 ($ancestors_only) : ?>
54                <input type="hidden" name="ancestors" value="1">
55                <?= I18N::translate('Find relationships via ancestors') ?>
56            <?php else : ?>
57                <?= view('components/radios', ['name' => 'ancestors', 'options' => $ancestors_options, 'selected' => $ancestors]) ?>
58            <?php endif ?>
59        </div>
60    </fieldset>
61
62    <fieldset class="row form-group">
63        <legend class="col-form-label col-sm-3 wt-page-options-label">
64        </legend>
65        <div class="col-sm-9 wt-page-options-value">
66            <?php if ($max_recursion === 0) : ?>
67                <?= I18N::translate('Find the closest relationships') ?>
68                <input type="hidden" name="recursion" value="0">
69            <?php else : ?>
70                <?= view('components/radios', ['name' => 'recursion', 'options' => $recursion_options, 'selected' => $recursion]) ?>
71            <?php endif ?>
72        </div>
73    </fieldset>
74
75    <div class="row form-group">
76        <div class="col-form-label col-sm-3 wt-page-options-label"></div>
77        <div class="col-sm-9 wt-page-options-value">
78            <button class="btn btn-primary" type="submit">
79                <?= /* I18N: A button label. */ I18N::translate('view') ?>
80            </button>
81
82            <button class="btn btn-link" id="btn-swap-individuals" type="button">
83                <?= /* I18N: Reverse the order of two individuals */
84                I18N::translate('Swap individuals') ?>
85            </button>
86        </div>
87    </div>
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