From 6d2aebf1d720902e2fd0623bacb574abd1e79f41 Mon Sep 17 00:00:00 2001 From: Dasc3er Date: Mon, 7 Sep 2020 10:34:42 +0200 Subject: [PATCH] Miglioramento interfaccia di geolocalizzazione --- modules/anagrafiche/edit.php | 62 ++++++++++++----------- modules/anagrafiche/modals/posizione.php | 30 +++++++---- modules/interventi/edit.php | 63 +++++++++++++----------- modules/ordini/quantita_impegnate.php | 4 +- plugins/receiptFE/src/Ricevuta.php | 1 - templates/ordini/body.php | 2 +- 6 files changed, 92 insertions(+), 70 deletions(-) diff --git a/modules/anagrafiche/edit.php b/modules/anagrafiche/edit.php index 9608232b7..2295f86c0 100755 --- a/modules/anagrafiche/edit.php +++ b/modules/anagrafiche/edit.php @@ -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 ' -'; -} echo '
@@ -214,6 +210,7 @@ echo '
'; +$map_load_message = '

'.tr('Clicca per visualizzare').'

'; if (empty($google)) { echo '
@@ -221,7 +218,9 @@ if (empty($google)) {
'; } elseif (!empty($sede_cliente->gaddress) || (!empty($sede_cliente->lat) && !empty($sede_cliente->lng))) { echo ' -
+
+ '.$map_load_message.' +

'; @@ -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, + }); + }); + } '; if ($is_cliente or $is_fornitore or $is_tecnico) { diff --git a/modules/anagrafiche/modals/posizione.php b/modules/anagrafiche/modals/posizione.php index 42fef0797..8a2f499a0 100644 --- a/modules/anagrafiche/modals/posizione.php +++ b/modules/anagrafiche/modals/posizione.php @@ -3,6 +3,8 @@ include_once __DIR__.'/../../../core.php'; include_once __DIR__.'/../init.php'; +$google = setting('Google Maps API key'); + echo '
@@ -38,15 +40,25 @@ echo ' '; -} echo '
@@ -98,6 +93,7 @@ echo '
'; +$map_load_message = '

'.tr('Clicca per visualizzare').'

'; if (empty($google)) { echo '
@@ -105,7 +101,9 @@ if (empty($google)) {
'; } elseif (!empty($sede_cliente->gaddress) || (!empty($sede_cliente->lat) && !empty($sede_cliente->lng))) { echo ' -
+
+ '.$map_load_message.' +

'; @@ -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, + }); + }); + } '; ?> diff --git a/modules/ordini/quantita_impegnate.php b/modules/ordini/quantita_impegnate.php index 45f2b9e2b..d10754742 100644 --- a/modules/ordini/quantita_impegnate.php +++ b/modules/ordini/quantita_impegnate.php @@ -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'; diff --git a/plugins/receiptFE/src/Ricevuta.php b/plugins/receiptFE/src/Ricevuta.php index d6d79c3ac..5fe7a0357 100755 --- a/plugins/receiptFE/src/Ricevuta.php +++ b/plugins/receiptFE/src/Ricevuta.php @@ -2,7 +2,6 @@ namespace Plugins\ReceiptFE; -use Carbon\Carbon; use Modules; use Modules\Fatture\Fattura; use Plugins; diff --git a/templates/ordini/body.php b/templates/ordini/body.php index ca7922111..6de609db8 100755 --- a/templates/ordini/body.php +++ b/templates/ordini/body.php @@ -27,7 +27,7 @@ echo " - "; + '; if ($has_image) { echo " ';
".tr('#', [], ['upper' => true])."".tr('#', [], ['upper' => true]).'".tr('Immagine', [], ['upper' => true]).'