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]).'