Changeset f35c98c


Ignore:
Timestamp:
Nov 7, 2025, 4:05:15 PM (4 weeks ago)
Author:
rgigli <147847165+rgigli@…>
Branches:
main
Children:
9996219, e200df2
Parents:
0d5f1b3
Message:

pagina di configurazione del sito

Aggiunto il salvataggio dei dati inseriti. E' parziale, vanno inseriti gli altri campi

Location:
admin
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • admin/modules/setup_sito.php

    r0d5f1b3 rf35c98c  
    88$EMAIL_ADMIN = $row[0]['adminmail'];
    99$MAP_PROVIDER = $row[0]['googlemaps']==='1' ? 'google' : 'openstreetmap' ;
    10 $MULTICOMUNE = $row[0]['multicomune']==='1' ? 'si' : 'no';
     10$MULTICOMUNE = $row[0]['multicomune']; #==='1' ? 'si' : 'no';
    1111$gru = [
    12     'google_api_key' => "'".$row[0]['gkey']."'"
     12    'google_api_key' => $row[0]['gkey']
    1313];
    1414#$MAP_PROVIDER = isset($gru['googlemaps']) && in_array($gru['googlemaps'], ['google', 'openstreetmap']) ? $gru['googlemaps'] : 'openstreetmap';
    1515$GOOGLE_API_KEY = !empty($gru['google_api_key']) ? htmlspecialchars($gru['google_api_key']) : '';
    16 
     16$GOOGLE_API_KEY = $row[0]['gkey'];
    1717$SITE_ISTAT=$row[0]['siteistat'];
    1818$row=elenco_comuni();
    1919foreach($row as $key=>$val){
    20         $comuni_disponibili[]=$val['descrizione'];
     20        if(!isset($DEFAULT_COMUNE)) {$DEFAULT_COMUNE=$val['descrizione']; $SITE_ISTAT_TMP=$val['id_comune'];}
     21        $comuni_disponibili[]=[$val['descrizione'],$val['id_comune']];
    2122        if($val['id_comune']==$SITE_ISTAT) $DEFAULT_COMUNE=$val['descrizione'];
    2223}
     
    3536      </div>
    3637      <div class="card-body">
    37         <form>
     38        <form id="configSitoForm" onsubmit="aggiornaDati(event)">
    3839          <!-- LOGO + ANTEPRIMA -->
    3940          <div class="mb-3 d-flex align-items-center">
     
    9596            <label for="multicomune" class="form-label">Gestione multicomune?</label>
    9697            <select class="form-select" name="multicomune" id="multicomune" onchange="toggleComuneDefault()">
    97               <option value="si" <?= $MULTICOMUNE === 'si' ? 'selected' : '' ?>>Si</option>
    98               <option value="no" <?= $MULTICOMUNE === 'no' ? 'selected' : '' ?>>No</option>
     98              <option value="1" <?= $MULTICOMUNE === '1' ? 'selected' : '' ?>>Si</option>
     99              <option value="0" <?= $MULTICOMUNE === '0' ? 'selected' : '' ?>>No</option>
    99100            </select>
    100101          </div>
    101102
    102103          <!-- COMUNE DI DEFAULT -->
    103           <div class="mb-3" id="defaultComuneRow" style="<?= $MULTICOMUNE === 'si' ? '' : 'display:none;' ?>">
     104          <div class="mb-3" id="defaultComuneRow" style="<?= $MULTICOMUNE === '1' ? '' : 'display:none;' ?>">
    104105            <label for="defaultComune" class="form-label">Comune visualizzato per default</label>
    105106            <select class="form-select" name="default_comune" id="defaultComune">
    106107              <?php foreach ($comuni_disponibili as $comune): ?>
    107                 <option value="<?= htmlspecialchars($comune) ?>" <?= $DEFAULT_COMUNE === $comune ? 'selected' : '' ?>>
    108                   <?= htmlspecialchars($comune) ?>
     108                <option value="<?= $comune[1] ?>" <?= $SITE_ISTAT === $comune[1] ? 'selected' : '' ?>>
     109                  <?= htmlspecialchars($comune[0]) ?>
    109110                </option>
    110111              <?php endforeach; ?>
     
    129130            <button type="submit" class="btn btn-primary">Salva</button>
    130131          </div>
     132          <div class="d-flex justify-content-end" id="risultato">
     133         
     134          </div>
    131135        </form>
    132136      </div>
     
    136140
    137141<script>
     142  function aggiornaDati(e) {
     143    e.preventDefault();
     144    const siteName = document.getElementById('siteName').value;
     145    const siteUrl = document.getElementById('siteUrl').value;
     146    const emailAdmin = document.getElementById('emailAdmin').value;
     147    const mapsProvider = document.getElementById('maps_provider').value;
     148    const googleApiKey = document.getElementById('googleApiKey').value;
     149    const multicomune = document.getElementById('multicomune').value;
     150    const defaultComune = document.getElementById('defaultComune').value;
     151
     152    // Salvataggio nel DB (commentato)
     153    var xmlhttp = new XMLHttpRequest();
     154    xmlhttp.onreadystatechange = function() {
     155                if (this.readyState == 4 && this.status == 200) {
     156                                document.getElementById("risultato").innerHTML = this.responseText;
     157                                document.getElementById("bottoneStato").focus();
     158                }
     159    }
     160    xmlhttp.open("GET","../principale.php?funzione=salvaConfigSito&siteName="+siteName+"&siteUrl="+siteUrl+"&emailAdmin="+emailAdmin+"&mapsProvider="+mapsProvider+"&googleApiKey="+googleApiKey+"&multicomune="+multicomune+"&defaultComune="+defaultComune,true);
     161    xmlhttp.send();
     162  }
     163
    138164  // Tooltip Bootstrap 5 init
    139165  document.addEventListener('DOMContentLoaded', function () {
     
    172198  function toggleComuneDefault() {
    173199    const multicomune = document.getElementById('multicomune').value;
    174     document.getElementById('defaultComuneRow').style.display = (multicomune === 'si') ? '' : 'none';
    175   }
     200    document.getElementById('defaultComuneRow').style.display = (multicomune === '1') ? '' : 'none';
     201  }
     202 
     203  function nascondiElemento() {
     204  const elemento = document.getElementById('risultato');
     205  if (elemento) {
     206    // Imposta la proprietà CSS display su 'none'
     207    elemento.style.display = 'none';
     208  }
     209}
    176210</script>
  • admin/principale.php

    r0d5f1b3 rf35c98c  
    9393                include("modules/salva_orario_affluenza.php");
    9494                break;
     95        case 'salvaConfigSito':
     96                include("modules/salva_config_sito.php");
     97                break;
    9598        case 101:
    9699                include("ws/funzioni/salvaModifiche.php");
Note: See TracChangeset for help on using the changeset viewer.