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