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