1<?php 2 3use Fisharebest\Webtrees\Census\CensusPlaceInterface; 4use Fisharebest\Webtrees\Date; 5use Fisharebest\Webtrees\I18N; 6 7/** 8 * @var array<CensusPlaceInterface> $census_places 9 */ 10 11?> 12 13<script> 14 function selectCensus(el) { 15 var option = $(":selected", el); 16 17 $("input[id^=DATE]", $(el).closest("form")).val(option.val()); 18 $("input[id^=PLAC]", $(el).closest("form")).val(option.data("place")); 19 $("input.census-class", $(el).closest("form")).val(option.data("census")); 20 } 21</script> 22 23<select id="census-selector" class="form-control" onchange="selectCensus(this)"> 24 <option value="" disabled selected hidden><?= I18N::translate('Census date') ?></option> 25 26 <?php foreach ($census_places as $census_place) : ?> 27 <optgroup label="<?= $census_place->censusPlace() ?>"> 28 <?php foreach ($census_place->allCensusDates() as $census) : ?> 29 <option value="<?= $census->censusDate() ?>" data-place="<?= $census->censusPlace() ?>" data-census="<?= get_class($census) ?>"> 30 <?= (new Date($census->censusDate()))->minimumDate()->format('%Y') ?> 31 <?php if ($census_place->censusPlace() !== $census->censusPlace()): ?> 32 — (<?= $census->censusPlace() ?>) 33 <?php endif ?> 34 </option> 35 <?php endforeach ?> 36 </optgroup> 37 <?php endforeach ?> 38</select> 39