Changeset 471 for trunk


Ignore:
Timestamp:
Jun 1, 2025, 5:13:02 PM (6 months ago)
Author:
roby
Message:
  • ADMIN

-- Adattata la funzione di import dati da altre installazioni eleonline per gestire anche file scaricati da versioni precedenti

  • CLIENT

-- Rivista la visualizzazione del grafico delle affluenze

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/modules/Elezioni/importa.php

    r466 r471  
    2424{
    2525        global $prefix, $dbi;
    26         global $ar_gruppo,$ar_lista,$ar_candi,$idcns;
     26        global $ar_gruppo,$ar_lista,$ar_candi,$idcns,$dbname;
    2727
    2828        foreach ($ar_gruppo as $rigagruppo){
     
    3131                $isnew=0;
    3232                $numcampi=count($rigagruppo);
     33                $sql="SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '$dbname' AND TABLE_NAME = '".$prefix."_ele_gruppo'";
     34                $resnew = $dbi->prepare("$sql");
     35                $resnew->execute();     
     36                list ($campiloc) = $resnew->fetch(PDO::FETCH_NUM);             
    3337                foreach($rigagruppo as $key=>$campo){
    3438                        if ($key==0) $valori="'$idcns',";
     
    4044                        else $valori.= ",'".$campo."'";
    4145                        if ($key==2) $numgruppo= $campo;
    42                 }
    43                 if($numcampi==10) $valori.=",'','',''";
    44                 if (!$isnew and isset($valori)) $valori.=",null,null";
    45                         if(isset($valori)){
    46                                 $sql="insert into ".$prefix."_ele_gruppo values($valori)";
    47                                 try {
    48                                         $res_gruppo = $dbi->prepare("$sql");
    49                                         $res_gruppo->execute();
    50                                 }
    51                                 catch(PDOException $e)
    52                                 {
    53                                         echo $sql . "<br>" . $e->getMessage();
    54                                 }                 
    55                                 $sql="select id_gruppo from ".$prefix."_ele_gruppo where num_gruppo='$numgruppo' and id_cons='$idcns'";
    56                                 $resnew = $dbi->prepare("$sql");
    57                                 $resnew->execute();     
    58                                 list ($newidg) = $resnew->fetch(PDO::FETCH_NUM);
    59                                 unset($valori);
    60                                 if($oldidg){
    61                                         $_SESSION['gruppi']['idg_'.$oldidg]=$newidg;
    62                                         $_SESSION['gruppi']['numg_'.$numgruppo]=$numgruppo;                                             
    63                                 }
     46                }               
     47                $i=$numcampi;
     48                if($numcampi<$campiloc) while($i<$campiloc) {$valori.=",''";$i++;}
     49                if(isset($valori)){
     50                        $sql="insert into ".$prefix."_ele_gruppo values($valori)";
     51                        try {
     52                                $res_gruppo = $dbi->prepare("$sql");
     53                                $res_gruppo->execute();
     54                        }
     55                        catch(PDOException $e)
     56                        {
     57                                echo $sql . "<br>" . $e->getMessage();
     58                        }                 
     59                        $sql="select id_gruppo from ".$prefix."_ele_gruppo where num_gruppo='$numgruppo' and id_cons='$idcns'";
     60                        $resnew = $dbi->prepare("$sql");
     61                        $resnew->execute();     
     62                        list ($newidg) = $resnew->fetch(PDO::FETCH_NUM);
     63                        unset($valori);
     64                        if($oldidg){
     65                                $_SESSION['gruppi']['idg_'.$oldidg]=$newidg;
     66                                $_SESSION['gruppi']['numg_'.$numgruppo]=$numgruppo;                                             
     67                        }
    6468                }
    6569        }
     
    6872function inslista()
    6973{
    70 global $prefix, $dbi;
     74global $prefix, $dbi,$dbname;
    7175global $ar_lista,$idcns;
    7276
     
    8589                }       
    8690                else $newidg=0;
    87                 $ultimocampo=count($rigalista)-1;
     91                $ultimocampo=count($rigalista);
     92                $sql="SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '$dbname' AND TABLE_NAME = '".$prefix."_ele_lista'";
     93                $resnew = $dbi->prepare("$sql");
     94                $resnew->execute();     
     95                list ($campiloc) = $resnew->fetch(PDO::FETCH_NUM);             
    8896                foreach($rigalista as $key=>$campo){
    8997                        if ($key==0) $valori=$idcns.",";
     
    92100                        elseif ($key==3) {$valori.= "'$newidg',"; if ($campo!=$oldidg) $okl=1;}
    93101                        elseif ($key==4) $valori.= "$numgruppo,";
    94                         elseif ($key==$ultimocampo ) $valori.= "'$campo'";
     102                        elseif ($key==($ultimocampo-1) ) $valori.= "'$campo'";
    95103                        else $valori.="'".$campo."',";
    96104                }
    97                 if($ultimocampo==9) $valori.=",''";
    98                 if($key==$ultimocampo){
     105                $i=$ultimocampo;
     106                if($ultimocampo<$campiloc) while($i<$campiloc) {$valori.=",''";$i++;}
     107#               if($ultimocampo==9) $valori.=",''";
     108#               if($key==$ultimocampo){
    99109                        if ($okl) {$okl=0;continue;}
    100110                        $sql="insert into ".$prefix."_ele_lista values($valori)";
     
    105115                        catch(PDOException $e)
    106116                        {
    107                                 echo $sql . "<br>" . $e->getMessage();
     117                                echo $sql . "<br>" . $e->getMessage(); die();
    108118                        }                 
    109119                               
     
    116126                                $_SESSION['liste']['idl_'.$oldidl]=$newidl;
    117127                        }
    118                 }
     128#               }
    119129        }
    120130}
     
    122132function inscandi()
    123133{
    124         global $prefix, $dbi;
     134        global $prefix, $dbi,$dbname;
    125135        global $ar_candi,$idcns;
     136        $sql="SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '$dbname' AND TABLE_NAME = '".$prefix."_ele_lista'";
     137        $resnew = $dbi->prepare("$sql");
     138        $resnew->execute();     
     139        list ($campiloc) = $resnew->fetch(PDO::FETCH_NUM);             
    126140        foreach ($ar_candi as $rigacandi){
    127141                if(!isset($rigacandi[2])) continue;
     
    137151                }
    138152                if(isset($valori) and $valori!=''){
    139                         for($x=count($rigacandi);$x<12;$x++) $valori.=",''";
     153                        for($x=count($rigacandi);$x<$campiloc;$x++) $valori.=",''";
    140154                        if ($okc) {$okc=0;continue;}
    141155                        $sql="insert into ".$prefix."_ele_candidati values($valori)";
  • trunk/admin/versione.php

    r470 r471  
    11<?php
    22
    3 $versione = "3.0 rev 470";
     3$versione = "3.0 rev 471";
    44$version_number = $versione;
    5 $datarel = "24 maggio 2025";
     5$datarel = "01 giugno 2025";
    66$version = "Eleonline $version_number (<i>Data Release: $datarel</i>)";
    7 
    87?>
  • trunk/client/footer.php

    r431 r471  
    66/* info@eleonline.it  luciano@aniene.net rgigli@libero.it               */
    77/************************************************************************/
    8 if ($tema=='bootstrap') die();
     8if (isset($tema) and $tema=='bootstrap') die();
    99global $csv;
    1010
  • trunk/client/modules.php

    r468 r471  
    119119# protezione csrf ottobre 2012 - by l.apolito
    120120if (file_exists("inc/csrf-magic/csrf-magic.php")) {
    121         include_once 'inc/csrf-magic/csrf-magic.php';
     121#       include_once 'inc/csrf-magic/csrf-magic.php';
    122122}
    123123
     
    262262$PHP_SELF=$_SERVER['PHP_SELF'];
    263263$file=(isset($param['file'])) ? htmlentities($param['file']):"index";
     264if($tema=='spectral' and $file!='foto') $file="index";
    264265$name=(isset($param['name'])) ? htmlentities($param['name']):"Elezioni";
    265266$op=(isset($param['op'])) ? htmlentities($param['op']):"gruppo";
     
    273274$sql->execute();
    274275list($id_cons) = $sql->fetch(PDO::FETCH_NUM);
    275 
     276$percorso=$name;
    276277if(!file_exists("temi/$tema/index.php")) {$tema='default'; $_SESSION['tema']=$tema;}
    277 if($tema=='bootstrap' and !$csv) {
    278         $name='../temi/bootstrap';
    279 }
    280 ###########
    281 
    282 $modpath = "modules/$name/$file.php";
     278if($name=='modelli')
     279        $percorso='../modelli';
     280else {
     281        if($tema=='bootstrap' and !$csv) {
     282                $percorso='../temi/bootstrap';
     283        }
     284        ###########
     285}
     286$modpath = "modules/$percorso/$file.php";
     287
    283288if (file_exists($modpath)) {
    284289        include($modpath);
  • trunk/client/modules/Elezioni/affluenze-inc.php

    r464 r471  
    3131$riga1='';
    3232$testacols=1;
     33$logo='';
     34$immagine='';
    3335#echo "<center>";
    3436if($csv==1){
     
    4143        $descr_com =stripslashes($descr_com);
    4244 #      if($xls!=1) {$datipdf .= "<div style=\"width:40%; margin:0px auto;text-align:center;\">";}
     45        $logo=verificasimbolo();
     46        $immagine= "<img src=\"modules/Elezioni/images/$logo\" alt=\"logo\">";
    4347        $siteistat=$id_comune;
    4448        # salva sull'hardisk lo stemma del comune
    45         $logo=verificasimbolo();
    46         $immagine= "<img src=\"modules/Elezioni/images/$logo\" alt=\"logo\">";
    4749        $html='';
    4850        if($xls!=1)     {
  • trunk/client/modules/Elezioni/consiglieri.php

    r469 r471  
    181181                        echo "<form id=\"gruppo\" action=\"modules.php\">";
    182182                        echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\"><tr class=\"bggray\"><td colspan=\"4\">"._COLLEGAMENTI."</td></tr><tr class=\"bggray\"><td>";
    183                         if($tema='bootstrap')
     183                        if($tema=='bootstrap')
    184184                                echo "<input type=\"hidden\" name=\"op\" value=\"31\"/>";
    185185                        else
     
    211211                echo "<form id=\"numgruppo\" action=\"modules.php\">";
    212212                echo "<table><tr><td>"._SCELTASIN.":</td><td align=\"left\">";
    213                 if($tema='bootstrap')
     213                if($tema=='bootstrap')
    214214                        echo "<input type=\"hidden\" name=\"op\" value=\"31\"/>";
    215215                else
     
    681681
    682682function stampalista($ar) {
    683 global $PNE,$CSEC,$stampa,$stampasind;
     683global $PNE,$CSEC,$stampa,$stampasind,$tema;
    684684$cmin=_SEGGIMIN;       
    685685$csin="";       
     
    751751        $tmpstampa=ob_get_clean();
    752752        $stampa=$stampasind.$tmpstampa;
    753 #       echo $stampa;
     753        if(isset($tema) and $tema!='bootstrap')
     754                echo $stampa;
    754755}
    755756
  • trunk/client/modules/Elezioni/grafici/raffrontivoto.php

    r105 r471  
    44
    55$titvoti=$_GET['titvoti'];
    6 $titperc=$_GET['titperc'];
     6if(isset($_GET['titperc']) $titperc=$_GET['titperc']; else $titperc='';
    77$altro=$_GET['altro'];
    88$desc=$_GET['desc'];
  • trunk/client/modules/Elezioni/language/lang-en.php

    r318 r471  
    181181define("_VOTI_RAGGR","Sum of ballots");
    182182define("_SEDI","Election Site");
    183 define("_LISTA","List");
     183if(!defined("_LISTA")) define("_LISTA","List");
    184184define("_LISTE","Lists");
    185185define("_TEST","If you wont to test Eleonline start inserting username \"suser\" and password \"test\"");
  • trunk/client/temi/bootstrap/pagine/grafici/affluenza.php

    r465 r471  
    2020if(count($rowpre)){
    2121        $preidcg=$rowpre[0]['id_cons_gen'];
     22        $row=dati_consultazione($preidcg);
     23        $descr_cons=$row[0]['descrizione'];
    2224        $rowpre=conscomune($preidcg);
    2325        $preidcons=$rowpre[0][0];
     
    2931        $voti_prec_percentuali=array();
    3032        $voti_prec=array();
     33        if($num_aff!=$num_aff_pre) {$rowpre=array(array_pop($rowpre));$diff=1;$num_aff_pre=1;} else $diff=0;
    3134        foreach($rowpre as $val) {
    3235                while($num_aff>$num_aff_pre) {
    33                         $num_aff_pre++; #die("TESTpiu:$num_aff -- $num_aff_pre");
    3436                        array_unshift($voti_prec_percentuali,0);
    3537                        array_unshift($voti_prec,0);
     38                        $num_aff_pre++;
    3639                }
    3740                if($num_aff<$num_aff_pre) {
    38                         $num_aff_pre--; #die("TESTmeno:$num_aff -- $num_aff_pre");
     41                        $num_aff_pre--;
    3942                        array_shift($voti_prec_percentuali);
    4043                        array_shift($voti_prec);
    4144                        continue;
    4245                }
    43                
    44 #               $labels[]=[$val[3],$val[4]."$tot"];
    45                 $voti_prec_percentuali[]=number_format($val[2]/$totprec*100,2);
    46                 $voti_prec[]=number_format($val[2],0,'','.');
     46                $voti_prec_percentuali[]= $diff ? 0 : number_format($val[2]/$totprec*100,2);
     47                $voti_prec[]= $diff ? 0 : number_format($val[2],0,'','.');
    4748        }
     49                if($diff) {array_shift($voti_prec_percentuali);array_shift($voti_prec);$voti_prec_percentuali[]=number_format($val[2]/$totprec*100,2);$voti_prec[]=number_format($val[2],0,'','.');}
     50
    4851}else{
    4952        foreach($voti as $val){
     
    5356}
    5457
    55 /*
    56 $labels = [
    57     ['01/03/2025', '14:00'],
    58     ['01/03/2025', '16:00'],
    59     ['01/03/2025', '18:00'],
    60     ['01/03/2025', '20:00']
    61 ];
    62 $voti_percentuali = [10, 24.7, 30, 47.5];  // Dati % attuali n.b. i decimali mettere il punto
    63 $voti = [700, 980, 1200, 2000];            // Voti attuali
    64 */
    65 // Affluenza precedente (valore zero o null non mette la barra)
    66 #$voti_prec_percentuali = [null, 15, 20, 35]; // Dati % Precedente
    67 #$voti_prec = [500, 600, 700, 1200];          // Dati dei voti
    6858?>
    6959<!-- Chart.js -->
    7060<script src="temi/bootstrap/pagine/grafici/js/chart.umd.js"></script>
    71 
    72 <!--style>
    73     #chartContainer {
    74         width: 100%;
    75         height: 400px;
    76         margin: 0 auto;
    77     }
    78 </style-->
    7961<style>
    8062    #chartContainer {
     
    8466    }
    8567</style>
     68
    8669<div class="container">
    8770    <div class="row text-center">
     
    140123                } <?php if(count($rowpre)) { ?>,
    141124                {
    142                     label: 'Affluenza Precedente Consultazione',
     125                    label: 'Affluenza Consultazione: <?php echo addslashes($descr_cons); if($diff) echo " (Dato Finale)";?>',
    143126                    data: voti_prec_percentuali,
    144127                    backgroundColor: 'rgba(70,130,180)',  // Blu acciaio
  • trunk/client/temi/bootstrap/pagine/grafici/affluenza_referendum.php

    r468 r471  
    1717
    1818$row = affluenze_referendum($id_gruppo,0);
     19$num_aff=count($row);
    1920$labels = array();
    2021$voti = array();
    2122
    2223foreach ($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    if (!isset($votest[$val[0] . $val[2] . $val[3]])) {
     25                $votest[$val[0] . $val[2] . $val[3]] = $val[1];
     26                $voto[]=$val[1];
     27        }
    2428    $i = 0;
    2529    foreach ($labels as $val2)
     
    3539        $voti[]=number_format($val,0,'','.');
    3640}
    37 #
     41#
     42 
    3843$predescr='';
    3944$rowpre=precedente_consultazione();#array();
     
    4853        $preid_gruppo=$rowpre[0][0];
    4954        $rowpre=affluenze_referendum($preid_gruppo,$preidcons);
     55        $num_aff_pre=count($rowpre);
    5056#       $labels=array();
    5157        $voti_prec_percentuali=array();
    5258        $voti_prec=array();
     59        if($num_aff!=$num_aff_pre) {$rowpre=array(array_pop($rowpre));$diff=1;$num_aff_pre=1;} else $diff=0;
    5360        foreach($rowpre as $val) {
    54 #               $labels[]=[$val[3],$val[4]."$tot"];
     61                while($num_aff>$num_aff_pre) {
     62                        array_unshift($voti_prec_percentuali,0);
     63                        array_unshift($voti_prec,0);
     64                        $num_aff_pre++;
     65                }
     66
    5567                $voti_prec_percentuali[]=number_format($val[1]/$totprec*100,2);
    5668                $voti_prec[]=number_format($val[1],0,'','.');
    5769        }
     70#        while(count($rowpre)<count($voti_prec))
     71#                array_unshift($rowpre,0);
     72
     73#               if($diff) {array_shift($voti_prec_percentuali);array_shift($voti_prec);$voti_prec_percentuali[]=number_format($val[1]/$totprec*100,2);$voti_prec[]=number_format($val[1],0,'','.');}
    5874}else{
    5975        foreach($voti as $val){
     
    6278        }
    6379}
    64 
    6580?>
    6681<!-- Chart.js -->
    6782<script src="temi/bootstrap/pagine/grafici/js/chart.umd.js"></script>
    6883
    69 <style>
    70     #chartContainer {
    71         width: 100%;
    72         height: 400px;
    73         margin: 0 auto;
    74     }
    75 </style>
     84
    7685<!-- Blocco select quesito referendum -->
    7786<div class="container pb-2">
     
    91100        <h4 class="fw-semibold text-primary mobile-expanded mt-2">Affluenza</h4>
    92101    </div>
     102        <?php #$oplink="come"; $infolink="affluenze_sez"; include 'temi/bootstrap/pagine/tab_link_opendata.php'; ?>     
    93103        <div class="table-responsive overflow-x">
    94104        <table class="table  mb-0">
     
    96106                        <tr>
    97107                                <th>Affluenza</th>
    98                                         <?php $oplink="come"; $infolink="affluenze_sez"; include 'temi/bootstrap/pagine/tab_link_opendata.php'; ?>     
    99108                                <?php if ($scrutinate == $sezionitotali) {?>
    100109                                        <th class="text-end">Dati finali</th>
     
    110119    </div>
    111120</div>
    112 
     121<style>
     122    #chartContainer {
     123        width: 100%;
     124        height: <?php echo min(300 + count($labels) * 30, 900); ?>px; /* L'altezza si adatta al numero di liste */
     125        margin: 0 auto;
     126    }
     127</style>
    113128<!-- Script per il grafico -->
    114129<script>
     
    116131
    117132    // Passaggio dei dati PHP a JavaScript
    118 
    119        
    120133    var labels = <?php echo json_encode($labels); ?>;
    121134    var voti_percentuali = <?php echo json_encode($voti_percentuali); ?>;
     
    145158                } <?php if(count($rowpre)) { ?>,
    146159                {
    147                     label: 'Affluenza Precedente ( <?php if(strlen($predescr)>0) echo "$predescr )";?>',
     160                    label: 'Affluenza Precedente ( <?php echo addslashes($predescr); if($diff) echo " (Dato Finale)";?>',
    148161                    data: voti_prec_percentuali,
    149162                    backgroundColor: 'rgba(70,130,180)',  // Blu acciaio
  • trunk/client/temi/bootstrap/query.php

    r468 r471  
    500500        if(isset($circo) and $circo) $filtro="and t1.id_circ='$idcirc'"; else $filtro='';
    501501        if($i==1) $ordine='order by t2.num_circ'; else $ordine='order by t2.descrizione';
    502         $sql="select t1.id_sede,t1.indirizzo,t1.telefono1,t1.telefono2, t1.mappa, t1.filemappa,t2.descrizione,t2.num_circ from ".$prefix."_ele_sede as t1, ".$prefix."_ele_circoscrizione as t2 where t1.id_circ=t2.id_circ and t1.id_cons='$id_cons' $filtro $ordine";
     502        $sql="select t1.id_sede,t1.indirizzo,t1.telefono1,t1.telefono2, t1.mappa, t1.filemappa,t2.descrizione,t2.num_circ,t1.latitudine,t1.longitudine from ".$prefix."_ele_sede as t1, ".$prefix."_ele_circoscrizione as t2 where t1.id_circ=t2.id_circ and t1.id_cons='$id_cons' $filtro $ordine";
    503503        $sth = $dbi->prepare("$sql");
    504504        $sth->execute();
     
    580580{
    581581        global $id_cons_gen,$prefix,$dbi,$tipocons,$datainizio,$id_comune;
    582         $sql="select t1.* from  ".$prefix."_ele_consultazione as t1 left join ".$prefix."_ele_cons_comune as t2 on t2.id_cons_gen=t1.id_cons_gen where t2.id_comune=$id_comune and t2.chiusa<'2' and (t1.tipo_cons=$tipocons) and t1.data_inizio<'$datainizio' order by t1.data_inizio desc limit 0,1";
     582        $tipo=$tipocons;
     583        if($tipocons==6 or $tipocons==11 or $tipocons==15 or $tipocons==18) $tipo="'6' or t1.tipo_cons='11' or t1.tipo_cons='15' or t1.tipo_cons='18'";
     584        if($tipocons==7 or $tipocons==10 or $tipocons==16 or $tipocons==19) $tipo="'7' or t1.tipo_cons='10' or t1.tipo_cons='16' or t1.tipo_cons='19'";
     585       
     586        $sql="select t1.* from  ".$prefix."_ele_consultazione as t1 left join ".$prefix."_ele_cons_comune as t2 on t2.id_cons_gen=t1.id_cons_gen where t2.id_comune=$id_comune and t2.chiusa<'2' and (t1.tipo_cons=$tipo) and t1.data_inizio<'$datainizio' order by t1.data_inizio desc limit 0,1";
    583587        $sth = $dbi->prepare("$sql");
    584588        $sth->execute();
  • trunk/client/versione.php

    r470 r471  
    11<?php
    2 $versione = "3.0 rev 470";
     2$versione = "3.0 rev 471";
    33$version_number = $versione;
    4 $datarel = "24 maggio 2025";
     4$datarel = "01 giugno 2025";
    55$version = "Eleonline $version_number (<i>Data Release: $datarel</i>)";
    6 
    76?>
Note: See TracChangeset for help on using the changeset viewer.