2020-08-19 17:29:42 +02:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-08-19 17:29:42 +02:00
|
|
|
|
|
|
|
include_once __DIR__.'/../../../core.php';
|
|
|
|
include_once __DIR__.'/../init.php';
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<form action="" method="post" id="form-posizione">
|
|
|
|
<input type="hidden" name="backto" value="record-edit">
|
|
|
|
<input type="hidden" name="op" value="posizione">
|
|
|
|
|
|
|
|
<div class="row">
|
2023-08-03 18:15:54 +02:00
|
|
|
<div class="col-md-6" id="geocomplete">
|
2023-06-15 14:09:04 +02:00
|
|
|
{[ "type": "text", "label": "'.tr('Indirizzo').'", "name": "gaddress", "value": "'.$record['gaddress'].'", "extra": "data-geo=\'formatted_address\'" ]}
|
2020-08-19 17:29:42 +02:00
|
|
|
</div>
|
|
|
|
|
2023-08-03 18:15:54 +02:00
|
|
|
<div class="col-md-2">
|
|
|
|
<label> </label>
|
2023-08-04 14:54:28 +02:00
|
|
|
<br><button type="button" class="btn btn-primary" onclick="initGeocomplete();"><i class="fa fa-search"></i> '.tr('Cerca').'</button>
|
2020-08-19 17:29:42 +02:00
|
|
|
</div>
|
|
|
|
|
2023-08-03 18:15:54 +02:00
|
|
|
<div class="col-md-2">
|
2023-08-04 14:54:28 +02:00
|
|
|
{[ "type": "text", "label": "'.tr('Latitudine').'", "name": "lat", "value": "'.$record['lat'].'", "extra": "data-geo=\'lat\'", "class": "text-right", "readonly": true ]}
|
2020-08-19 17:29:42 +02:00
|
|
|
</div>
|
2023-06-15 14:09:04 +02:00
|
|
|
|
|
|
|
<div class="col-md-2">
|
2023-08-04 14:54:28 +02:00
|
|
|
{[ "type": "text", "label": "'.tr('Longitudine').'", "name": "lng", "value": "'.$record['lng'].'", "extra": "data-geo=\'lng\'", "class": "text-right", "readonly": true ]}
|
2023-06-15 14:09:04 +02:00
|
|
|
</div>
|
2023-08-03 18:15:54 +02:00
|
|
|
|
2020-08-19 17:29:42 +02:00
|
|
|
</div>
|
|
|
|
|
2021-03-23 16:41:23 +01:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
|
|
|
<div id="map" style="height:400px;"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div> </div>
|
2020-08-19 17:29:42 +02:00
|
|
|
<!-- PULSANTI -->
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12 text-right">
|
|
|
|
<button type="submit" class="btn btn-primary">
|
|
|
|
<i class="fa fa-save"></i> '.tr('Salva').'
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>';
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<script>$(document).ready(init)</script>
|
|
|
|
|
|
|
|
<script>
|
2023-06-29 09:49:21 +02:00
|
|
|
$("#modals > div").on("shown.bs.modal", function () {
|
2023-06-15 14:09:04 +02:00
|
|
|
if (input("lat").get() && input("lng").get()) {
|
2023-06-29 09:49:21 +02:00
|
|
|
caricaMappa();
|
2023-06-15 14:09:04 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function initGeocomplete() {
|
|
|
|
$.ajax({
|
|
|
|
url: "https://nominatim.openstreetmap.org/search.php?q=" + encodeURI(input("gaddress").get()) + "&format=jsonv2",
|
|
|
|
type : "GET",
|
|
|
|
dataType: "JSON",
|
|
|
|
success: function(data){
|
|
|
|
input("lat").set(data[0].lat);
|
|
|
|
input("lng").set(data[0].lon);
|
|
|
|
input("gaddress").set(data[0].display_name);
|
|
|
|
caricaMappa();
|
|
|
|
}
|
2020-09-07 10:34:42 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-06-29 09:49:21 +02:00
|
|
|
var map = null;
|
2023-06-15 14:09:04 +02:00
|
|
|
function caricaMappa() {
|
|
|
|
const lat = parseFloat(input("lat").get());
|
|
|
|
const lng = parseFloat(input("lng").get());
|
2023-08-08 15:33:28 +02:00
|
|
|
|
|
|
|
var container = L.DomUtil.get("map");
|
|
|
|
|
|
|
|
if (!lat || !lng){
|
|
|
|
|
|
|
|
var div = document.createElement("div");
|
|
|
|
div.innerHTML = "<div class=\'alert alert-info\'> <i class=\'fa fa-info\'></i> '.tr("La posizione non è stata definita"). '.</div>";
|
|
|
|
container.appendChild(div);
|
|
|
|
|
|
|
|
indirizzo = $("#indirizzo").val();
|
|
|
|
citta = $("#citta").val();
|
|
|
|
|
|
|
|
if (indirizzo || citta) {
|
|
|
|
$("#gaddress").val(indirizzo + ", " + citta);
|
|
|
|
initGeocomplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-06-15 14:09:04 +02:00
|
|
|
|
2023-06-29 09:49:21 +02:00
|
|
|
if(container._leaflet_id != null){
|
|
|
|
map.eachLayer(function (layer) {
|
|
|
|
if(layer instanceof L.Marker) {
|
|
|
|
map.removeLayer(layer);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
map = L.map("map", {
|
|
|
|
gestureHandling: true
|
|
|
|
});
|
2023-06-15 14:09:04 +02:00
|
|
|
|
2023-08-04 14:54:28 +02:00
|
|
|
L.tileLayer("'.setting('Tile server OpenStreetMap').'", {
|
2023-06-29 09:49:21 +02:00
|
|
|
maxZoom: 17,
|
|
|
|
attribution: "© OpenStreetMap"
|
|
|
|
}).addTo(map);
|
|
|
|
}
|
|
|
|
|
|
|
|
var icon = new L.Icon({
|
|
|
|
iconUrl: globals.rootdir + "/assets/dist/img/marker-icon.png",
|
|
|
|
shadowUrl:globals.rootdir + "/assets/dist/img/leaflet/marker-shadow.png",
|
|
|
|
iconSize: [25, 41],
|
|
|
|
iconAnchor: [12, 41],
|
|
|
|
popupAnchor: [1, -34],
|
|
|
|
shadowSize: [41, 41]
|
|
|
|
});
|
2023-06-15 14:09:04 +02:00
|
|
|
|
|
|
|
var marker = L.marker([lat, lng], {
|
|
|
|
icon: icon
|
|
|
|
}).addTo(map);
|
2023-06-29 09:49:21 +02:00
|
|
|
|
|
|
|
map.setView([lat, lng], 10);
|
2020-09-07 10:34:42 +02:00
|
|
|
}
|
2020-08-25 10:07:46 +02:00
|
|
|
|
|
|
|
// Ricaricamento della pagina alla chiusura
|
|
|
|
$("#modals > div button.close").on("click", function() {
|
|
|
|
location.reload();
|
|
|
|
});
|
2020-08-19 17:29:42 +02:00
|
|
|
</script>';
|