Changeset 452
- Timestamp:
- Apr 4, 2025, 3:23:19 PM (8 months ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
admin/modules/Elezioni/aggiornadb.php (modified) (1 diff)
-
admin/versione.php (modified) (1 diff)
-
client/temi/bootstrap/pagine/grafici/affluenza_referendum.php (modified) (3 diffs)
-
client/temi/bootstrap/pagine/referendum_risultati.php (modified) (1 diff)
-
client/temi/bootstrap/query.php (modified) (1 diff)
-
client/temi/bootstrap/top_nav.php (modified) (1 diff)
-
client/versione.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/modules/Elezioni/aggiornadb.php
r431 r452 329 329 { 330 330 $sql="ALTER TABLE `".$prefix."_ele_candidati` ADD `num_lista` INT(2) UNSIGNED NOT NULL AFTER `id_lista`"; 331 $sql2="update `".$prefix."_ele_candidati` as t1 set t1.num_lista=(select t2.num_lista from `".$prefix."_ele_lista` as t2 where t2.id_lista=t1.id_lista) where t1.num_lista=0 and(select t2.num_lista from `".$prefix."_ele_lista` as t2 where t2.id_lista=t1.id_lista) is not null";331 $sql2="update `".$prefix."_ele_candidati` as t1 set t1.num_lista=(select t2.num_lista from `".$prefix."_ele_lista` as t2 where t2.id_lista=t1.id_lista) where (select t2.num_lista from `".$prefix."_ele_lista` as t2 where t2.id_lista=t1.id_lista) is not null"; 332 332 $ret=aggiorna($sql,$dbi,$sql2,$num); 333 333 }else{ 334 $sql="update `".$prefix."_ele_candidati` as t1 set t1.num_lista=(select t2.num_lista from `".$prefix."_ele_lista` as t2 where t2.id_lista=t1.id_lista) where t1.num_lista=0 and(select t2.num_lista from `".$prefix."_ele_lista` as t2 where t2.id_lista=t1.id_lista) is not null";334 $sql="update `".$prefix."_ele_candidati` as t1 set t1.num_lista=(select t2.num_lista from `".$prefix."_ele_lista` as t2 where t2.id_lista=t1.id_lista) where (select t2.num_lista from `".$prefix."_ele_lista` as t2 where t2.id_lista=t1.id_lista) is not null"; 335 335 $ret=aggiorna($sql,$dbi,'',$num); 336 336 } -
trunk/admin/versione.php
r451 r452 1 1 <?php 2 2 3 $versione = "3.0 rev 45 1";3 $versione = "3.0 rev 452"; 4 4 $version_number = $versione; 5 $datarel = "0 2aprile 2025";5 $datarel = "04 aprile 2025"; 6 6 $version = "Eleonline $version_number (<i>Data Release: $datarel</i>)"; 7 7 -
trunk/client/temi/bootstrap/pagine/grafici/affluenza_referendum.php
r450 r452 1 1 <?php 2 2 // Dati dinamici da PHP 3 $quesiti=elenco_gruppi('gruppo'); 4 if(isset($_GET['num_gruppo'])) $num_gruppo=intval($_GET['num_gruppo']); else $num_gruppo=1; 5 foreach($quesiti as $val) if($val['num_gruppo']==$num_gruppo) $id_gruppo=$val['id_gruppo']; 6 $row=totale_iscritti(0); 7 $tot=$row[0][2]; 8 $row=scrutinio_affluenze($id_gruppo); 9 $scrutinate=$row[0][0]; 10 $sezionitotali=sezioni_totali(); 11 $row=affluenze_referendum($id_gruppo); 12 $labels=array(); 13 $voti=array(); 14 foreach($row as $val) { 15 if(!isset($voti[$val[0].$val[2].$val[3]])) $voti[$val[0].$val[2].$val[3]]=$val[1]; 16 $i=0; 17 foreach($labels as $val2) 18 if($val2[0]==$val[2] and $val2[1]==$val[3]) {$i=1; break;} 19 if(!$i) $labels[]=[$val[2],$val[3]]; 20 } 21 22 foreach($voti as $val) {$voti_percentuali[]=number_format($val/$tot*100,2);} 23 #$voti_percentuali = [10, 24.7, 30, 47.5]; // Dati % attuali n.b. i decimali mettere il punto 24 # $voti = [700, 980, 1200, 2000]; // Voti attuali 25 #$scrutinate =10; 26 #$sezionitotali=15; 3 $quesiti = elenco_gruppi('gruppo'); 4 if (isset($_GET['num_gruppo'])) $num_gruppo = intval($_GET['num_gruppo']); 5 else $num_gruppo = 1; 6 7 foreach ($quesiti as $val) { 8 if ($val['num_gruppo'] == $num_gruppo) $id_gruppo = $val['id_gruppo']; 9 } 10 11 $row = totale_iscritti(0); 12 $tot = $row[0][2]; 13 14 $row = scrutinio_affluenze($id_gruppo); 15 $scrutinate = $row[0][0]; 16 $sezionitotali = sezioni_totali(); 17 18 $row = affluenze_referendum($id_gruppo,0); 19 $labels = array(); 20 $voti = array(); 21 22 foreach ($row as $val) { 23 if (!isset($votest[$val[0] . $val[2] . $val[3]])) {$votest[$val[0] . $val[2] . $val[3]] = $val[1]; $voto[]=$val[1];} 24 $i = 0; 25 foreach ($labels as $val2) 26 if ($val2[0] == $val[2] and $val2[1] == $val[3]) { 27 $i = 1; 28 break; 29 } 30 if (!$i) $labels[] = [$val[2], $val[3]]; 31 } 32 33 foreach ($voto as $key=>$val) { 34 $voti_percentuali[$key] = number_format(100*($val/$tot),2); 35 $voti[]=number_format($val,0,'','.'); 36 } 37 # 38 $rowpre=array(); 39 if(count($rowpre)){ 40 $preidcg=$rowpre[0]['id_cons_gen']; 41 $rowpre=conscomune($preidcg); 42 $preidcons=$rowpre[0][0]; 43 $rowpre=totale_iscritti($preidcons); 44 $totprec=$rowpre[0][2]; 45 $rowpre=affluenze_referendum($id_gruppo,$preidcons); 46 # $labels=array(); 47 $voti_prec_percentuali=array(); echo "<br>TEST:".count($rowpre); 48 $voti_prec=array(); 49 foreach($rowpre as $val) { 50 # $labels[]=[$val[3],$val[4]."$tot"]; 51 $voti_prec_percentuali[]=number_format($val[2]/$totprec*100,2); 52 $voti_prec[]=number_format($val[2],0,'','.'); 53 } 54 }else{ 55 foreach($voti as $val){ 56 $voti_prec_percentuali[]=''; 57 $voti_prec[]=''; 58 } 59 } 60 27 61 ?> 28 62 <!-- Chart.js --> … … 36 70 } 37 71 </style> 38 <div class="container pb-2">39 <label for="defaultSelect">Seleziona Quesito</label>40 <select id="defaultSelect" onchange="location = this.value;">41 <!-- option selected>Selezione Quesito</option -->42 <?php43 44 foreach($quesiti as $key=>$val) {if ($num_gruppo==$val['num_gruppo']) {$id_gruppo=$val['id_gruppo']; $sel='selected'; } else {$sel='';} ?>45 <option <?php echo $sel; ?> value=" <?php echo "modules.php?op=51&id_comune=$id_comune$cirpar&id_cons_gen=$id_cons_gen&num_gruppo=".$val[1];?>">Quesito <?php echo $val['num_gruppo'];?></option>46 <?php }?>47 </select>48 </div>49 72 <div class="container"> 50 73 <div class="row text-center"> … … 72 95 <!-- Script per il grafico --> 73 96 <script> 74 var ctx = document.getElementById('affluenzaChart').getContext('2d'); 75 76 // Passaggio dei dati PHP a JavaScript 77 var labels = <?php echo json_encode($labels); ?>; 78 var voti_percentuali = <?php echo json_encode($voti_percentuali); ?>; 79 var voti = <?php echo json_encode($voti); ?>; 80 81 // Funzione per sostituire i valori nulli o vuoti con 0 82 function handleNullValues(array) { 83 return array.map(value => value === null || value === undefined ? 0 : value); 84 } 85 86 var affluenzaChart = new Chart(ctx, { 87 type: 'bar', 88 data: { 89 labels: labels, 90 datasets: [ 97 var ctx = document.getElementById('affluenzaChart').getContext('2d'); 98 99 // Passaggio dei dati PHP a JavaScript 100 101 102 var labels = <?php echo json_encode($labels); ?>; 103 var voti_percentuali = <?php echo json_encode($voti_percentuali); ?>; 104 var voti = <?php echo json_encode($voti); ?>; 105 var voti_prec_percentuali = <?php echo json_encode($voti_prec_percentuali); ?>; 106 var voti_prec = <?php echo json_encode($voti_prec); ?>; 107 108 // Funzione per sostituire i valori nulli o vuoti con 0 109 function handleNullValues(array) { 110 return array.map(value => value === null || value === undefined ? 0 : value); 111 } 112 113 // Gestire i valori nulli per i dataset 114 voti_prec_percentuali = handleNullValues(voti_prec_percentuali); 115 voti_prec = handleNullValues(voti_prec); 116 117 var affluenzaChart = new Chart(ctx, { 118 type: 'bar', 119 data: { 120 labels: labels, 121 datasets: [ 122 { 123 label: 'Affluenza Attuale', 124 data: voti_percentuali, 125 backgroundColor: 'rgba(240,128,128)', // Rosso brillante 126 borderWidth: 1 127 } <?php if(count($rowpre)) { ?>, 128 { 129 label: 'Affluenza Precedente', 130 data: voti_prec_percentuali, 131 backgroundColor: 'rgba(70,130,180)', // Blu acciaio 132 borderWidth: 1 133 } 134 <?php } ?> 135 ] 136 }, 137 options: { 138 responsive: true, 139 maintainAspectRatio: false, 140 indexAxis: 'y', 141 scales: { 142 x: { 143 beginAtZero: true, 144 max: 100 145 }, 146 y: { 147 ticks: { 148 stepSize: 1 149 }, 150 // Dinamica della larghezza delle barre 151 barThickness: (window.innerWidth <= 768) ? 30 : 50 // Modifica la larghezza della barra per dispositivi mobili 152 } 153 }, 154 plugins: { 155 legend: { 156 display: true 157 }, 158 tooltip: { 159 callbacks: { 160 title: function (tooltipItems) { 161 // Manteniamo le due righe di etichetta in formato leggibile 162 const index = tooltipItems[0].dataIndex; 163 return labels[index].join(' - '); 164 }, 165 label: function (context) { 166 const index = context.dataIndex; 167 const datasetIndex = context.datasetIndex; 168 169 // Selezione del dataset giusto: attuale o precedente 170 const isCurrentDataset = datasetIndex === 0; 171 const percentuale = isCurrentDataset 172 ? voti_percentuali[index] 173 : voti_prec_percentuali[index]; 174 const votiValue = isCurrentDataset 175 ? voti[index] 176 : voti_prec[index]; 177 178 const affluenzaType = isCurrentDataset ? 'Attuale' : 'Precedente'; 179 180 return `${affluenzaType}: ${percentuale}% (${votiValue} voti)`; 181 } 182 } 183 } 184 } 185 }, 186 plugins: [ 91 187 { 92 label: 'Affluenza', 93 data: voti_percentuali, 94 backgroundColor: 'rgba(240,128,128)', 95 borderWidth: 1 188 id: 'insideBarPercentage', 189 afterDatasetDraw: function (chart) { 190 const ctx = chart.ctx; 191 192 chart.data.datasets.forEach((dataset, datasetIndex) => { 193 if (!chart.isDatasetVisible(datasetIndex)) { 194 return; 195 } 196 197 dataset.data.forEach((value, index) => { 198 const meta = chart.getDatasetMeta(datasetIndex).data[index]; 199 200 // Se il valore Ú zero, non disegnare la barra ma non eliminarla completamente 201 if (value === 0) { 202 return; // Non disegnare il testo se il valore Ú zero 203 } 204 205 const votoValue = datasetIndex === 0 206 ? voti[index] || 0 207 : voti_prec[index] || 0; 208 209 // Mostra la percentuale e i voti in modo coerente 210 const text = value + '% (' + votoValue + ' voti)'; 211 212 const x = meta.base + (meta.width + 65); 213 const y = meta.y; 214 215 ctx.save(); 216 ctx.fillStyle = '#000000'; // Scritta nera 217 ctx.font = 'bold 14px Titillium Web, Arial'; 218 ctx.textAlign = 'center'; 219 ctx.textBaseline = 'middle'; 220 ctx.fillText(text, x, y); 221 ctx.restore(); 222 }); 223 }); 224 } 96 225 } 97 226 ] 98 }, 99 options: { 100 responsive: true, 101 maintainAspectRatio: false, 102 indexAxis: 'y', 103 scales: { 104 x: { 105 beginAtZero: true, 106 max: 100 107 }, 108 y: { 109 ticks: { 110 stepSize: 1, 111 font: { 112 family: 'Titillium Web', 113 size: 14, 114 weight: 'bold' 115 } 116 } 117 } 118 }, 119 plugins: { 120 legend: { 121 labels: { 122 font: { 123 family: 'Titillium Web', 124 size: 16, 125 weight: 'bold' 126 } 127 } 128 }, 129 tooltip: { 130 callbacks: { 131 title: function (tooltipItems) { 132 const index = tooltipItems[0].dataIndex; 133 return labels[index].join(' - '); 134 }, 135 label: function (context) { 136 const index = context.dataIndex; 137 return `Affluenza: ${voti_percentuali[index]}% (${voti[index]} voti)`; 138 } 139 } 140 } 141 } 142 } 143 }); 227 }); 144 228 </script> -
trunk/client/temi/bootstrap/pagine/referendum_risultati.php
r431 r452 2 2 $row=dati_consultazione(); 3 3 $tipo=$row[0][4]; 4 $affluenze=affluenze_referendum(0 );4 $affluenze=affluenze_referendum(0,0); 5 5 $sezionitotali=sezioni_totali(); 6 6 $listareferendum=elenco_gruppi('gruppo'); -
trunk/client/temi/bootstrap/query.php
r450 r452 1 1 <?php 2 2 3 function affluenze_referendum($id) 4 { 5 global $id_cons,$prefix,$dbi; 3 function affluenze_referendum($id,$cons) 4 { 5 global $id_cons,$prefix,$dbi; 6 if(!$cons) $cons=$id_cons; 6 7 if($id) $filtro="and t3.id_gruppo='$id'"; else $filtro=''; 7 $sql="select t3.id_gruppo,sum(t3.voti_complessivi),t3.data ,t3.orario from ".$prefix."_ele_voti_parziale as t3 where t3.id_cons=$ id_cons $filtro group by t3.id_gruppo,t3.data ,t3.orario order by t3.data,t3.orario";8 $sql="select t3.id_gruppo,sum(t3.voti_complessivi),t3.data ,t3.orario from ".$prefix."_ele_voti_parziale as t3 where t3.id_cons=$cons $filtro group by t3.id_gruppo,t3.data ,t3.orario order by t3.data,t3.orario"; 8 9 $sth = $dbi->prepare("$sql"); 9 10 $sth->execute(); -
trunk/client/temi/bootstrap/top_nav.php
r449 r452 300 300 <?php }?> 301 301 <?php }else{ ?> 302 <?php $tmp=affluenze_referendum(0 ); if($tmp and $tmp[0][1]>0) $stato=''; else $stato='disabled'; ?>302 <?php $tmp=affluenze_referendum(0,0); if($tmp and $tmp[0][1]>0) $stato=''; else $stato='disabled'; ?> 303 303 <li><a class="dropdown-item <?php echo $stato; ?> list-item left-icon" href="modules.php?op=51&id_comune=<?php echo $id_comune.$cirpar;?>&id_cons_gen=<?php echo $id_cons_gen;?>"> 304 304 <svg class="icon icon-sm icon-primary left"><use href="<?php echo $curdir?>/svg/sprites.svg#it-chart-line"></use></svg><span>Affluenze Referendum</span></a></li> -
trunk/client/versione.php
r451 r452 1 1 <?php 2 $versione = "3.0 rev 45 1";2 $versione = "3.0 rev 452"; 3 3 $version_number = $versione; 4 $datarel = "0 2aprile 2025";4 $datarel = "04 aprile 2025"; 5 5 $version = "Eleonline $version_number (<i>Data Release: $datarel</i>)"; 6 6
Note:
See TracChangeset
for help on using the changeset viewer.
