xref: /webtrees/resources/views/admin/map-import-form.phtml (revision 1bdbe4be8b89ea7a9cca535712d11b03e44ed743)
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                <div class="input-group-prepend">
32                            <span class="input-group-text">
33                                <?= e($folder) ?>
34                            </span>
35                </div>
36                <select id="serverfile" name="serverfile" class="form-control">
37                    <option selected value=""></option>
38                    <?php foreach ($files as $file) : ?>
39                        <option value="<?= e($file) ?>">
40                            <?= e($file) ?>
41                        </option>
42                    <?php endforeach ?>
43                </select>
44            </div>
45        </div>
46    </div>
47
48    <!-- local file -->
49    <div class="row form-group">
50        <label class="col-form-label col-sm-4" for="localfile">
51            <?= I18N::translate('A file on your computer') ?>
52        </label>
53        <div class="col-sm-8">
54            <input id="localfile" type="file" name="localfile" class="form-control-file">
55        </div>
56    </div>
57
58    <!-- CLEAR DATABASE -->
59    <fieldset class="form-group">
60        <div class="row">
61            <legend class="col-form-label col-sm-4">
62                <?= I18N::translate('Delete all existing geographic data before importing the file.') ?>
63            </legend>
64            <div class="col-sm-8">
65                <?= view('components/radios-inline', ['name' => 'cleardatabase', 'options' => [I18N::translate('no'), I18N::translate('yes')], 'selected' => 0]) ?>
66            </div>
67        </div>
68    </fieldset>
69
70    <!-- Import options -->
71    <fieldset class="form-group">
72        <div class="row">
73            <legend class="col-form-label col-sm-4" for="import-options">
74                <?= I18N::translate('Import') ?>
75            </legend>
76            <div class="col-sm-8">
77                <?= 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')]]) ?>
78            </div>
79        </div>
80    </fieldset>
81
82    <!-- SAVE BUTTON -->
83    <div class="row form-group">
84        <div class="offset-sm-4 col-sm-8">
85            <button type="submit" class="btn btn-primary">
86                <?= view('icons/save') ?>
87                <?= I18N::translate('continue') ?>
88            </button>
89            <a href="<?= e(route(MapDataList::class)) ?>">
90                <?= view('icons/cancel') ?>
91                <?= /* I18N: A button label. */ I18N::translate('cancel') ?>
92            </a>
93        </div>
94    </div>
95</form>
96
97<?php View::push('javascript') ?>
98    <script>
99        $('#upload_form').on('submit', function(e) {
100            let self = this;
101            e.preventDefault();
102            if($('input[name="cleardatabase"]:checked').val() === '1') {
103                if (!confirm('<?= I18N::translate('Really delete all geographic data?') ?> ')) {
104                    return false;
105                }
106            }
107            self.submit();
108        });
109    </script>
110<?php View::endpush() ?>
111