xref: /webtrees/resources/views/modules/relationships-chart/page.phtml (revision 242a78626998a767db1568b24919e94ae4b38ac3)
19b5537c3SGreg Roach<?php use Fisharebest\Webtrees\Bootstrap4; ?>
29b5537c3SGreg Roach<?php use Fisharebest\Webtrees\Functions\FunctionsEdit; ?>
39b5537c3SGreg Roach<?php use Fisharebest\Webtrees\I18N; ?>
49b5537c3SGreg Roach<?php use Fisharebest\Webtrees\View; ?>
59b5537c3SGreg Roach
69b5537c3SGreg Roach<h2 class="wt-page-title">
79b5537c3SGreg Roach    <?= $title ?>
89b5537c3SGreg Roach</h2>
99b5537c3SGreg Roach
109b5537c3SGreg Roach<form class="wt-page-options wt-page-options-relationships-chart d-print-none">
119b5537c3SGreg Roach    <input type="hidden" name="route" value="module">
129b5537c3SGreg Roach    <input type="hidden" name="module" value="<?= e($module_name) ?>">
139b5537c3SGreg Roach    <input type="hidden" name="action" value="Chart">
149b5537c3SGreg Roach    <input type="hidden" name="ged" value="<?= e($tree->name()) ?>">
159b5537c3SGreg Roach
169b5537c3SGreg Roach    <div class="row form-group">
173dcc812bSGreg Roach        <label class="col-sm-3 col-form-label wt-page-options-label" for="xref">
189b5537c3SGreg Roach            <?= I18N::translate('Individual 1') ?>
199b5537c3SGreg Roach        </label>
209b5537c3SGreg Roach        <div class="col-sm-9 wt-page-options-value">
219b5537c3SGreg Roach            <?= FunctionsEdit::formControlIndividual($tree, $individual1, [
223dcc812bSGreg Roach                'id'   => 'xref',
233dcc812bSGreg Roach                'name' => 'xref',
249b5537c3SGreg Roach            ]) ?>
259b5537c3SGreg Roach            <button class="btn btn-link small" id="btn-swap-individuals" type="button">
269b5537c3SGreg Roach                <?= /* I18N: Reverse the order of two individuals */
279b5537c3SGreg Roach                I18N::translate('Swap individuals') ?>
289b5537c3SGreg Roach            </button>
299b5537c3SGreg Roach        </div>
309b5537c3SGreg Roach    </div>
319b5537c3SGreg Roach
329b5537c3SGreg Roach    <div class="row form-group">
339b5537c3SGreg Roach        <label class="col-sm-3 col-form-label wt-page-options-label" for="xref2">
349b5537c3SGreg Roach            <?= I18N::translate('Individual 2') ?>
359b5537c3SGreg Roach        </label>
369b5537c3SGreg Roach        <div class="col-sm-9 wt-page-options-value">
379b5537c3SGreg Roach            <?= FunctionsEdit::formControlIndividual($tree, $individual2, [
389b5537c3SGreg Roach                'id'   => 'xref2',
399b5537c3SGreg Roach                'name' => 'xref2',
409b5537c3SGreg Roach            ]) ?>
419b5537c3SGreg Roach        </div>
429b5537c3SGreg Roach    </div>
439b5537c3SGreg Roach
449b5537c3SGreg Roach    <fieldset class="form-group">
459b5537c3SGreg Roach        <div class="row">
469b5537c3SGreg Roach            <legend class="col-form-label col-sm-3 wt-page-options-label">
479b5537c3SGreg Roach            </legend>
489b5537c3SGreg Roach            <div class="col-sm-9 wt-page-options-value">
499b5537c3SGreg Roach                <?php if ($ancestors_only) : ?>
509b5537c3SGreg Roach                    <input type="hidden" name="ancestors" value="1">
519b5537c3SGreg Roach                    <?= I18N::translate('Find relationships via ancestors') ?>
529b5537c3SGreg Roach                <?php else : ?>
539b5537c3SGreg Roach                    <?= Bootstrap4::radioButtons('ancestors', $ancestors_options, $ancestors, false) ?>
549b5537c3SGreg Roach                <?php endif ?>
559b5537c3SGreg Roach            </div>
569b5537c3SGreg Roach        </div>
579b5537c3SGreg Roach    </fieldset>
589b5537c3SGreg Roach
599b5537c3SGreg Roach    <fieldset class="form-group">
609b5537c3SGreg Roach        <div class="row">
619b5537c3SGreg Roach            <legend class="col-form-label col-sm-3 wt-page-options-label">
629b5537c3SGreg Roach            </legend>
639b5537c3SGreg Roach            <div class="col-sm-9 wt-page-options-value">
649b5537c3SGreg Roach                <?php if ($max_recursion === 0) : ?>
659b5537c3SGreg Roach                    <?= I18N::translate('Find the closest relationships') ?>
669b5537c3SGreg Roach                    <input type="hidden" name="recursion" value="0">
679b5537c3SGreg Roach                <?php else : ?>
689b5537c3SGreg Roach                    <?= Bootstrap4::radioButtons('recursion', $recursion_options, $recursion, false) ?>
699b5537c3SGreg Roach                <?php endif ?>
709b5537c3SGreg Roach            </div>
719b5537c3SGreg Roach        </div>
729b5537c3SGreg Roach    </fieldset>
739b5537c3SGreg Roach
749b5537c3SGreg Roach    <div class="row form-group">
759b5537c3SGreg Roach        <div class="col-form-label col-sm-3 wt-page-options-label"></div>
769b5537c3SGreg Roach        <div class="col-sm-9 wt-page-options-value">
779b5537c3SGreg Roach            <input class="btn btn-primary" type="submit" value="<?= /* I18N: A button label. */
789b5537c3SGreg Roach            I18N::translate('view') ?>">
799b5537c3SGreg Roach        </div>
809b5537c3SGreg Roach    </div>
819b5537c3SGreg Roach</form>
829b5537c3SGreg Roach
839b5537c3SGreg Roach<?php if ($individual1 !== null && $individual2 !== null) : ?>
84*242a7862SGreg Roach    <div class="wt-ajax-load wt-page-content wt-chart wt-chart-relationships" data-ajax-url="<?= e($ajax_url) ?>"></div>
859b5537c3SGreg Roach<?php endif ?>
869b5537c3SGreg Roach
879b5537c3SGreg Roach<?php View::push('javascript') ?>
889b5537c3SGreg Roach<script>
899b5537c3SGreg Roach  $('#btn-swap-individuals').click(function () {
909b5537c3SGreg Roach    // Swap the (hidden) options of the select
913dcc812bSGreg Roach    var select1       = document.querySelector('#xref');
929b5537c3SGreg Roach    var select2       = document.querySelector('#xref2');
939b5537c3SGreg Roach    var tmp_html      = select1.innerHTML;
949b5537c3SGreg Roach    select1.innerHTML = select2.innerHTML;
959b5537c3SGreg Roach    select2.innerHTML = tmp_html;
969b5537c3SGreg Roach
979b5537c3SGreg Roach    // Also swap the select2 element
983dcc812bSGreg Roach    var span1       = document.querySelector('#xref + span');
999b5537c3SGreg Roach    var span2       = document.querySelector('#xref2 + span');
1009b5537c3SGreg Roach    var tmp_html    = span1.innerHTML;
1013dcc812bSGreg Roach    span1.innerHTML = span2.innerHTML.replace('xref2', 'xref');
1023dcc812bSGreg Roach    span2.innerHTML = tmp_html.replace('xref', 'xref2');
1039b5537c3SGreg Roach  });
1049b5537c3SGreg Roach</script>
1059b5537c3SGreg Roach<?php View::endpush() ?>
106