1<?php 2 3declare(strict_types=1); 4 5use Fisharebest\Webtrees\I18N; 6use Fisharebest\Webtrees\Individual; 7use Fisharebest\Webtrees\Tree; 8use Fisharebest\Webtrees\View; 9 10/** 11 * @var string $ajax_url 12 * @var int $ancestors 13 * @var array<string,string> $ancestors_options 14 * @var bool $ancestors_only 15 * @var Individual|null $individual1 16 * @var Individual|null $individual2 17 * @var int $max_recursion 18 * @var int $recursion 19 * @var array<string,string> $recursion_options 20 * @var string $title 21 * @var Tree $tree 22 */ 23 24?> 25 26<h2 class="wt-page-title"> 27 <?= $title ?> 28</h2> 29 30<form method="post" class="wt-page-options wt-page-options-relationships-chart d-print-none"> 31 <div class="row"> 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"> 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 mb-3"> 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 mb-3"> 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 mb-3"> 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 89 <?= csrf_field() ?> 90</form> 91 92<?php if ($individual1 !== null && $individual2 !== null) : ?> 93 <div class="wt-ajax-load wt-page-content wt-chart wt-chart-relationships" data-wt-ajax-url="<?= e($ajax_url) ?>"></div> 94<?php endif ?> 95 96<?php View::push('javascript') ?> 97<script> 98 $('#btn-swap-individuals').click(function () { 99 // Swap the name attributes 100 document.getElementById("xref").name = "xref2"; 101 document.getElementById("xref2").name = "xref"; 102 document.querySelector(".wt-page-options-relationships-chart").submit(); 103 }); 104</script> 105<?php View::endpush() ?> 106