1*1afbbc50SGreg Roach<?php 2*1afbbc50SGreg Roach 3*1afbbc50SGreg Roachuse Fisharebest\Webtrees\Gedcom; 4*1afbbc50SGreg Roachuse Fisharebest\Webtrees\GedcomCode\GedcomCodePedi; 5*1afbbc50SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ReorderFamiliesAction; 6*1afbbc50SGreg Roachuse Fisharebest\Webtrees\I18N; 7*1afbbc50SGreg Roachuse Fisharebest\Webtrees\View; 8*1afbbc50SGreg Roach 9*1afbbc50SGreg Roach?> 10*1afbbc50SGreg Roach 11*1afbbc50SGreg Roach<h2 class="wt-page-title"><?= $title ?></h2> 12*1afbbc50SGreg Roach 13*1afbbc50SGreg Roach<form method="post" action="<?= e(route(ReorderFamiliesAction::class, ['tree' => $tree->name(), 'xref' => $individual->xref()])) ?>" class="wt-page-content"> 14*1afbbc50SGreg Roach <?= csrf_field() ?> 15*1afbbc50SGreg Roach 16*1afbbc50SGreg Roach <?php if ($fams_facts->count() < 2) : ?> 17*1afbbc50SGreg Roach <?php foreach ($fams_facts as $fact) : ?> 18*1afbbc50SGreg Roach <input type="hidden" name="order[]" value="<?= e($fact->id()) ?>"> 19*1afbbc50SGreg Roach <?php endforeach ?> 20*1afbbc50SGreg Roach <?php else : ?> 21*1afbbc50SGreg Roach <h3><?= I18N::translate('Spouses') ?></h3> 22*1afbbc50SGreg Roach 23*1afbbc50SGreg Roach <p> 24*1afbbc50SGreg Roach <?= I18N::translate('When an individual has more than one spouse, you should sort the families in date order.') ?> 25*1afbbc50SGreg Roach </p> 26*1afbbc50SGreg Roach 27*1afbbc50SGreg Roach <p> 28*1afbbc50SGreg Roach <button class="btn btn-secondary" id="btn-default-order" type="button"> 29*1afbbc50SGreg Roach <?= view('icons/sort') ?> 30*1afbbc50SGreg Roach <?= /* I18N: A button label. */ I18N::translate('sort by date of marriage') ?> 31*1afbbc50SGreg Roach </button> 32*1afbbc50SGreg Roach </p> 33*1afbbc50SGreg Roach 34*1afbbc50SGreg Roach <div class="wt-sortable-list-fams"> 35*1afbbc50SGreg Roach <?php foreach ($fams_facts as $fact) : ?> 36*1afbbc50SGreg Roach <div class="card mb-2 wt-sortable-item" data-sortbydate="<?= $fact->target()->getMarriageDate()->julianDay() ?>"> 37*1afbbc50SGreg Roach <input type="hidden" name="order[]" value="<?= $fact->id() ?>"> 38*1afbbc50SGreg Roach <div class="card-header"> 39*1afbbc50SGreg Roach <span class="drag-handle"> 40*1afbbc50SGreg Roach <?= view('icons/drag-handle') ?> 41*1afbbc50SGreg Roach </span> 42*1afbbc50SGreg Roach <?= $fact->target()->fullName() ?> 43*1afbbc50SGreg Roach </div> 44*1afbbc50SGreg Roach <div class="card-body"> 45*1afbbc50SGreg Roach <?= $fact->target()->formatFirstMajorFact(Gedcom::MARRIAGE_EVENTS, 2) ?> 46*1afbbc50SGreg Roach <?= $fact->target()->formatFirstMajorFact(Gedcom::DIVORCE_EVENTS, 2) ?> 47*1afbbc50SGreg Roach </div> 48*1afbbc50SGreg Roach </div> 49*1afbbc50SGreg Roach <?php endforeach ?> 50*1afbbc50SGreg Roach </div> 51*1afbbc50SGreg Roach <?php endif ?> 52*1afbbc50SGreg Roach 53*1afbbc50SGreg Roach <?php if ($famc_facts->count() < 2) : ?> 54*1afbbc50SGreg Roach <?php foreach ($famc_facts as $fact) : ?> 55*1afbbc50SGreg Roach <input type="hidden" name="order[]" value="<?= e($fact->id()) ?>"> 56*1afbbc50SGreg Roach <?php endforeach ?> 57*1afbbc50SGreg Roach <?php else : ?> 58*1afbbc50SGreg Roach <?php if ($fams_facts->count() >= 2) : ?> 59*1afbbc50SGreg Roach <hr> 60*1afbbc50SGreg Roach <?php endif ?> 61*1afbbc50SGreg Roach 62*1afbbc50SGreg Roach <h3><?= I18N::translate('Parents') ?></h3> 63*1afbbc50SGreg Roach 64*1afbbc50SGreg Roach <p> 65*1afbbc50SGreg Roach <?= I18N::translate('An individual can have more than one set of parents. For example, birth and adopted.') ?> 66*1afbbc50SGreg Roach <br> 67*1afbbc50SGreg Roach <?= I18N::translate('The first family in the list will be used in charts, lists, reports, etc.') ?> 68*1afbbc50SGreg Roach </p> 69*1afbbc50SGreg Roach 70*1afbbc50SGreg Roach <div class="wt-sortable-list-famc"> 71*1afbbc50SGreg Roach <?php foreach ($famc_facts as $fact) : ?> 72*1afbbc50SGreg Roach <div class="card mb-2 wt-sortable-item" data-sortbydate="<?= $fact->target()->getMarriageDate()->julianDay() ?>"> 73*1afbbc50SGreg Roach <input type="hidden" name="order[]" value="<?= $fact->id() ?>"> 74*1afbbc50SGreg Roach <div class="card-header"> 75*1afbbc50SGreg Roach <span class="drag-handle"> 76*1afbbc50SGreg Roach <?= view('icons/drag-handle') ?> 77*1afbbc50SGreg Roach </span> 78*1afbbc50SGreg Roach <?= $fact->target()->fullName() ?> 79*1afbbc50SGreg Roach <?php if ($fact->attribute('PEDI') !== '') : ?> 80*1afbbc50SGreg Roach — <?= GedcomCodePedi::getValue($fact->attribute('PEDI'), $individual) ?> 81*1afbbc50SGreg Roach <?php endif ?> 82*1afbbc50SGreg Roach </div> 83*1afbbc50SGreg Roach <div class="card-body"> 84*1afbbc50SGreg Roach <?= $fact->target()->formatFirstMajorFact(Gedcom::MARRIAGE_EVENTS, 2) ?> 85*1afbbc50SGreg Roach <?= $fact->target()->formatFirstMajorFact(Gedcom::DIVORCE_EVENTS, 2) ?> 86*1afbbc50SGreg Roach </div> 87*1afbbc50SGreg Roach </div> 88*1afbbc50SGreg Roach <?php endforeach ?> 89*1afbbc50SGreg Roach </div> 90*1afbbc50SGreg Roach <?php endif ?> 91*1afbbc50SGreg Roach 92*1afbbc50SGreg Roach <p> 93*1afbbc50SGreg Roach <button class="btn btn-primary" type="submit"> 94*1afbbc50SGreg Roach <?= view('icons/save') ?> 95*1afbbc50SGreg Roach <?= /* I18N: A button label. */ I18N::translate('save') ?> 96*1afbbc50SGreg Roach </button> 97*1afbbc50SGreg Roach 98*1afbbc50SGreg Roach <a class="btn btn-secondary" href="<?= e($individual->url()) ?>"> 99*1afbbc50SGreg Roach <?= view('icons/cancel') ?> 100*1afbbc50SGreg Roach <?= /* I18N: A button label. */ I18N::translate('cancel') ?> 101*1afbbc50SGreg Roach </a> 102*1afbbc50SGreg Roach </p> 103*1afbbc50SGreg Roach</form> 104*1afbbc50SGreg Roach 105*1afbbc50SGreg Roach<?php View::push('javascript') ?> 106*1afbbc50SGreg Roach<script> 107*1afbbc50SGreg Roach new Sortable(document.querySelector(".wt-sortable-list-famc"), { 108*1afbbc50SGreg Roach handle: ".drag-handle", 109*1afbbc50SGreg Roach }); 110*1afbbc50SGreg Roach 111*1afbbc50SGreg Roach new Sortable(document.querySelector(".wt-sortable-list-fams"), { 112*1afbbc50SGreg Roach handle: ".drag-handle", 113*1afbbc50SGreg Roach }); 114*1afbbc50SGreg Roach 115*1afbbc50SGreg Roach $("#btn-default-order").on("click", function() { 116*1afbbc50SGreg Roach $(".wt-sortable-list-fams .wt-sortable-item").sort(function(x, y) { 117*1afbbc50SGreg Roach return Math.sign(x.dataset.sortbydate - y.dataset.sortbydate); 118*1afbbc50SGreg Roach }).appendTo(".wt-sortable-list-fams"); 119*1afbbc50SGreg Roach }); 120*1afbbc50SGreg Roach</script> 121*1afbbc50SGreg Roach<?php View::endpush() ?> 122