xref: /webtrees/resources/views/modules/GEDFact_assistant/select-census.phtml (revision 241a1636dee0487eb56818cbf3b6a79ceaf02090)
1<?php use Fisharebest\Webtrees\Date; ?>
2<?php use Fisharebest\Webtrees\I18N; ?>
3
4<script>
5  function selectCensus(el) {
6    var option = $(":selected", el);
7
8    $("input[id^=DATE]", $(el).closest("form")).val(option.val());
9    $("input[id^=PLAC]", $(el).closest("form")).val(option.data("place"));
10    $("input.census-class", $(el).closest("form")).val(option.data("census"));
11  }
12</script>
13
14<select id="census-selector" class="form-control" onchange="selectCensus(this)">
15    <option value=""><?= I18N::translate('Census date') ?></option>
16
17    <?php foreach ($census_places as $census_place) : ?>
18        <option value=""></option>
19        <?php foreach ($census_place->allCensusDates() as $census) : ?>
20            <option value="<?= $census->censusDate() ?>" data-place="<?= $census->censusPlace() ?>" data-census="<?= get_class($census) ?>">
21                <?= (explode(', ', $census->censusPlace()))[0] ?>
22                <?= (new Date($census->censusDate()))->minimumDate()->format('%Y') ?>
23            </option>
24        <?php endforeach ?>
25    <?php endforeach ?>
26</select>
27