xref: /webtrees/resources/views/modules/GEDFact_assistant/select-census.phtml (revision 3d2c98d1066d5e178a3d1ceb3bdc58b7ba8ee926)
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=""><?= I18N::translate('Census date') ?></option>
25
26    <?php foreach ($census_places as $census_place) : ?>
27        <option value="">&nbsp;</option>
28        <?php foreach ($census_place->allCensusDates() as $census) : ?>
29            <option value="<?= $census->censusDate() ?>" data-place="<?= $census->censusPlace() ?>" data-census="<?= get_class($census) ?>">
30                <?= (explode(', ', $census->censusPlace()))[0] ?>
31                <?= (new Date($census->censusDate()))->minimumDate()->format('%Y') ?>
32            </option>
33        <?php endforeach ?>
34    <?php endforeach ?>
35</select>
36