Changeset 65575a8
- Timestamp:
- Dec 5, 2025, 1:14:04 PM (3 days ago)
- Branches:
- main
- Children:
- a1f2a9f
- Parents:
- 2e3acf5
- Location:
- admin
- Files:
-
- 2 added
- 13 edited
-
aggiornadb.php (modified) (1 diff)
-
includes/aggiornadbTo4.php (added)
-
includes/menu.php (modified) (6 diffs)
-
includes/query.php (modified) (3 diffs)
-
includes/sidebar.php (modified) (3 diffs)
-
modules/aggiorna_rev.php (modified) (2 diffs)
-
modules/aggiornamento.php (modified) (1 diff)
-
modules/contenuto.php (modified) (1 diff)
-
modules/elenco_consultazioni.php (modified) (1 diff)
-
modules/gestione_affluenza.php (modified) (1 diff)
-
modules/gestione_consultazioni.php (modified) (5 diffs)
-
modules/modules.php (modified) (1 diff)
-
modules/salva_consultazione.php (added)
-
modules/setup_sito.php (modified) (4 diffs)
-
principale.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
admin/aggiornadb.php
r2e3acf5 r65575a8 679 679 $ret=aggiorna_index($tab,$ind,$dbi,$sql2,$num); 680 680 681 ######################## 682 $sql= "RENAME TABLE `soraldo_ele_candidati` TO `soraldo_ele_candidato`, `soraldo_ele_collegi` TO `soraldo_ele_collegio`, `soraldo_ele_comuni` TO `soraldo_ele_comune`, `soraldo_ele_comu_collegi` TO `soraldo_ele_comu_collegio`, `soraldo_ele_controlli` TO `soraldo_ele_controllo`, `soraldo_ele_documenti` TO `soraldo_ele_documento`, `soraldo_ele_fasce` TO `soraldo_ele_fascia`, `soraldo_ele_modelli` TO `soraldo_ele_modello`, `soraldo_ele_numeri` TO `soraldo_ele_numero`, `soraldo_ele_operatori` TO `soraldo_ele_operatore`, `soraldo_ele_province` TO `soraldo_ele_provincia`, `soraldo_ele_regioni` TO `soraldo_ele_regione`, `soraldo_ele_servizi` TO `soraldo_ele_servizio`, `soraldo_ele_sezioni` TO `soraldo_ele_sezione`, `soraldo_ele_temi` TO `soraldo_ele_tema`, `soraldo_ele_voti_candidati` TO `soraldo_ele_voti_candidato`, `soraldo_ws_funzioni` TO `soraldo_ws_funzione`, `soraldo_ws_sezioni` TO `soraldo_ws_sezione`"; 683 $res = $dbi->prepare("$sql"); 684 $res->execute(); 685 ####################### 686 681 687 echo "<br><br>".++$num.") Modifica Charset del database"; 682 688 flush(); ob_flush(); -
admin/includes/menu.php
r2e3acf5 r65575a8 1 1 <?php 2 2 require_once '../includes/check_access.php'; 3 require_once '../includes/versione.php';3 #require_once '../includes/versione.php'; 4 4 require_once '../includes/query.php'; 5 5 // NOTIFICHE DINAMICHE … … 78 78 return ['rev' => $rev, 'tempo' => $tempo ?: 'Adesso']; 79 79 } 80 80 global $patch; 81 if(!isset($_SESSION['tipo_cons'])) $_SESSION['tipo_cons']=''; 81 82 // Estrai build corrente 82 preg_match('/rev\s*(\d+)/i', $versione, $match); 83 $build_corrente = isset($match[1]) ? (int)$match[1] : 0; 83 #preg_match('/rev\s*(\d+)/i', $versione, $match); 84 $build_corrente = $patch; 85 #isset($match[1]) ? (int)$match[1] : 0; 84 86 85 87 // Ottieni revisione online e tempo … … 132 134 // Array esempio consultazioni, id => nome 133 135 $row=elenco_cons(); 136 $consultazioni=array(); 134 137 foreach($row as $key=>$val){ 135 138 $consultazioni[$val['id_cons_gen']] = $val['descrizione']; … … 183 186 </select> 184 187 </div> 185 < div class="form-group mb-2">188 <!--div class="form-group mb-2"> 186 189 <label for="comune-mobile">Comune</label> 187 190 <select class="form-control form-control-sm" name="id_comune" id="comune-mobile"> … … 190 193 <?php endforeach; ?> 191 194 </select> 192 </div >195 </div--> 193 196 </form> 194 197 </div> … … 203 206 <?php endforeach; ?> 204 207 </select> 205 < select class="form-control form-control-sm mr-2" name="id_comune" id="comune">208 <!--select class="form-control form-control-sm mr-2" name="id_comune" id="comune"> 206 209 <?php foreach ($comuni as $id => $nomeComune): ?> 207 210 <option value="<?= $id ?>" <?= ($id == $id_comune) ? 'selected' : '' ?>><?= $nomeComune ?></option> 208 211 <?php endforeach; ?> 209 </select >212 </select--> 210 213 </form> 211 214 212 215 <script> 213 216 // Submit automatico al cambio select desktop e mobile 214 ['consultazione' , 'comune'].forEach(id => {217 ['consultazione'].forEach(id => { 215 218 document.getElementById(id).addEventListener('change', () => { 216 219 document.getElementById('form-consultazione').submit(); -
admin/includes/query.php
r2e3acf5 r65575a8 28 28 } 29 29 30 function dati_cons_comune($id) 31 { 32 global $dbi,$prefix,$id_cons_gen; 33 if(!$id) $id=$id_cons_gen; 34 $sql="SELECT * FROM ".$prefix."_ele_cons_comune where id_cons_gen='$id'"; 35 $sth = $dbi->prepare("$sql"); 36 $sth->execute(); 37 $row = $sth->fetchAll(PDO::FETCH_ASSOC); 38 return($row); 39 } 40 30 41 function dati_consultazione($id) 31 42 { … … 62 73 } 63 74 64 function elenco_autorizzati() #elenco dei comuni autorizzati per la consultazione attiva65 {66 global $id_cons_gen,$prefix,$dbi;67 if(!$id) $id=$id_cons_gen;68 $sql="select * from ".$prefix."_ele_cons_comune where id_cons_gen=$id_cons_gen";69 $sth = $dbi->prepare("$sql");70 $sth->execute();71 $row = $sth->fetchAll(PDO::FETCH_ASSOC);72 return($row);73 }74 75 75 function elenco_cons() 76 76 { 77 77 global $id_cons_gen,$id_comune,$prefix,$dbi; 78 $sql="select * from ".$prefix."_ele_consultazioneorder by data_inizio desc";78 $sql="select t1.*,t2.chiusa,t2.id_conf,t2.preferita,t2.preferenze,t2.id_fascia,t2.vismf,t2.solo_gruppo,t2.disgiunto,t2.proiezione from ".$prefix."_ele_consultazione as t1 left join ".$prefix."_ele_cons_comune as t2 on t1.id_cons_gen=t2.id_cons_gen order by data_inizio desc"; 79 79 $sth = $dbi->prepare("$sql"); 80 80 $sth->execute(); … … 87 87 global $id_cons_gen,$id_comune,$prefix,$dbi; 88 88 $sql="select * from ".$prefix."_ele_comune order by descrizione"; #id_comune,descrizione 89 $sth = $dbi->prepare("$sql"); 90 $sth->execute(); 91 $row = $sth->fetchAll(PDO::FETCH_ASSOC); 92 return($row); 93 } 94 95 function elenco_leggi() 96 { 97 global $id_cons,$id_comune,$prefix,$dbi; 98 $sql="select id_conf,descrizione from ".$prefix."_ele_conf order by id_conf"; 89 99 $sth = $dbi->prepare("$sql"); 90 100 $sth->execute(); -
admin/includes/sidebar.php
r2e3acf5 r65575a8 57 57 <li class="nav-item"><a href="modules.php?op=4" class="nav-link <?php echo ($op == 4) ? 'active' : ''; ?>"><i class="nav-icon fas fa-palette text-warning"></i><p>Tema colore</p></a></li> 58 58 <!-- <li class="nav-item"><a href="modules.php?op=200" class="nav-link <?php echo ($op == 5) ? 'active' : ''; ?>"><i class="nav-icon fas fa-chart-pie text-primary"></i><p>Config. D'Hondt</p></a></li>--> 59 < li class="nav-item"><a href="modules.php?op=6" class="nav-link <?php echo ($op == 6) ? 'active' : ''; ?>"><i class="nav-icon fas fa-city text-secondary"></i><p>Anagrafica Enti/Comuni</p></a></li>59 <!--li class="nav-item"><a href="modules.php?op=6" class="nav-link <?php echo ($op == 6) ? 'active' : ''; ?>"><i class="nav-icon fas fa-city text-secondary"></i><p>Anagrafica Enti/Comuni</p></a></li--> 60 60 <li class="nav-item"><a href="modules.php?op=7" class="nav-link <?php echo ($op == 7) ? 'active' : ''; ?>"><i class="nav-icon fas fa-sync-alt text-warning"></i><p>Aggiornamento Rev</p></a></li> 61 61 </ul> … … 75 75 <ul class="nav nav-treeview"> 76 76 <li class="nav-item"><a href="modules.php?op=8" class="nav-link <?php echo ($op == 8) ? 'active' : ''; ?>"><i class="nav-icon fas fa-user-shield text-secondary"></i><p>Gestione Utenti</p></a></li> 77 <li class="nav-item"><a href="modules.php?op=36" class="nav-link <?php echo ($op == 36) ? 'active' : ''; ?>"><i class="nav-icon fas fa-key text-danger"></i><p>P residenti</p></a></li>77 <li class="nav-item"><a href="modules.php?op=36" class="nav-link <?php echo ($op == 36) ? 'active' : ''; ?>"><i class="nav-icon fas fa-key text-danger"></i><p>Permessi</p></a></li> 78 78 </ul> 79 79 </li> … … 134 134 </a> 135 135 </li> 136 < li class="nav-item">136 <!--li class="nav-item"> 137 137 <a href="modules.php?op=22" class="nav-link <?php echo ($op == 22) ? 'active' : ''; ?>"> 138 138 <i class="nav-icon fas fa-check-circle text-success"></i> 139 139 <p>Autorizza Comune</p> 140 140 </a> 141 </li >141 </li--> 142 142 143 143 <li class="nav-item"> -
admin/modules/aggiorna_rev.php
r2e3acf5 r65575a8 23 23 // Leggi parametri POST con fallback a 0 24 24 $data_rev = isset($_POST['data_rev']) ? $_POST['data_rev'] : ''; 25 $rev_locale = isset($_POST['rev_locale']) ? (int)$_POST['rev_locale'] : 0; 26 $rev_online = isset($_POST['rev_online']) ? (int)$_POST['rev_online'] : 0; 27 $rev_successivo = $rev_locale + 1; 25 $rev_locale = isset($_POST['rev_locale']) ? (int)$_POST['rev_locale'] : 0; # caricare da db 26 if ($stream = fopen('http://mail.eleonline.it/version/risposta.php', 'r')) { 27 $rev= stream_get_contents($stream, 7); 28 fclose($stream); 29 $rev_online=substr($rev,0,7); 30 $_SESSION['remoterev']=$rev_online; 31 }else{ 32 $errmex=2; 33 Header("Location: admin.php?op=aggiorna&id_cons_gen=$id_cons_gen&errmex=$errmex"); exit; 34 } 28 35 29 36 $backup_sql_confermato = isset($_POST['backup_sql']) ? (int)$_POST['backup_sql'] : -1; … … 67 74 } 68 75 69 $url = "https://trac.eleonline.it/eleonline4/changeset?format=zip&new= {$rev_online}&new_path=%2Ftrunk&old={$rev_successivo}&old_path=%2Ftrunk";76 $url = "https://trac.eleonline.it/eleonline4/changeset?format=zip&new=$rev_online&new_path=%2F&old=$rev_locale&old_path=%2F"; 70 77 71 78 send_output("Scaricamento da: $url"); -
admin/modules/aggiornamento.php
r2e3acf5 r65575a8 1 1 <?php require_once '../includes/check_access.php'; ?> 2 2 <?php 3 require_once '../includes/versione.php';4 3 #require_once '../includes/versione.php'; 4 global $patch; 5 5 // Estrai build corrente 6 preg_match('/rev\s*(\d+)/i', $versione, $match); 7 $build_corrente = isset($match[1]) ? (int)$match[1] : 0; 8 6 #preg_match('/rev\s*(\d+)/i', $versione, $match); 7 $build_corrente = $patch; #isset($match[1]) ? (int)$match[1] : 0; 9 8 // Variabili già pronte dalle notifiche dinamiche 10 9 $build_nuovo = $notifiche[0]['testo'] ?? ''; -
admin/modules/contenuto.php
r2e3acf5 r65575a8 41 41 34 => 'pagina_in_costruzionei.php', 42 42 35 => 'pagina_in_costruzionei.php', 43 36 => 'pagina_in_costruzionei.php', 43 36 => 'pagina_in_costruzionei.php', #permessi.php 44 44 37 => 'pagina_in_costruzionei.php', 45 45 38 => 'pagina_in_costruzionei.php', -
admin/modules/elenco_consultazioni.php
r2e3acf5 r65575a8 8 8 # ciclo ancora da adattare 9 9 foreach($row as $key=>$val){ 10 echo "<tr id=\"riga$key\"><td id=\"data$key\">".$val['data']."</td><td id=\"orario$key\">".$val['orario']."</td><td><button type=\"button\" class=\"btn btn-danger btn-sm\" onclick=\"rimuoviAffluenza($key)\">Elimina</button></td></tr>"; 11 } #die("TEST: --- ".count($row)); 10 if($val['preferita']) $pref=1; else $pref=''; 11 echo "<tr id=\"riga$key\"><td style=\"display:none;\" id=\"link_trasparenza$key\" name=\"link_trasparenza$key\">".$val['link_trasparenza']."</td><td style=\"display:none;\" id=\"id_cons_gen$key\" name=\"id_cons_gen$key\">".$val['id_cons_gen']."</td><td style=\"display:none;\" id=\"tipo_cons$key\" name=\"tipo_cons$key\">".$val['tipo_cons']."</td><td style=\"display:none;\" id=\"chiusa$key\" name=\"chiusa$key\">".$val['chiusa']."</td><td style=\"display:none;\" id=\"id_conf$key\" name=\"id_conf$key\">".$val['id_conf']."</td><td style=\"display:none;\" id=\"preferita$key\" name=\"preferita$key\">".$pref."</td><td style=\"display:none;\" id=\"preferenze$key\" name=\"preferenze$key\">".$val['preferenze']."</td><td style=\"display:none;\" id=\"id_fascia$key\" name=\"id_fascia$key\">".$val['id_fascia']."</td><td style=\"display:none;\" id=\"vismf$key\" name=\"vismf$key\">".$val['vismf']."</td><td style=\"display:none;\" id=\"solo_gruppo$key\" name=\"solo_gruppo$key\">".$val['solo_gruppo']."</td><td style=\"display:none;\" id=\"disgiunto$key\" name=\"disgiunto$key\">".$val['disgiunto']."</td><td style=\"display:none;\" id=\"proiezione$key\" name=\"proiezione$key\">".$val['proiezione']."</td><td>"; 12 if($val['preferita']) echo "*"; 13 echo "</td><td id=\"descrizione$key\">".$val['descrizione']."</td><td id=\"data_inizio$key\">".$val['data_inizio']."</td><td id=\"data_fine$key\">".$val['data_fine']."</td><td><button type=\"button\" class=\"btn btn-sm btn-warning me-1\" onclick=\"editConsultazione($key)\">Modifica</button><button type=\"button\" class=\"btn btn-danger btn-sm\" onclick=\"rimuoviConsultazione($key)\">Elimina</button></td></tr>"; 14 } 12 15 13 16 ?> -
admin/modules/gestione_affluenza.php
r2e3acf5 r65575a8 136 136 } 137 137 </script> 138 139 <?php140 // GESTIONE POST JSON (commentata)141 /*142 if ($_SERVER['REQUEST_METHOD'] === 'POST') {143 header('Content-Type: application/json');144 $input = json_decode(file_get_contents('php://input'), true);145 if (!$input || !isset($input['action'])) {146 echo json_encode(['success' => false, 'error' => 'Dati non validi']);147 exit;148 }149 150 $data = $input['data'] ?? '';151 $ora = $input['ora'] ?? '';152 $minuto = $input['minuto'] ?? '';153 154 if ($input['action'] === 'insert') {155 $stmt = $conn->prepare("INSERT INTO affluenze (data, ora, minuto) VALUES (?, ?, ?)");156 $stmt->bind_param("sss", $data, $ora, $minuto);157 echo $stmt->execute()158 ? json_encode(['success' => true])159 : json_encode(['success' => false, 'error' => $stmt->error]);160 }161 162 if ($input['action'] === 'delete') {163 $stmt = $conn->prepare("DELETE FROM affluenze WHERE data=? AND ora=? AND minuto=?");164 $stmt->bind_param("sss", $data, $ora, $minuto);165 echo $stmt->execute()166 ? json_encode(['success' => true])167 : json_encode(['success' => false, 'error' => $stmt->error]);168 }169 170 exit;171 }172 */173 ?> -
admin/modules/gestione_consultazioni.php
r2e3acf5 r65575a8 2 2 require_once '../includes/check_access.php'; 3 3 4 // --- DA ATTIVARE QUANDO HAI IL DB PRONTO ---5 6 /*7 $conn = new mysqli('host', 'username', 'password', 'database');8 if ($conn->connect_error) {9 die("Connessione fallita: " . $conn->connect_error);10 }11 12 // Carica consultazioni da DB, ordinate da ultima a prima (data_inizio DESC)13 $sql = "SELECT id, tipo, denominazione, data_inizio, data_fine, link, predefinita FROM consultazioni ORDER BY data_inizio DESC";14 $result = $conn->query($sql);15 16 $consultazioni = [];17 if ($result && $result->num_rows > 0) {18 while ($row = $result->fetch_assoc()) {19 $row['predefinita'] = (bool)$row['predefinita'];20 $consultazioni[] = $row;21 }22 } else {23 $consultazioni = [];24 }25 26 $conn->close();27 */28 29 // --- Dati di esempio in mancanza di DB (puoi rimuoverli quando usi DB) ---30 $consultazioni = [31 ['id'=>1, 'tipo'=>'CAMERA', 'denominazione'=>'Elezioni Politiche 2022', 'data_inizio'=>'2022-09-25', 'data_fine'=>'2022-09-26', 'link'=>'https://dait.interno.gov.it/elezioni', 'predefinita'=>true],32 ['id'=>2, 'tipo'=>'COMUNALI', 'denominazione'=>'Comunali 2023 - Roma', 'data_inizio'=>'2023-06-15', 'data_fine'=>'2023-06-16', 'link'=>'https://dait.interno.gov.it/elezioni/trasparenza', 'predefinita'=>false],33 ];34 4 ?> 35 5 … … 44 14 </div> 45 15 <div class="card-body"> 46 <form id="consultazioneForm" >47 <input type="hidden" name=" consultazione_id" id="consultazione_id">16 <form id="consultazioneForm" onsubmit="aggiungiConsultazione(event)"> 17 <input type="hidden" name="id_cons_gen" id="id_cons_gen"> 48 18 49 19 <div class="form-row"> 50 20 <div class="form-group col-md-3"> 51 21 <label for="tipo">Tipo*</label> 52 <select class="form-control" id="tipo" name="tipo" required>22 <select class="form-control" id="tipo" name="tipo" onchange="selezionaInput()" required> 53 23 <option value="">Seleziona...</option> 54 <option value=" PROVINCIALI">PROVINCIALI</option>55 <option value=" REFERENDUM">REFERENDUM</option>56 <option value=" COMUNALI">COMUNALI</option>57 <option value=" CIRCOSCRIZIONALI">CIRCOSCRIZIONALI</option>58 <option value=" BALLOTTAGGIO COMUNALI">BALLOTTAGGIO COMUNALI</option>59 <option value=" CAMERA">CAMERA</option>60 <option value=" SENATO">SENATO</option>61 <option value=" EUROPEE">EUROPEE</option>62 <option value=" REGIONALI">REGIONALI</option>63 <option value=" SENATO CON GRUPPI">SENATO CON GRUPPI</option>64 <option value=" CAMERA CON GRUPPI">CAMERA CON GRUPPI</option>65 <option value=" PROVINCIALI CON COLLEGI">PROVINCIALI CON COLLEGI</option>66 <option value=" BALLOTTAGGIO PROVINCIALI">BALLOTTAGGIO PROVINCIALI</option>67 <option value=" EUROPEE CON COLLEGI">EUROPEE CON COLLEGI</option>68 <option value=" CAMERA CON GRUPPI E COLLEGI">CAMERA CON GRUPPI E COLLEGI</option>69 <option value=" SENATO CON GRUPPI E COLLEGI">SENATO CON GRUPPI E COLLEGI</option>70 <option value=" REGIONALI CON COLLEGI">REGIONALI CON COLLEGI</option>71 <option value=" CAMERA - Rosatellum 2.0">CAMERA - Rosatellum 2.0</option>72 <option value=" SENATO - Rosatellum 2.0">SENATO - Rosatellum 2.0</option>24 <option value="1">PROVINCIALI</option> 25 <option value="2">REFERENDUM</option> 26 <option value="3">COMUNALI</option> 27 <option value="4">CIRCOSCRIZIONALI</option> 28 <option value="5">BALLOTTAGGIO COMUNALI</option> 29 <option value="6">CAMERA</option> 30 <option value="7">SENATO</option> 31 <option value="8">EUROPEE</option> 32 <option value="9">REGIONALI</option> 33 <option value="10">SENATO CON GRUPPI</option> 34 <option value="11">CAMERA CON GRUPPI</option> 35 <option value="12">PROVINCIALI CON COLLEGI</option> 36 <option value="13">BALLOTTAGGIO PROVINCIALI</option> 37 <option value="14">EUROPEE CON COLLEGI</option> 38 <option value="15">CAMERA CON GRUPPI E COLLEGI</option> 39 <option value="16">SENATO CON GRUPPI E COLLEGI</option> 40 <option value="17">REGIONALI CON COLLEGI</option> 41 <option value="18">CAMERA - Rosatellum 2.0</option> 42 <option value="19">SENATO - Rosatellum 2.0</option> 73 43 </select> 74 44 </div> … … 87 57 </div> 88 58 89 <div class="form-group" >59 <div class="form-group" id="divlink"> 90 60 <label for="link">Link DAIT Trasparenza</label> 91 61 <input type="url" class="form-control" id="link" name="link"> 62 </div> 63 <div class="form-row"> 64 <div class="form-group col-md-1" id="divpreferenze"> 65 <label for="preferenze">Preferenze</label> 66 <input type="input" class="form-control" id="preferenze" name="preferenze"> 67 </div> 68 <?php $row=elenco_leggi(); ?> 69 <div class="form-group col-md-2" id="divlegge"> 70 <label for="id_conf">Legge elettorale</label> 71 <select class="form-control" id="id_conf" name="id_conf"> 72 <?php $i=0; foreach($row as $val) { ?> 73 <option value="<?= $val['id_conf'] ?>" <?php if(!$i++) echo "selected"; ?>><?= $val['descrizione'] ?></option> 74 <?php } ?> 75 </select> 76 </div> 77 <div class="form-group col-md-2" id="divstato"> 78 <label for="chiusa">Stato</label> 79 <select class="form-control" id="chiusa" name="chiusa"> 80 <option value="0">Attiva</option> 81 <option value="1">Chiusa</option> 82 <option value="2">Nulla</option> 83 </select> 84 </div> 85 <div class="form-group col-md-2" id="divfascia"> 86 <label for="id_fascia">Abitanti</label> 87 <select class="form-control" id="id_fascia" name="id_fascia"> 88 <option value="1">0 - 3.000</option> 89 <option value="2">3.001 - 10.000</option> 90 <option value="3">10.001 - 15.000</option> 91 <option value="4">15.001 - 30.000</option> 92 <option value="5">30.001 - 100.000</option> 93 <option value="6">100.001 - 250.000</option> 94 <option value="7">250.001 - 500.000</option> 95 <option value="8">500.001 - 1.000.000</option> 96 <option value="9">Oltre 1.000.000</option> 97 </select> 98 </div> 99 </div> 100 <div class="form-row"> 101 <div class="form-group col-md-2" id="divdisgiunto"> 102 <label for="disgiunto">Voto disgiunto</label> 103 <select class="form-control" id="disgiunto" name="disgiunto"> 104 <option value="0">No</option> 105 <option value="1">Si</option> 106 </select> 107 </div> 108 <div class="form-group col-md-2" id="divsologruppo"> 109 <label for="solo_gruppo">Ai soli gruppi</label> 110 <select class="form-control" id="solo_gruppo" name="solo_gruppo"> 111 <option value="0">No</option> 112 <option value="1">Si</option> 113 </select> 114 </div> 115 <div class="form-group col-md-2" id="divvismf"> 116 <label for="vismf">Affluenze per genere</label> 117 <select class="form-control" id="vismf" name="vismf"> 118 <option value="0">No</option> 119 <option value="1">Si</option> 120 </select> 121 </div> 122 <div class="form-group col-md-2" id="divproiezione"> 123 <label for="disgiunto">Proiezione consiglio</label> 124 <select class="form-control" id="proiezione" name="proiezione"> 125 <option value="0">No</option> 126 <option value="1">Si</option> 127 </select> 128 </div> 92 129 </div> 93 130 94 131 <div class="form-group form-check"> 95 <input type="checkbox" class="form-check-input" id="predefinita" name="predefinita"> 96 <label class="form-check-label" for="predefinita">Consultazione predefinita</label> 132 <input type="checkbox" class="form-check-input" id="preferita" name="preferita"> 133 <label class="form-check-label" for="preferita">Consultazione predefinita</label> 134 97 135 </div> 98 136 99 <button type="submit" class="btn btn-success" >Aggiungi Consultazione</button>137 <button type="submit" class="btn btn-success" id="submitBtn">Aggiungi Consultazione</button> 100 138 <button type="reset" class="btn btn-secondary" id="cancelEdit">Annulla</button> 101 139 </form> … … 113 151 <tr> 114 152 <th style="width:30px;"></th> <!-- colonna stella senza titolo --> 115 <th>Tipo</th>116 153 <th>Denominazione</th> 117 154 <th>Data Inizio</th> 118 155 <th>Data Fine</th> 119 <th>Link DAIT</th>120 156 <th>Azioni</th> 121 157 </tr> 122 158 </thead> 123 <tbody id=" consultazioniRows"></tbody>159 <tbody id="risultato"><?php include('elenco_consultazioni.php'); ?> </tbody> 124 160 </table> 125 161 </div> … … 129 165 130 166 <script> 131 let consultazioni = <?php echo json_encode($consultazioni); ?>; 132 133 const form = document.getElementById('consultazioneForm'); 134 const rows = document.getElementById('consultazioniRows'); 135 const formTitle = document.getElementById('form-title'); 136 const submitBtn = form.querySelector('button[type="submit"]'); 137 138 // Ordina consultazioni da più recente a meno recente (data_inizio DESC) 139 function ordinaConsultazioni() { 140 consultazioni.sort((a,b) => { 141 // Confronto stringhe ISO date 'YYYY-MM-DD' direttamente valido 142 if (a.data_inizio > b.data_inizio) return -1; 143 if (a.data_inizio < b.data_inizio) return 1; 144 return 0; 145 }); 146 } 147 148 // Render lista consultazioni in tabella 149 function renderConsultazioni() { 150 ordinaConsultazioni(); 151 rows.innerHTML = ''; 152 consultazioni.forEach(c => { 153 const tr = document.createElement('tr'); 154 tr.innerHTML = ` 155 <td style="text-align:center; cursor:pointer;" onclick="impostaPredefinita(${c.id})"> 156 ${c.predefinita ? '⭐' : ''} 157 </td> 158 <td>${c.tipo}</td> 159 <td>${c.denominazione}</td> 160 <td>${c.data_inizio}</td> 161 <td>${c.data_fine}</td> 162 <td>${c.link ? `<a href="${c.link}" target="_blank">Vai</a>` : ''}</td> 163 <td> 164 <button class="btn btn-sm btn-warning" onclick="editConsultazione(${c.id})">Modifica</button> 165 <button class="btn btn-sm btn-danger" onclick="deleteConsultazione(${c.id})">Elimina</button> 166 </td> 167 `; 168 rows.appendChild(tr); 169 }); 170 } 171 172 // Reset form in modalità aggiunta 173 function resetForm() { 174 form.reset(); 175 document.getElementById('consultazione_id').value = ''; 176 formTitle.innerText = 'Aggiungi Consultazione'; 177 submitBtn.innerText = 'Aggiungi Consultazione'; 178 } 179 180 // Funzione modifica consultazione 181 function editConsultazione(id) { 182 const c = consultazioni.find(x => x.id === id); 183 if (!c) return; 184 document.getElementById('consultazione_id').value = c.id; 185 document.getElementById('tipo').value = c.tipo; 186 document.getElementById('denominazione').value = c.denominazione; 187 document.getElementById('data_inizio').value = c.data_inizio; 188 document.getElementById('data_fine').value = c.data_fine; 189 document.getElementById('link').value = c.link; 190 document.getElementById('predefinita').checked = c.predefinita; 191 192 formTitle.innerText = 'Modifica Consultazione'; 193 submitBtn.innerText = 'Modifica Consultazione'; 194 // SCROLL verso il titolo del form (con un piccolo offset se vuoi) 195 document.getElementById('form-title').scrollIntoView({ behavior: 'smooth', block: 'start' }); 196 } 197 198 // Imposta consultazione predefinita (una sola alla volta) 199 function impostaPredefinita(id) { 200 consultazioni.forEach(c => c.predefinita = (c.id === id)); 201 renderConsultazioni(); 202 const currentId = parseInt(document.getElementById('consultazione_id').value); 203 if (currentId === id) { 204 document.getElementById('predefinita').checked = true; 167 function aggiungiConsultazione(e) { 168 e.preventDefault(); 169 170 const denominazione = document.getElementById ( "denominazione" ).value 171 const dataInizio = document.getElementById ( "data_inizio" ).value 172 const dataFine = document.getElementById ( "data_fine" ).value 173 const linkDait = document.getElementById ( "link" ).value 174 const tipo = document.getElementById ( "tipo" ).value 175 const preferita = document.getElementById ( "preferita" ).value 176 const id_cons_gen = document.getElementById ( "id_cons_gen" ).value 177 const chiusa = document.getElementById ( "chiusa" ).value 178 const id_conf = document.getElementById ( "id_conf" ).value 179 const preferenze = document.getElementById ( "preferenze" ).value 180 const id_fascia = document.getElementById ( "id_fascia" ).value 181 const vismf = document.getElementById ( "vismf" ).value 182 const solo_gruppo = document.getElementById ( "solo_gruppo" ).value 183 const disgiunto = document.getElementById ( "disgiunto" ).value 184 const proiezione = document.getElementById ( "proiezione" ).value 185 186 // Crea un oggetto FormData e aggiungi il file 187 const formData = new FormData(); 188 formData.append('funzione', 'salvaConsultazione'); 189 formData.append('id_cons_gen', id_cons_gen); 190 formData.append('descrizione', denominazione); 191 formData.append('data_inizio', dataInizio); 192 formData.append('data_fine', dataFine); 193 formData.append('link_dait', linkDait); 194 formData.append('tipo', tipo); 195 formData.append('preferita', preferita); 196 formData.append('chiusa', chiusa); 197 formData.append('id_conf', id_conf); 198 formData.append('preferenze', preferenze); 199 formData.append('id_fascia', id_fascia); 200 formData.append('vismf', vismf); 201 formData.append('solo_gruppo', solo_gruppo); 202 formData.append('disgiunto', disgiunto); 203 formData.append('proiezione', proiezione); 204 formData.append('op', 'salva'); 205 206 // Invia la richiesta AJAX usando Fetch 207 fetch('../principale.php', { 208 method: 'POST', 209 body: formData // FormData viene gestito automaticamente da Fetch per l'upload 210 }) 211 .then(response => response.text()) // O .json() se il server risponde con JSON 212 .then(data => { 213 const myForm = document.getElementById('consultazioneForm'); 214 risultato.innerHTML = data; // Mostra la risposta del server 215 myForm.reset(); 216 document.getElementById ( "submitBtn" ).textContent = "Aggiungi Consultazione" 217 218 }) 219 .catch(error => { 220 console.error('Errore durante l\'upload:', error); 221 risultato.innerHTML = 'Si è verificato un errore durante l\'upload.'; 222 }); 223 }; 224 225 226 function deleteConsultazione(index) { 227 var id_cons_gen = document.getElementById ( "id_cons_gen"+index ).innerText 228 var xmlhttp = new XMLHttpRequest(); 229 xmlhttp.onreadystatechange = function() { 230 if (this.readyState == 4 && this.status == 200) { 231 document.getElementById("risultato").innerHTML = this.responseText; 232 } 233 } 234 xmlhttp.open("GET","../principale.php?funzione=salvaConsultazione&id_cons_gen="+id_cons_gen+"&op=cancella",true); 235 xmlhttp.send(); 236 237 // document.getElementById("riga"+index).style.display = 'none' 205 238 } 206 } 207 208 // Cancella consultazione con conferma e controllo predefinita 209 function deleteConsultazione(id) { 210 const c = consultazioni.find(x => x.id === id); 211 if (!c) return; 212 213 let msg = `Eliminare la consultazione "${c.denominazione}"?`; 214 if (c.predefinita) { 215 // Trova la nuova consultazione predefinita (più recente dopo eliminazione) 216 const altre = consultazioni.filter(x => x.id !== id); 217 ordinaConsultazioni(altre); 218 const nuovaPredefinita = altre.length > 0 ? altre[0].denominazione : null; 219 220 msg = `ATTENZIONE! Stai eliminando la consultazione predefinita "${c.denominazione}".\n` + 221 `La consultazione predefinita sarà spostata automaticamente alla consultazione "${nuovaPredefinita}".\n\n` + 222 `Procedere comunque?`; 239 function editConsultazione(index) { 240 document.getElementById ( "id_cons_gen" ).value = document.getElementById ( "id_cons_gen"+index ).innerText 241 document.getElementById ( "denominazione" ).value = document.getElementById ( "descrizione"+index ).innerText 242 document.getElementById ( "data_inizio" ).value = document.getElementById ( "data_inizio"+index ).innerText 243 document.getElementById ( "data_fine" ).value = document.getElementById ( "data_fine"+index ).innerText 244 document.getElementById ( "tipo" ).selectedIndex = document.getElementById ( "tipo_cons"+index ).innerText 245 document.getElementById ( "link" ).value = document.getElementById ( "link_trasparenza"+index ).innerText 246 document.getElementById ( "chiusa" ).selectedIndex = document.getElementById ( "chiusa"+index ).innerText 247 document.getElementById ( "id_conf" ).selectedIndex = document.getElementById ( "id_conf"+index ).innerText - 1 248 if(document.getElementById ( "preferita"+index ).innerText==1) 249 document.getElementById ( "preferita" ).checked = true 250 else 251 document.getElementById ( "preferita" ).checked = false 252 document.getElementById ( "preferenze" ).value = document.getElementById ( "preferenze"+index ).innerText 253 document.getElementById ( "id_fascia" ).selectedIndex = document.getElementById ( "id_fascia"+index ).innerText -1 254 document.getElementById ( "vismf" ).selectedIndex = document.getElementById ( "vismf"+index ).innerText 255 document.getElementById ( "solo_gruppo" ).selectedIndex = document.getElementById ( "solo_gruppo"+index ).innerText 256 document.getElementById ( "disgiunto" ).selectedIndex = document.getElementById ( "disgiunto"+index ).innerText 257 document.getElementById ( "proiezione" ).selectedIndex = document.getElementById ( "proiezione"+index ).innerText 258 259 document.getElementById ( "submitBtn" ).textContent = "Salva modifiche" 260 // document.getElementById("riga"+index).style.display = 'none' 261 selezionaInput() 223 262 } 224 if (!confirm(msg)) return;225 226 // Rimuove consultazione227 consultazioni = consultazioni.filter(x => x.id !== id);228 229 // Se eliminata consultazione predefinita, sposta flag all'ultima consultazione (più recente)230 if (c.predefinita && consultazioni.length > 0) {231 ordinaConsultazioni();232 consultazioni[0].predefinita = true;233 }234 235 resetForm();236 renderConsultazioni();237 }238 239 // Ordina consultazioni per data di inizio discendente (più recente prima)240 function ordinaConsultazioni(lista = consultazioni) {241 lista.sort((a, b) => new Date(b.data_inizio) - new Date(a.data_inizio));242 }243 244 245 form.addEventListener('submit', function(e) {246 e.preventDefault();247 248 const id = document.getElementById('consultazione_id').value;249 const tipo = document.getElementById('tipo').value.trim();250 const denominazione = document.getElementById('denominazione').value.trim();251 const data_inizio = document.getElementById('data_inizio').value;252 const data_fine = document.getElementById('data_fine').value;253 const link = document.getElementById('link').value.trim();254 const predefinita = document.getElementById('predefinita').checked;255 256 if (!tipo || !denominazione || !data_inizio || !data_fine) {257 alert('Compilare tutti i campi obbligatori (*)');258 return;259 }260 261 if (id) {262 // Modifica263 const cIndex = consultazioni.findIndex(x => x.id == id);264 if (cIndex === -1) {265 alert('Consultazione non trovata');266 return;267 }268 consultazioni[cIndex] = { id: Number(id), tipo, denominazione, data_inizio, data_fine, link, predefinita };269 } else {270 // Aggiungi nuovo: genera id incrementale271 const maxId = consultazioni.reduce((max, c) => c.id > max ? c.id : max, 0);272 consultazioni.push({ id: maxId + 1, tipo, denominazione, data_inizio, data_fine, link, predefinita });273 }274 275 // Se predefinita selezionata, togli dalle altre276 if (predefinita) {277 const currentId = id ? Number(id) : consultazioni[consultazioni.length - 1].id;278 consultazioni.forEach(c => {279 if (c.id !== currentId) c.predefinita = false;280 });281 } else {282 // Se nessuna è predefinita (caso possibile dopo modifica), imposta la prima (più recente)283 if (!consultazioni.some(c => c.predefinita) && consultazioni.length > 0) {284 ordinaConsultazioni();285 consultazioni[0].predefinita = true;286 }287 }288 289 resetForm();290 renderConsultazioni();291 });292 const predefCheck = document.getElementById('predefinita');293 294 predefCheck.addEventListener('change', function() {295 const isChecked = this.checked;296 const id = document.getElementById('consultazione_id').value;297 263 298 if (isChecked) { 299 // Se sto selezionando come predefinita 300 if (id) { 301 alert('Stai impostando questa consultazione come predefinita. Verrà tolta la predefinita a un\'altra consultazione.'); 302 } else { 303 alert('Stai aggiungendo una nuova consultazione predefinita. Verrà tolta la predefinita a un\'altra consultazione.'); 304 } 305 } else { 306 // Se sto togliendo la predefinita 307 if (id) { 308 alert('Stai togliendo la predefinita da questa consultazione. Il sistema imposterà un\'altra consultazione come predefinita automaticamente.'); 309 } else { 310 alert('Hai tolto la spunta di consultazione predefinita.'); 311 } 312 } 313 }); 314 function impostaPredefinita(id) { 315 const consultazione = consultazioni.find(c => c.id === id); 316 if (!consultazione) return; 317 318 if (consultazione.predefinita) { 319 if (!confirm(`Stai rimuovendo la consultazione predefinita "${consultazione.denominazione}". Il sistema ne imposterà automaticamente un'altra.`)) { 320 return; 321 } 322 } else { 323 if (!confirm(`Stai impostando "${consultazione.denominazione}" come consultazione predefinita. Verrà tolta la predefinita a un'altra consultazione.`)) { 324 return; 325 } 326 } 327 328 consultazioni.forEach(c => c.predefinita = (c.id === id)); 329 renderConsultazioni(); 330 331 const currentId = parseInt(document.getElementById('consultazione_id').value); 332 if (currentId === id) { 333 document.getElementById('predefinita').checked = true; 334 } else { 335 document.getElementById('predefinita').checked = false; 336 } 337 } 338 339 document.getElementById('cancelEdit').addEventListener('click', resetForm); 340 341 // Inizializza lista 342 renderConsultazioni(); 264 265 function selezionaInput() { 266 const tipo = document.getElementById ( "tipo" ).value 267 document.getElementById ( "divproiezione" ).style.display = 'none'; 268 switch (tipo) { 269 case "1": 270 case "5": 271 case "6": 272 case "7": 273 case "8": 274 case "12": 275 case "13": 276 case "14": 277 278 document.getElementById ( "divpreferenze" ).style.display = 'block'; 279 document.getElementById ( "divlink" ).style.display = 'block'; 280 document.getElementById ( "divsologruppo" ).style.display = 'none'; 281 document.getElementById ( "divdisgiunto" ).style.display = 'none'; 282 document.getElementById ( "divfascia" ).style.display = 'none'; 283 document.getElementById ( "divlegge" ).style.display = 'none'; 284 break 285 case "2": 286 document.getElementById ( "divpreferenze" ).style.display = 'none'; 287 document.getElementById ( "divlink" ).style.display = 'none'; 288 document.getElementById ( "divsologruppo" ).style.display = 'none'; 289 document.getElementById ( "divdisgiunto" ).style.display = 'none'; 290 document.getElementById ( "divfascia" ).style.display = 'none'; 291 document.getElementById ( "divlegge" ).style.display = 'none'; 292 break; 293 case "3": 294 case "4": 295 document.getElementById ( "divproiezione" ).style.display = 'block'; 296 case "9": 297 case "10": 298 case "11": 299 case "15": 300 case "16": 301 case "17": 302 case "18": 303 case "19": 304 document.getElementById ( "divpreferenze" ).style.display = 'block'; 305 document.getElementById ( "divlink" ).style.display = 'block'; 306 document.getElementById ( "divsologruppo" ).style.display = 'block'; 307 document.getElementById ( "divdisgiunto" ).style.display = 'block'; 308 document.getElementById ( "divfascia" ).style.display = 'block'; 309 document.getElementById ( "divlegge" ).style.display = 'block'; 310 break 311 } 312 } 343 313 </script> -
admin/modules/modules.php
r2e3acf5 r65575a8 50 50 $sth = $dbi->prepare("SET NAMES 'utf8'"); 51 51 $sth->execute(); 52 global $id_cons_gen; 52 global $id_cons_gen,$patch; 53 require_once '../includes/query.php'; 54 $row=configurazione(); 55 $versione=$row[0]['versione']; 56 $patch=$row[0]['patch']; 57 if($versione==3) { 58 require_once '../includes/aggiornadbTo4.php'; 59 } 53 60 ob_start(); // attiva output buffering 54 61 include '../includes/header.php'; -
admin/modules/setup_sito.php
r2e3acf5 r65575a8 93 93 94 94 <!-- MULTICOMUNE --> 95 < div class="mb-3">95 <!--div class="mb-3"> 96 96 <label for="multicomune" class="form-label">Gestione multicomune?</label> 97 97 <select class="form-select" name="multicomune" id="multicomune" onchange="toggleComuneDefault()"> … … 99 99 <option value="0" <?= $MULTICOMUNE === '0' ? 'selected' : '' ?>>No</option> 100 100 </select> 101 </div >101 </div--> 102 102 103 103 <!-- COMUNE DI DEFAULT --> 104 < div class="mb-3" id="defaultComuneRow" style="<?= $MULTICOMUNE === '1' ? '' : 'display:none;' ?>">104 <!--div class="mb-3" id="defaultComuneRow" style="<?= $MULTICOMUNE === '1' ? '' : 'display:none;' ?>"> 105 105 <label for="defaultComune" class="form-label">Comune visualizzato per default</label> 106 106 <select class="form-select" name="default_comune" id="defaultComune"> … … 111 111 <?php endforeach; ?> 112 112 </select> 113 </div >113 </div--> 114 114 115 115 <!-- VERIFICA DATI OPERATORE PRESIDENTE --> 116 < div class="mb-3">116 <!--div class="mb-3"> 117 117 <label for="verifica_operatore" class="form-label"> 118 118 Verifica dati operatore presidente … … 124 124 <option value="no" <?= (isset($VERIFICA_OPERATORE) && $VERIFICA_OPERATORE === 'no') ? 'selected' : '' ?>>No</option> 125 125 </select> 126 </div >126 </div--> 127 127 128 128 -
admin/principale.php
r2e3acf5 r65575a8 70 70 if (isset($param['funzione'])) {$funzione=$param['funzione'];} else die("Errore: funzione non definita"); 71 71 require_once 'includes/query.php'; 72 72 if($permessi>32) 73 switch ($funzione) { 74 case 'salvaColoreTema': 75 include("modules/salva_colore_tema.php"); 76 break; 77 case 'salvaAffluenza': 78 include("modules/salva_orario_affluenza.php"); 79 break; 80 case 'salvaConfigSito': 81 include("modules/salva_config_sito.php"); 82 break; 83 case 'salvaConsultazione': 84 include("modules/salva_consultazione.php"); 85 break; 86 } 87 73 88 switch ($funzione) { 74 89 case 'salvaAffluenze': … … 86 101 case 'leggiBarraSezioni': 87 102 include("modules/barra_sezioni.php"); 88 break;89 case 'salvaColoreTema':90 include("modules/salva_colore_tema.php");91 break;92 case 'salvaAffluenza':93 include("modules/salva_orario_affluenza.php");94 break;95 case 'salvaConfigSito':96 include("modules/salva_config_sito.php");97 break;98 case 'salvaComune':99 include("modules/salva_comune.php");100 103 break; 101 104 case 'immagine':
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/eleonline4/chrome/common/trac_banner.png)