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