.
*/
include_once __DIR__.'/../../core.php';
if (get('op') == 'getmappa') {
$nome = 'Ricarica mappa';
} else {
$nome = 'Visualizza mappa';
}
echo "
".$nome.'';
echo '
';
if (get('op') == 'getmappa') {
$current_module = Modules::get($id_module);
$total = Util\Query::readQuery($current_module);
$module_query = Modules::replaceAdditionals($id_module, $total['query']);
$search_filters = [];
if (is_array($_SESSION['module_'.$id_module])) {
foreach ($_SESSION['module_'.$id_module] as $field_name => $field_value) {
if ($field_value != '' && $field_name != 'selected' && $field_name != 'id_segment') {
$field_name = str_replace('search_', '', $field_name);
$field_name = str_replace('__', ' ', $field_name);
$field_name = str_replace('-', ' ', $field_name);
array_push($search_filters, '`'.$field_name.'` LIKE "%'.$field_value.'%"');
}
}
}
if (sizeof($search_filters) > 0) {
$module_query = str_replace('2=2', '2=2 AND ('.implode(' AND ', $search_filters).') ', $module_query);
}
$rs1 = $dbo->fetchArray($module_query);
// marker svg
if (!file_exists($docroot.'/assets/dist/img/leaflet/place-marker.svg')) {
throw new Exception('File not found: '.$docroot.'/assets/dist/img/leaflet/place-marker.svg');
}
$svgContent = file_get_contents($docroot.'/assets/dist/img/leaflet/place-marker.svg');
if ($svgContent === false) {
throw new Exception('Error reading file: '.$docroot.'/assets/dist/img/leaflet/place-marker.svg');
}
$stringa_descrizioni = '';
$stringa_content = '';
$color = '';
$lat = '';
$lng = '';
for ($i = 0; $i < sizeof($rs1); ++$i) {// elenco delle righe
$val = html_entity_decode((string) $rs1[$i]['idanagrafica']);
$id_sede = $dbo->selectOne('in_interventi', '*', ['id' => $rs1[$i]['id']])['idsede_destinazione'];
if ($id_sede) {
$query = "SELECT *, nomesede AS ragione_sociale FROM an_sedi WHERE id='".$id_sede."'";
$rs = $dbo->fetchArray($query);
} else {
$query = "SELECT *, ragione_sociale FROM an_anagrafiche WHERE idanagrafica='".$val."'";
$rs = $dbo->fetchArray($query);
}
if ($rs[0]['lat'] && $rs[0]['lng']) {
$color .= "'".$rs1[$i]['_bg_']."',";
$lat .= "'".$rs[0]['lat']."',";
$lng .= "'".$rs[0]['lng']."',";
$stringa_descrizioni .= "'".str_replace("'", ' ', $rs[0]['ragione_sociale'])."',";
$stringa_content .= "'";
$stringa_content .= str_replace("'", '', ''.$rs[0]['ragione_sociale'].'
'.$rs[0]['indirizzo'].', '.$rs[0]['cap'].', '.$rs[0]['citta'].' ('.$rs[0]['provincia'].')'.($rs[0]['telefono'] != '' ? '
'.$rs[0]['telefono'] : '').($rs[0]['email'] != '' ? '
'.$rs[0]['email'] : '').'
');
$altri_interventi = $dbo->fetchArray('SELECT * FROM in_interventi WHERE idsede_destinazione='.prepare($id_sede).' AND idanagrafica='.prepare($val).' AND id IN ('.implode(',', array_column($rs1, 'id')).')');
for ($j = 0; $j < sizeof($altri_interventi); ++$j) {
$stringa_content .= str_replace("'", '', '
Intervento numero: '.$altri_interventi[$j]['codice'].' del '.date('d/m/Y', strtotime((string) $altri_interventi[$j]['data_richiesta'])).'');
}
$stringa_content .= "',";
}
}
echo "";
$stringa_descrizioni = substr($stringa_descrizioni, 0, -1);
$stringa_content = substr($stringa_content, 0, -1);
$lat = substr($lat, 0, -1);
$lng = substr($lng, 0, -1);
?>