xref: /webtrees/resources/views/admin/map-import-form.phtml (revision 1ff45046fabc22237b5d0d8e489c96f031fc598d)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
6use Fisharebest\Webtrees\Http\RequestHandlers\MapDataImportAction;
7use Fisharebest\Webtrees\Http\RequestHandlers\MapDataList;
8use Fisharebest\Webtrees\I18N;
9use Fisharebest\Webtrees\View;
10
11/**
12 * @var array<string> $files
13 * @var string        $folder
14 * @var string        $title
15 */
16
17?>
18
19<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), route(MapDataList::class)  => I18N::translate('Geographic data'), $title]]) ?>
20
21<h3><?= $title ?></h3>
22
23<form method="post" action="<?= e(route(MapDataImportAction::class)) ?>" id="upload_form" enctype="multipart/form-data">
24    <div class="row mb-3">
25        <label class="col-form-label col-sm-4">
26            <input type="radio" name="source" id="import-client" value="client" checked>
27            <?= I18N::translate('A file on your computer') ?>
28        </label>
29        <div class="col-sm-8">
30            <input id="import-client-file" type="file" name="client_file" class="form-control">
31        </div>
32    </div>
33
34    <div class="row mb-3">
35        <label class="col-form-label col-sm-4">
36            <input type="radio" name="source" id="import-server" value="server">
37            <?= I18N::translate('A file on the server') ?>
38        </label>
39        <div class="col-sm-8">
40            <div class="input-group" dir="ltr">
41                <span class="input-group-text" dir="ltr">
42                    <?= e($folder) ?>
43                </span>
44
45                <select name="server_file" class="form-select" dir="ltr" id="import-server-file">
46                    <option selected="selected" value="">&nbsp;</option>
47                    <?php foreach ($files as $file) : ?>
48                        <option value="<?= e($file) ?>">
49                            <?= e($file) ?>
50                        </option>
51                    <?php endforeach ?>
52                </select>
53            </div>
54        </div>
55    </div>
56
57    <!-- Import options -->
58    <fieldset class="row mb-3">
59        <legend class="col-form-label col-sm-4">
60            <?= I18N::translate('Import') ?>
61        </legend>
62        <div class="col-sm-8">
63            <?= view('components/select', ['name' => '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')]]) ?>
64        </div>
65    </fieldset>
66
67    <!-- SAVE BUTTON -->
68    <div class="row mb-3">
69        <div class="offset-sm-4 col-sm-8">
70            <button type="submit" class="btn btn-primary">
71                <?= view('icons/save') ?>
72                <?= I18N::translate('continue') ?>
73            </button>
74            <a href="<?= e(route(MapDataList::class)) ?>">
75                <?= view('icons/cancel') ?>
76                <?= /* I18N: A button label. */ I18N::translate('cancel') ?>
77            </a>
78        </div>
79    </div>
80
81    <?= csrf_field() ?>
82</form>
83
84<?php View::push('javascript') ?>
85<script>
86  document.getElementById('import-client-file').addEventListener('focus', function () {
87    document.getElementById('import-client').checked = true;
88  });
89
90  document.getElementById('import-server-file').addEventListener('focus', function () {
91    document.getElementById('import-server').checked = true;
92  });
93</script>
94<?php View::endpush() ?>
95