xref: /webtrees/resources/views/modules/GEDFact_assistant/select-census.phtml (revision 6fd7250f6c16d6ac1ede6f02b0e2892379acc193)
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') ?>
3132                  <?= $census->censusPlace() ?>
33              </option>
34          <?php endforeach ?>
35        </optgroup>
36    <?php endforeach ?>
37</select>
38