Miglioramento interfaccia di geolocalizzazione

This commit is contained in:
Dasc3er 2020-09-07 10:34:42 +02:00
parent 1377bb61cd
commit 6d2aebf1d7
6 changed files with 92 additions and 70 deletions

View File

@ -201,10 +201,6 @@ $anagrafica_azienda = Anagrafica::find(setting('Azienda predefinita'));
$sede_azienda = $anagrafica_azienda->sedeLegale;
$google = setting('Google Maps API key');
if (!empty($google)) {
echo '
<script src="//maps.googleapis.com/maps/api/js?libraries=places&key='.$google.'"></script>';
}
echo '
<div class="col-md-4">
@ -214,6 +210,7 @@ echo '
</div>
<div class="panel-body">';
$map_load_message = '<p>'.tr('Clicca per visualizzare').'</p>';
if (empty($google)) {
echo '
<div class="alert alert-info">
@ -221,7 +218,9 @@ if (empty($google)) {
</div>';
} elseif (!empty($sede_cliente->gaddress) || (!empty($sede_cliente->lat) && !empty($sede_cliente->lng))) {
echo '
<div id="map-edit" style="height:200px; width:100%"></div>
<div id="map-edit" style="height: 200px;width: 100%;display: flex;align-items: center;justify-content: center;" onclick="caricaMappa()">
'.$map_load_message.'
</div>
<div class="clearfix"></div>
<br>';
@ -305,32 +304,39 @@ echo '
return lat + "," + lng;
}
$(document).ready(function() {
const map_element = $("#map-edit")[0];
const lat = parseFloat("'.$sede_cliente->lat.'");
const lng = parseFloat("'.$sede_cliente->lng.'");
function caricaMappa() {
const map_div = $("#map-edit");
if (map_div.html().trim() !== "'.$map_load_message.'"){
return;
}
if (!lat || !lng) return;
const position = new google.maps.LatLng(lat, lng);
$.getScript("//maps.googleapis.com/maps/api/js?libraries=places&key='.$google.'", function() {
const map_element = map_div[0];
const lat = parseFloat("'.$sede_cliente->lat.'");
const lng = parseFloat("'.$sede_cliente->lng.'");
// Create a Google Maps native view under the map_canvas div.
const map = new google.maps.Map(map_element, {
zoom: 14,
scrollwheel: false,
mapTypeControl: true,
mapTypeId: "roadmap",
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
mapTypeIds: ["roadmap", "terrain"],
}
});
if (!lat || !lng) return;
const position = new google.maps.LatLng(lat, lng);
map.setCenter(position);
const marker = new google.maps.Marker({
position: position,
map: map,
});
});
// Create a Google Maps native view under the map_canvas div.
const map = new google.maps.Map(map_element, {
zoom: 14,
scrollwheel: false,
mapTypeControl: true,
mapTypeId: "roadmap",
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
mapTypeIds: ["roadmap", "terrain"],
}
});
map.setCenter(position);
const marker = new google.maps.Marker({
position: position,
map: map,
});
});
}
</script>';
if ($is_cliente or $is_fornitore or $is_tecnico) {

View File

@ -3,6 +3,8 @@
include_once __DIR__.'/../../../core.php';
include_once __DIR__.'/../init.php';
$google = setting('Google Maps API key');
echo '
<form action="" method="post" id="form-posizione">
<input type="hidden" name="backto" value="record-edit">
@ -38,15 +40,25 @@ echo '
<script>$(document).ready(init)</script>
<script>
$("#geocomplete input").geocomplete({
map: $("#map").length ? "#map" : false,
location: $("#gaddress").val() ? $("#gaddress").val() : [$("#lat").val(), $("#lng").val()],
details: ".details",
detailsAttribute: "data-geo"
}).bind("geocode:result", function (event, result) {
$("#lat").val(result.geometry.location.lat());
$("#lng").val(result.geometry.location.lng());
});
if(window.google){
initGeocomplete();
} else {
$.getScript("//maps.googleapis.com/maps/api/js?libraries=places&key='.$google.'", function() {
initGeocomplete();
});
}
function initGeocomplete() {
$("#geocomplete input").geocomplete({
map: $("#map").length ? "#map" : false,
location: $("#gaddress").val() ? $("#gaddress").val() : [$("#lat").val(), $("#lng").val()],
details: ".details",
detailsAttribute: "data-geo"
}).bind("geocode:result", function (event, result) {
$("#lat").val(result.geometry.location.lat());
$("#lng").val(result.geometry.location.lng());
});
}
// Ricaricamento della pagina alla chiusura
$("#modals > div button.close").on("click", function() {

View File

@ -14,7 +14,6 @@ echo '
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="id_record" value="'.$id_record.'">
<div class="row">
<div class="col-md-8">
<!-- DATI CLIENTE -->
@ -85,10 +84,6 @@ $anagrafica_azienda = Anagrafica::find(setting('Azienda predefinita'));
$sede_azienda = $anagrafica_azienda->sedeLegale;
$google = setting('Google Maps API key');
if (!empty($google)) {
echo '
<script src="//maps.googleapis.com/maps/api/js?libraries=places&key='.$google.'"></script>';
}
echo '
<div class="col-md-4">
@ -98,6 +93,7 @@ echo '
</div>
<div class="panel-body">';
$map_load_message = '<p>'.tr('Clicca per visualizzare').'</p>';
if (empty($google)) {
echo '
<div class="alert alert-info">
@ -105,7 +101,9 @@ if (empty($google)) {
</div>';
} elseif (!empty($sede_cliente->gaddress) || (!empty($sede_cliente->lat) && !empty($sede_cliente->lng))) {
echo '
<div id="map-edit" style="height:200px; width:100%"></div>
<div id="map-edit" style="height: 200px;width: 100%;display: flex;align-items: center;justify-content: center;" onclick="caricaMappa()">
'.$map_load_message.'
</div>
<div class="clearfix"></div>
<br>';
@ -177,32 +175,39 @@ echo '
return lat + "," + lng;
}
$(document).ready(function() {
const map_element = $("#map-edit")[0];
const lat = parseFloat("'.$sede_cliente->lat.'");
const lng = parseFloat("'.$sede_cliente->lng.'");
function caricaMappa() {
const map_div = $("#map-edit");
if (map_div.html().trim() !== "'.$map_load_message.'"){
return;
}
if (!lat || !lng) return;
const position = new google.maps.LatLng(lat, lng);
$.getScript("//maps.googleapis.com/maps/api/js?libraries=places&key='.$google.'", function() {
const map_element = map_div[0];
const lat = parseFloat("'.$sede_cliente->lat.'");
const lng = parseFloat("'.$sede_cliente->lng.'");
// Create a Google Maps native view under the map_canvas div.
const map = new google.maps.Map(map_element, {
zoom: 14,
scrollwheel: false,
mapTypeControl: true,
mapTypeId: "roadmap",
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
mapTypeIds: ["roadmap", "terrain"],
}
});
if (!lat || !lng) return;
const position = new google.maps.LatLng(lat, lng);
map.setCenter(position);
const marker = new google.maps.Marker({
position: position,
map: map,
});
});
// Create a Google Maps native view under the map_canvas div.
const map = new google.maps.Map(map_element, {
zoom: 14,
scrollwheel: false,
mapTypeControl: true,
mapTypeId: "roadmap",
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
mapTypeIds: ["roadmap", "terrain"],
}
});
map.setCenter(position);
const marker = new google.maps.Marker({
position: position,
map: map,
});
});
}
</script>';
?>

View File

@ -40,8 +40,8 @@ foreach ($articoli as $elenco) {
WHERE or_ordini.id != '.prepare($ordine->id).'
AND idstatoordine = (SELECT id FROM or_statiordine WHERE descrizione = 'Bozza')
AND idtipoordine IN (SELECT id FROM or_tipiordine WHERE dir = 'entrata')
AND idarticolo=".prepare($articolo->id)."
GROUP BY idarticolo")['qta'];
AND idarticolo=".prepare($articolo->id).'
GROUP BY idarticolo')['qta'];
$qta_impegnata = floatval($qta_impegnata);
$class = $qta_impegnata + $qta > $articolo->qta ? 'danger' : 'success';

View File

@ -2,7 +2,6 @@
namespace Plugins\ReceiptFE;
use Carbon\Carbon;
use Modules;
use Modules\Fatture\Fattura;
use Plugins;

View File

@ -27,7 +27,7 @@ echo "
<table class='table table-striped table-bordered' id='contents'>
<thead>
<tr>
<th class='text-center' style='width:5%'>".tr('#', [], ['upper' => true])."</th>";
<th class='text-center' style='width:5%'>".tr('#', [], ['upper' => true]).'</th>';
if ($has_image) {
echo "
<th class='text-center' style='width:20%'>".tr('Immagine', [], ['upper' => true]).'</th>';