1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-01-03 03:19:17 +01:00

Aggiunto supporto a Google Maps

This commit is contained in:
Thomas Zilio 2017-09-18 11:22:02 +02:00
parent f8120f9cf7
commit 2badc57898
4 changed files with 73 additions and 15 deletions

View File

@ -56,6 +56,9 @@ switch (post('op')) {
'foro_competenza' => $post['foro_competenza'],
'colore' => $post['colore'],
'idtipointervento_default' => $post['idtipointervento_default'],
'gaddress' => $post['gaddress'],
'lat' => $post['lat'],
'lng' => $post['lng'],
], ['idanagrafica' => $id_record]);
$_SESSION['infos'][] = str_replace('_NAME_', '"'.$post['ragione_sociale'].'"', "Informazioni per l'anagrafica _NAME_ salvate correttamente!");

View File

@ -2,8 +2,14 @@
include_once __DIR__.'/../../core.php';
?>
<form action="" method="post" role="form">
$google = Settings::get('Google Maps API key');
if (!empty($google)) {
echo '
<script src="http://maps.googleapis.com/maps/api/js?libraries=places&key='.$google.'"></script>';
}
?><form action="" method="post" role="form">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="op" value="update">
@ -165,7 +171,6 @@ if ($fornitore) {
</div>
</div>
<?php
}
if ($cliente) {
@ -184,7 +189,6 @@ if ($fornitore) {
</div>
</div>
<?php
} ?>
<div class="row">
@ -203,7 +207,6 @@ if ($fornitore) {
</div>
</div>
<?php
}
?>
@ -305,7 +308,6 @@ if ($fornitore) {
{[ "type": "text", "label": "<?php echo tr('Colore'); ?>", "name": "colore", "class": "colorpicker text-center", "value": "$colore$", "extra": "maxlength='7'", "icon-after": "<div class='img-circle square'></div>" ]}
</div>
<?php
} ?>
<?php
if (in_array('Cliente', explode(',', $records[0]['tipianagrafica']))) {
@ -318,14 +320,11 @@ if ($fornitore) {
{[ "type": "select", "label": "<?php echo tr('Relazione con il cliente'); ?>", "name": "idrelazione", "values": "query=SELECT id, descrizione, colore AS _bgcolor_ FROM an_relazioni ORDER BY descrizione", "value": "$idrelazione$" ]}
</div>
<?php
} ?>
<div class="col-md-3">
{[ "type": "text", "label": "<?php echo tr('Capitale sociale'); ?>", "name": "capitale_sociale", "value": "$capitale_sociale$" ]}
</div>
</div>
@ -334,6 +333,46 @@ if ($fornitore) {
{[ "type": "textarea", "label": "<?php echo tr('Note'); ?>", "name": "note", "value": "$note$" ]}
</div>
</div>
<?php
if (!empty($google)) {
echo '
<div class="row">
<div class="col-md-9">
<div class="row">
<div class="col-md-4" id="geocomplete">
{[ "type": "text", "label": "'.tr('Indirizzo Google').'", "name": "gaddress", "value": "$gaddress$", "extra": "data-geo=\'formatted_address\'" ]}
</div>
<div class="col-md-4">
{[ "type": "text", "label": "'.tr('Latitudine').'", "name": "lat", "value": "$lat$", "extra": "data-geo=\'lat\'", "class": "text-right" ]}
</div>
<div class="col-md-4">
{[ "type": "text", "label": "'.tr('Longitudine').'", "name": "lng", "value": "$lng$", "extra": "data-geo=\'lng\'", "class": "text-right" ]}
</div>
</div>
</div>';
// Calcola percorso
if (empty($records[0]['gaddress']) || (empty($records[0]['lat']) && empty($records[0]['lng']))) {
echo '
<div class="col-md-3">
<label>&nbsp;</label><br>
<a class="btn btn-info" onclick="window.open(\'https://maps.google.com/maps/search/\'+encodeURI( $(\'#indirizzo\').val() )+\', \'+encodeURI( $(\'#citta\').val() ) );"><i class="fa fa-map-marker"></i> Cerca su Google Maps...</a>
</div>';
}
echo '
</div>';
if (!empty($records[0]['gaddress']) || (!empty($records[0]['lat']) && !empty($records[0]['lng']))) {
echo '
<div id="map" style="height:400px; width:100%"></div>';
}
}
?>
</div>
</div>
</form>
@ -353,6 +392,16 @@ if (!str_contains($records[0]['idtipianagrafica'], $id_azienda)) {
});
$('#colore').parent().find('.square').css('background', $('#colore').val());
$("#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());
});
});
</script>

View File

@ -45,6 +45,7 @@
"eonasdan-bootstrap-datetimepicker": "^4.17.47",
"font-awesome": "^4.7.0",
"fullcalendar": "^3.4.0",
"geocomplete": "^1.7.0",
"inputmask": "^3.3.6",
"jquery": "^3.2.1",
"jquery-form": "^4.2.1",

View File

@ -941,8 +941,13 @@ UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Stampe
UPDATE `zz_modules` SET `title` = `name` WHERE `title` = '';
-- Aggiunta del campo per introdurre l'help nei widget
ALTER TABLE `zz_widgets` ADD `help` VARCHAR(255) NULL;
ALTER TABLE `zz_widgets` ADD `help` varchar(255);
-- ALTER TABLE `my_componenti_interventi` ADD PRIMARY KEY (`id_intervento`, `id_componente`);
-- ALTER TABLE `my_impianti_interventi` ADD PRIMARY KEY (`idintervento`, `idimpianto`);
-- ALTER TABLE `co_righe_documenti`ADD FOREIGN KEY (`idintervento`) REFERENCES `in_interventi`(`id`) ON DELETE CASCADE;
-- Aggiunta delle mappe Google
INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES ('Google Maps API key', '', 'string', '1', 'Generali');
ALTER TABLE `an_anagrafiche` ADD `gaddress` varchar(255), ADD `lat` float(10, 5), ADD `lng` float(10, 5);