xref: /webtrees/resources/views/admin/locations.phtml (revision e340fe65d66c30f8416fe6cc6a22bb4eb8a4bb1d)
1<?php
2
3use Fisharebest\Webtrees\I18N;
4use Fisharebest\Webtrees\Webtrees;
5
6?>
7
8<?= view('components/breadcrumbs', ['links' => $breadcrumbs]) ?>
9
10<h1><?= $title ?></h1>
11
12<table class="table table-bordered table-striped table-sm table-hover">
13    <thead class="thead-dark">
14        <tr>
15            <th><?= I18N::translate('Place') ?></th>
16            <th><?= I18N::translate('Latitude') ?></th>
17            <th><?= I18N::translate('Longitude') ?></th>
18            <!--
19            <th><?= I18N::translate('Flag') ?> </th>
20            -->
21            <th><?= I18N::translate('Edit') ?></th>
22            <th><?= I18N::translate('Delete') ?></th>
23        </tr>
24    </thead>
25
26    <tbody>
27    <?php foreach ($placelist as $place) : ?>
28        <tr>
29            <th scope="row">
30                <a href="<?= e(route('map-data', ['parent_id' => $place->pl_id])) ?>">
31                    <?= e($place->pl_place) ?>
32                    <span class="badge badge-pill badge-<?= $place->badge ?>">
33                        <?= I18N::number($place->child_count) ?>
34                    </span>
35                </a>
36            </th>
37
38            <td dir="ltr">
39                <?php if ($place->pl_lati === null) : ?>
40                    <?= view('icons/warning') ?>
41                <?php else : ?>
42                    <?= strtr($place->pl_lati, ['N' => '', 'S' => '-', ',' => '.']) ?>
43                <?php endif ?>
44            </td>
45
46            <td dir="ltr">
47                <?php if ($place->pl_long === null) : ?>
48                    <?= view('icons/warning') ?>
49                <?php else : ?>
50                    <?= strtr($place->pl_long, ['E' => '', 'W' => '-', ',' => '.']) ?>
51                <?php endif ?>
52            </td>
53
54            <!--
55            <td>
56                <?php if (is_file(Webtrees::MODULES_PATH . 'openstreetmap/' . $place->pl_icon)) : ?>
57                    <img src="<?= e(Webtrees::MODULES_PATH . 'openstreetmap/' . $place->pl_icon) ?>" width="25" height="15" alt="<?= I18N::translate('Flag of %s', $place->pl_place) ?>">
58                <?php endif ?>
59            </td>
60            -->
61
62            <td>
63                <a class="btn btn-primary" href="<?= e(route('map-data-edit', ['place_id'  => $place->pl_id, 'parent_id' => $place->pl_parent_id])) ?>" title="<?= I18N::translate('Edit') ?>">
64                    <?= view('icons/edit') ?>
65                    <span class="sr-only">
66                        <?= I18N::translate('Edit') ?>
67                    </span>
68                </a>
69            </td>
70
71            <td>
72                <?php if ($place->child_count === 0) : ?>
73                    <form method="post" action="<?= e(route('map-data-delete', ['parent_id' => $parent_id, 'place_id' => $place->pl_id])) ?>"
74                          data-confirm="<?= I18N::translate('Remove this location?') ?>"
75                          onsubmit="return confirm(this.dataset.confirm)">
76                        <?= csrf_field() ?>
77                        <button type="submit" class="btn btn-danger" aria-label="<?= I18N::translate('delete') ?>">
78                            <?= view('icons/delete') ?>
79                        </button>
80                    </form>
81                <?php else : ?>
82                    <button type="button" class="btn btn-danger" disabled>
83                        <?= view('icons/delete') ?>
84                    </button>
85                <?php endif ?>
86            </td>
87        </tr>
88    <?php endforeach ?>
89    </tbody>
90
91    <tfoot>
92        <tr>
93            <td colspan="7">
94                <a class="btn btn-primary" href="<?= e(route('map-data-edit', ['place_id' => '0', 'parent_id' => $parent_id])) ?>">
95                    <?= view('icons/add') ?>
96                    <?= /* I18N: A button label. */
97                    I18N::translate('add place') ?>
98                </a>
99                <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton"
100                        data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
101                    <?= view('icons/download') ?>
102                    <?= /* I18N: A button label. */
103                    I18N::translate('export file') ?>
104                </button>
105                <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
106                    <a class="dropdown-item" href="<?= e(route('locations-export', ['parent_id' => $parent_id, 'format' => 'csv'])) ?>">
107                        csv
108                    </a>
109                    <a class="dropdown-item" href="<?= e(route('locations-export', ['parent_id' => $parent_id, 'format' => 'geojson'])) ?>">
110                        geoJSON
111                    </a>
112                </div>
113                <a class="btn btn-primary" href="<?= e(route('locations-import', ['parent_id' => $parent_id])) ?>">
114                    <?= view('icons/upload') ?>
115                    <?= /* I18N: A button label. */
116                    I18N::translate('import file') ?>
117                </a>
118            </td>
119        </tr>
120    </tfoot>
121</table>
122
123<form method="post" action="<?= e(route('locations-import-from-tree')) ?>">
124    <?= csrf_field() ?>
125
126    <div class="form-group row">
127        <label class="form-control-plaintext col-sm-4" for="tree">
128            <?= I18N::translate('Import all places from a family tree') ?>
129        </label>
130        <div class="col-sm-6">
131            <?= view('components/select', ['name' => 'ged', 'selected' => '', 'options' => $tree_titles]) ?>
132        </div>
133        <div class="col-sm-2">
134            <button type="submit" class="btn btn-primary">
135                <?= view('icons/upload') ?>
136                <?= /* I18N: A button label. */
137                I18N::translate('import') ?>
138            </button>
139        </div>
140    </div>
141</form>
142