xref: /webtrees/resources/views/admin/map-import-form.phtml (revision 3d9e70a53ebdea3db408ada1769711840cc7d14c)
1<?php
2
3use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
4use Fisharebest\Webtrees\Http\RequestHandlers\MapDataImportAction;
5use Fisharebest\Webtrees\Http\RequestHandlers\MapDataList;
6use Fisharebest\Webtrees\I18N;
7use Fisharebest\Webtrees\View;
8
9/**
10 * @var array<string> $files
11 * @var string        $folder
12 * @var string        $title
13 */
14
15?>
16
17<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), route(MapDataList::class)  => I18N::translate('Geographic data'), $title]]) ?>
18
19<h3><?= $title ?></h3>
20
21<form method="post" action="<?= e(route(MapDataImportAction::class)) ?>" id="upload_form" enctype="multipart/form-data">
22    <?= csrf_field() ?>
23
24    <!-- Server file -->
25    <div class="row form-group">
26        <label class="col-form-label col-sm-4" for="serverfile">
27            <?= I18N::translate('A file on the server') ?>
28        </label>
29        <div class="col-sm-8">
30            <div class="input-group" dir="ltr">
31                <span class="input-group-text">
32                    <?= e($folder) ?>
33                </span>
34
35                <select id="serverfile" name="serverfile" class="form-control">
36                    <option selected value=""></option>
37                    <?php foreach ($files as $file) : ?>
38                        <option value="<?= e($file) ?>">
39                            <?= e($file) ?>
40                        </option>
41                    <?php endforeach ?>
42                </select>
43            </div>
44        </div>
45    </div>
46
47    <!-- local file -->
48    <div class="row form-group">
49        <label class="col-form-label col-sm-4" for="localfile">
50            <?= I18N::translate('A file on your computer') ?>
51        </label>
52        <div class="col-sm-8">
53            <input id="localfile" type="file" name="localfile" class="form-control-file">
54        </div>
55    </div>
56
57    <!-- CLEAR DATABASE -->
58    <fieldset class="row form-group">
59        <legend class="col-form-label col-sm-4">
60            <?= I18N::translate('Delete all existing geographic data before importing the file.') ?>
61        </legend>
62        <div class="col-sm-8">
63            <?= view('components/radios-inline', ['name' => 'cleardatabase', 'options' => [I18N::translate('no'), I18N::translate('yes')], 'selected' => 0]) ?>
64        </div>
65    </fieldset>
66
67    <!-- Import options -->
68    <fieldset class="row form-group">
69        <legend class="col-form-label col-sm-4">
70            <?= I18N::translate('Import') ?>
71        </legend>
72        <div class="col-sm-8">
73            <?= view('components/select', ['name' => 'import-options', 'selected' => '', 'options' => ['update' => I18N::translate('Only update existing records'), 'add' => I18N::translate('Only add new records'), 'addupdate' => I18N::translate('Add new, and update existing records')]]) ?>
74        </div>
75    </fieldset>
76
77    <!-- SAVE BUTTON -->
78    <div class="row form-group">
79        <div class="offset-sm-4 col-sm-8">
80            <button type="submit" class="btn btn-primary">
81                <?= view('icons/save') ?>
82                <?= I18N::translate('continue') ?>
83            </button>
84            <a href="<?= e(route(MapDataList::class)) ?>">
85                <?= view('icons/cancel') ?>
86                <?= /* I18N: A button label. */ I18N::translate('cancel') ?>
87            </a>
88        </div>
89    </div>
90</form>
91
92<?php View::push('javascript') ?>
93    <script>
94        $('#upload_form').on('submit', function(e) {
95            let self = this;
96            e.preventDefault();
97            if($('input[name="cleardatabase"]:checked').val() === '1') {
98                if (!confirm('<?= I18N::translate('Really delete all geographic data?') ?> ')) {
99                    return false;
100                }
101            }
102            self.submit();
103        });
104    </script>
105<?php View::endpush() ?>
106