Ignore:
Timestamp:
Sep 24, 2022, 1:11:18 PM (20 months ago)
Author:
roby
Message:

Admin:

  • modificata la funzione aggiornadb per gestire il caso di cambiamento del nome del superutente e tolto il default per tipi campo text
  • modificata la funzione dei controlli per gestire il tipo consultazione Regionali in Sicilia

Install:

  • modificata la funzione di installazione per compatibilità con php 8.0

Client:

  • cambiata l'immagine "vuoto.jpg" nel formato png per gestire la trasparenza
  • modificate le funzioni affluenze e votanti per correggere l'esportazione in pdf e le stampe
  • per il tema Futura2 eliminato il taglio della descrizione della consultazione
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/modules/Elezioni/affluenze.php

    r371 r376  
    44/* by Luciano Apolito & Roberto Gigli                                   */
    55/* http://www.eleonline.it                                              */
    6 /* info@eleonline.it  luciano@aniene.net rgigli@libero.it               */
     6/* info@eleonline.it rgigli@libero.it                                   */
    77/************************************************************************/
    88
     
    1111}
    1212
     13
    1314require_once('inc/hpdf5/autoload.php');
    1415use Spipu\Html2Pdf\Html2Pdf;
     
    1617use Spipu\Html2Pdf\Exception\ExceptionFormatter;
    1718
    18 if (isset($param['id_cons_gen'])) $id_cons_gen=intval($param['id_cons_gen']); else $id_cons_gen='';
    19 if (isset($param['num_ref'])) $num_ref=intval($param['num_ref']);
    20 if (isset($param['num_refs'])) $num_refs=intval($param['num_refs']);
    21 if (isset($param['id_comune'])) $id_comune=intval($param['id_comune']);
    22 if (isset($param['xls'])) $xls=intval($param['xls']);
    23 if (isset($param['pdf'])) $pdf=intval($param['pdf']);
    24 $sql="SELECT t1.tipo_cons,t3.genere,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.tipo_cons=t3.tipo_cons and t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'";
    25 $res = $dbi->prepare("$sql");
    26 $res->execute();
    27 list($tipo_cons,$genere,$id_cons) = $res->fetch(PDO::FETCH_NUM);
    28 global $lang,$circo,$id_circ;
    29 
    30 if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
    31 else $circos='';
    32 
    33 # testata
    34 include_once("modules/Elezioni/language/lang-$lang.php");
    35 if($csv==1){
    36         include_once("modules/Elezioni/funzioni.php");
    37        
    38         $sql="SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
    39         $res = $dbi->prepare("$sql");
    40         $res->execute();
    41         list($descr_com) = $res->fetch(PDO::FETCH_NUM);
    42         $descr_com =stripslashes($descr_com);
    43         $datipdf .= "<div style=\"margin:0px auto; text-align:center;\">";
    44         $siteistat=$id_comune;
    45         # salva sull'hardisk lo stemma del comune
    46         $logo=verificasimbolo();
    47         $immagine= "<img src=\"modules/Elezioni/images/$logo\" alt=\"logo\" align=\"left\"/>";
    48 
    49         if($xls!=1) $datipdf .= "<table><tr><td>$immagine</td><td>";
    50        
    51         $datipdf .= ""._COMUNE." $descr_com <br />
    52         "._RISULTA." "._CONSULTA."<br/ >";
    53         $datipdf .= "$descr_cons<br />"._DISCLAIMER."
    54         <br /><b>"._DETTAGLIO."  "._AFFLUENZE."</b>";
    55         if($xls!=1) $datipdf .=  "</td></tr></table>";
    56         $datipdf .="</div>";
    57 
    58         $html = "<style type=\"text/css\">
    59         <!--
    60 
    61         .td-89 {
    62         width: 89%;     
    63         border: 1px;
    64         text-align: left;
    65         }
    66         .td-vuoto {
    67                
    68         width: 100%;   
    69         border: 1px;
    70         text-align: left;
    71        
    72 }
    73 
    74 
    75         .td-5 {
    76        
    77         margin: 0px 0 0 0px;
    78         width: 5%;     
    79         /*border: none;*/
    80         padding: 0px;
    81        
    82         text-align: center;
    83         }       
    84 
    85 
    86 
    87         .bggray         {
    88                 background: #ffffff;
    89                 FONT-SIZE: 13px;
    90                 FONT-FAMILY: Helvetica;
    91                 border: 1px;
    92         }
    93 
    94         .bggray2        {
    95                 background: #EFEFEF;
    96                 FONT-SIZE: 13px;
    97                 FONT-FAMILY: Helvetica;
    98                 border: 1px;
    99                 }
    100         -->
    101         </style>";
    102 
    103 
    104 
    105 
    106 }
    107        
    108      
    109 
    110 
    111 
    112 
    113    
    114         // referendum
    115        
    116         $posref='';
    117         if (!IsSet($num_ref)) {
    118                 $num_ref=1;
    119                 $sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons'";
    120                 $resg = $dbi->prepare("$sql");
    121                 $resg->execute();
    122                 $num_refs= $resg->rowCount(); //quante pagine?
    123         }       
    124         if($genere=='0'){
    125                 $sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' and num_gruppo='$num_ref'";
    126                 $resg = $dbi->prepare("$sql");
    127                 $resg->execute();
    128                 list($id_gruppo)=$resg->fetch(PDO::FETCH_NUM);
    129         $posref="&amp;num_ref=$num_ref&amp;num_refs=$num_refs";
    130        
    131         }
    132         // icone stampa e grafici
    133        
    134         if (!$csv){
    135         if(!isset($html)) $html='';
    136         $html .= "<div>
    137         <a href=\"modules.php?name=Elezioni&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;op=affluenze_graf\">
    138         "._VER_GRAF." <img class=\"image\" src=\"modules/Elezioni/images/grafici.png\" alt=\"\" /></a>
    139         <a href=\"modules.php?name=Elezioni&amp;op=come&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;info=affluenze_sez$posref&amp;csv=1\">"._VER_STAMPA."
    140         <img class=\"image\" src=\"modules/Elezioni/images/printer.png\" alt=\"\" /></a>
    141         <a href=\"modules.php?name=Elezioni&amp;op=come&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;info=affluenze_sez$posref&amp;csv=1&amp;xls=1\">
    142         <img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"\" /></a>
    143 <a href=\"modules.php?name=Elezioni&amp;op=come&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;info=affluenze_sez$posref&amp;csv=1&amp;pdf=1\">
    144         <img class=\"image\" src=\"modules/Elezioni/images/pdf.gif\" alt=\"\" /></a>
    145 
    146         </div>
    147 
    148         <h2><b>"._DETTAGLIO."  "._AFFLUENZE."</b></h2>";
    149           } 
    150        
    151         // descrizione
    152          if ($genere==0){
    153          $sql="select descrizione from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
    154         $des = $dbi->prepare("$sql");
    155         $des->execute();
    156                 list($descrizione)=$des->fetch(PDO::FETCH_NUM);
    157                 if(!isset($html)) $html='';
    158                 $html .= "<div><h4>$descrizione</h4></div>";
    159         }
    160        
    161        
    162         $cond= $genere==0 ? "and t3.id_gruppo='$id_gruppo'" : "";
    163         $i=1;
    164        
    165        
    166         $sql="SELECT num_sez,id_sez,t1.id_sede, t2.id_circ,maschi,femmine,(maschi+femmine) as elettori FROM ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede $circos order by num_sez";
    167         $res = $dbi->prepare("$sql");
    168         $res->execute();
    169         while ($linka[$i++] = $res->fetch(PDO::FETCH_BOTH));
    170 #       while (list($appo) = mysql_fetch_array($res)) {$i=$appo['num_sez']; $linka[$i] = $appo;echo "\nnum:$i:".$linka[$i]['num_sez'];}die();
    171         $num_sez = $res->rowCount(); //numero totale delle sezioni
    172         if (isset($linka[1]['num_sez']))  $sez_da=$linka[1]['num_sez']; else $sez_da=0;
    173         $sez_a=$sez_da+$num_sez-1;
    174         $tot_compl=0;$tot_u=0;$tot_d=0;
    175 //      $ar['riga1'][0]="<hr>";
    176         $tot= array();
    177         $ar[0][0]="<b>TOTALI</b>";
    178         $ar['perc'][0]="Perc.";
    179 //      $ar['riga2'][0]="<hr>";
    180 #       foreach($linka['num_sez'] as $i)
    181 $y=1;
    182 for ($i=$sez_da;$i<=$sez_a;$i++,$y++)   {       
    183 #               $ar[$i]['numsez']=$i;
    184                 if(!isset($linka[$y]['num_sez'])) { $linka[$y]['num_sez']=0; $linka[$y]['elettori']=0;}
    185                 $z=$linka[$y]['num_sez'];
    186                 $ar[$z]['numsez']=$linka[$y]['num_sez'];
    187                 $ar[$z]['elettori']=number_format($linka[$y]['elettori'],0,',','.');
    188                 $tot_compl+=$linka[$y]['elettori'];
    189                 $tot_u+=$linka[$y]['maschi'];
    190                 $tot_d+=$linka[$y]['femmine'];
    191 
    192 
    193         }
    194         $ar[0][1]="<b>".number_format($tot_compl,0,',','.')."</b>";
    195 
    196         $ar['perc'][1]=" ";
    197 
    198         $perc_u=0;$perc_d=0;$perc_c=0;
    199         $sql="SELECT t1.data,t1.orario FROM ".$prefix."_ele_rilaff as t1 left join ".$prefix."_ele_voti_parziale as t2 on t2.data=t1.data and t2.orario=t1.orario left join ".$prefix."_ele_cons_comune as t3 on t3.id_cons_gen=t1.id_cons_gen where t1.id_cons_gen='$id_cons_gen' and t3.id_cons=t2.id_cons group by t1.data,t1.orario order by t1.data,t1.orario";
    200         $resril = $dbi->prepare("$sql");
    201         $resril->execute();
    202         $num_ril= $resril->rowCount();  //numero delle rilevazioni previste
    203         if(!isset($html)) $html='';
    204         $html .= "<table class=\"td-89\">";
    205         $html .= "<tr class=\"bggray\"><td class=\"\">"._SEZIONI."</td><td>"._ISCR_SEZ."</td>";
    206 
    207                 $sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
    208                 $resuo = $dbi->prepare("$sql");
    209                 $resuo->execute();
    210                 list($ultora,$ultdata)=$resuo->fetch(PDO::FETCH_NUM);
    211                
    212 
    213         $sql="select t3.data,t3.orario,sum(t3.voti_complessivi),sum(t3.voti_uomini),sum(t3.voti_donne)  from ".$prefix."_ele_voti_parziale as t3 left join ".$prefix."_ele_sezioni as t1 on t3.id_sez=t1.id_sez left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t3.id_cons='$id_cons' $circos $cond group by t3.data,t3.orario,t3.id_gruppo order by t3.data,t3.orario";
    214         $ressomma = $dbi->prepare("$sql");
    215         $ressomma->execute();
    216 
    217 
    218 $perc_u=array(); $perc_d=array(); $perc_c=array();
    219         while (list($data,$ora,$somma,$votiu,$votid) = $ressomma->fetch(PDO::FETCH_NUM)) {
    220                 $perc_u[$data.$ora]=0;
    221                 $perc_d[$data.$ora]=0;
    222                 $perc_c[$data.$ora]=0;
    223                 if($votiu or $votid)
    224 #               if(($data==$ultdata) and ($ora==$ultora))
    225                 {
    226                         $tot[$data.$ora]="<table style=\"width:180px;\"><tr class=\"bggray2\"><td style=\"width:33%;text-align:center;\">
    227                         <b>".number_format($votiu,0,',','.')."</b></td><td style=\"width:33%;text-align:center;\">
    228                         <b>".number_format($votid,0,',','.')."</b></td><td style=\"width:33%;text-align:center;\">
    229                         <b>".number_format($somma,0,',','.')."</b></td>
    230                         </tr></table>";
    231                         $perc_u[$data.$ora]=number_format($votiu*100/$tot_u,2);
    232                         $perc_d[$data.$ora]=number_format($votid*100/$tot_d,2);
    233                         $perc_c[$data.$ora]=number_format($somma*100/$tot_compl,2);
    234                 }
    235                 else
    236                         $tot[$data.$ora]=$somma;
    237         }
    238         $ud=0;$ora_rif="";
    239         while (list($data1,$ora1) = $resril->fetch(PDO::FETCH_NUM))
    240         {
    241                 $ud++; 
    242                 list($hour, $minute, $second) = explode(":", $ora1);
    243                 $ora_ril=$hour.":".$minute;
    244                 $html .= "<td";
    245                 if ($ud==$num_ril and (isset($perc_u[$data1.$ora1]) or isset($perc_d[$data1.$ora1]))) {$ora_rif="$data1.$ora1";}
    246                 $html .= ">";
    247                 $data_a=form_data($data1);
    248                 $html .= "".$data_a."<br />"._ORE." ".$ora_ril;
    249                 $sql="SELECT count(data) FROM ".$prefix."_ele_voti_parziale as t3 left join ".$prefix."_ele_sezioni as t1 on t3.id_sez=t1.id_sez left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' and data='$data1' and orario='$ora_ril' $circos group by t3.id_gruppo";
    250                 $resaff = $dbi->prepare("$sql");
    251                 $resaff->execute();
    252                 list($num_scr) = $resaff->fetch(PDO::FETCH_NUM);  //numero delle sezioni inserite
    253                 $html .= "<br />"._SEZIONI." $num_scr "._SU." $num_sez";
    254 ##              if ($ud==$num_ril and ($perc_u or $perc_d)) $html .= "<br />
    255                 if (isset($perc_u[$data1.$ora1]) or isset($perc_d[$data1.$ora1])) $html .= "<br />
    256                
    257                 <table style=\"width:180px;\"><tr class=\"bggray\">
    258                 <th style=\"width:28%;text-align:center;\">"._UOMINI."</th>
    259                 <th style=\"width:28%;text-align:center;\">"._DONNE."</th>
    260                 <th style=\"width:28%;text-align:center;\">"._COMPLESSIVI."</th>
    261                 </tr></table>";
    262                
    263                 $html .= "</td>";
    264 
    265         if (isset($tot[$data1.$ora1])){
    266 ##              if ($ora_rif=="$data1.$ora1")
    267 if (($perc_u[$data1.$ora1] or $perc_d[$data1.$ora1]))           {
    268                         $ar['perc'][$data1.$ora1]="<table style=\"width:180px;\"><tr class=\"bggray2\">
    269                         <td style=\"width:33%;text-align:center;\"><b><i><span class=\"red\">".$perc_u[$data1.$ora1]."%</span></i></b></td>
    270                         <td style=\"width:33%;text-align:center;\"><b><i><span class=\"red\">".$perc_d[$data1.$ora1]."%</span></i></b></td>
    271                         <td style=\"width:33%;text-align:center;\" ><span class=\"red\"><b><i>".$perc_c[$data1.$ora1]."%</i></b></span></td>
    272                         </tr></table>";
    273                         $ar[0][$data1.$ora1]=$tot[$data1.$ora1];
    274                 }
    275                 else
    276                 {
    277                         $ar['perc'][$data1.$ora1]="<b><span class=\"red\"><i>
    278                         ".number_format($tot[$data1.$ora1]*100/$tot_compl,2)."%</i></span></b>";
    279                         $ar[0][$data1.$ora1]="<b>".(number_format($tot[$data1.$ora1],0,',','.'))."</b>";
    280                 }
    281 
    282                 if (intval(preg_match('/[1-9]/',$tot[$data1.$ora1]))>0) {
    283 #foreach($ar[['num_sez'] as $i)
    284 ##########
    285         $sql="select t1.num_sez  from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t2.id_cons='$id_cons' $circos order by t1.num_sez ";
    286         $resvoti = $dbi->prepare("$sql");
    287         $resvoti->execute();
    288 
    289 ###########
    290 #               for ($i=$sez_da;$i<=$sez_a;$i++)
    291                 while (list($i)=$resvoti->fetch(PDO::FETCH_NUM))
    292                         {
    293                                 $ar[$i][$data1.$ora1]="<span style=\"color: rgb(255, 0, 0);\">non rilevata</span>";
    294                         }
    295                 }
    296         }
    297         }
    298         $sql="select t3.data,t3.orario,t1.num_sez,voti_uomini, voti_donne, voti_complessivi  from ".$prefix."_ele_voti_parziale as t3 left join ".$prefix."_ele_sezioni as t1 on t3.id_sez=t1.id_sez left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t3.id_cons='$id_cons' $circos $cond order by data,orario,t1.num_sez ";
    299         $resvoti = $dbi->prepare("$sql");
    300         $resvoti->execute();
    301         $ud=0;
    302         while (list($data,$ora,$numsez,$uomini,$donne,$complessivi) = $resvoti->fetch(PDO::FETCH_NUM)) {
    303 #               if ($ora_rif=="$data.$ora")
    304                 if(($uomini+$donne)>0)
    305                         $ar[$numsez][$data.$ora]="<table style=\"width:180px;\"><tr class=\"bggray2\">
    306                         <td style=\"width:33%;text-align:center;\">$uomini</td>
    307                         <td style=\"width:33%;text-align:center;\">$donne</td>
    308                         <td style=\"width:33%;text-align:center;\">$complessivi</td>
    309                         </tr></table>";
    310                 else
    311                         $ar[$numsez][$data.$ora]=$complessivi;
    312         }
    313     $html .= "</tr>";
    314 
    315         foreach ($ar as $i => $arr) {
    316                 $html .= "<tr class=\"bggray2\">";
    317                 foreach ($arr as $valore)
    318                 {
    319                
    320                         $html .= "<td class=\"bggray2\" style=\"text-align:center;\">$valore</td>";
    321                 }
    322                 $html .= "</tr>";
    323         }
    324 
    325        
    326              
    327              $html .= "</table>";
    328                
    329              if($genere==0){ //se e' referendum
    330         #'Pagina precedente' e 'Pagina Successiva'
    331         if ($xls!='1' && $pdf!='1' && $csv!='1'){
    332         $html .= "<div class=\"modulo\">";
    333             $cur=$num_ref;
    334         if ($cur>1) {
    335                
    336                 $num_ref--;
    337                           $html .= "<a href=\"modules.php?name=Elezioni&amp;op=come&amp;info=affluenze_sez&amp;id_cons_gen=$id_cons_gen&amp;num_ref=$num_ref&amp;num_refs=$num_refs&amp;id_comune=$id_comune\">";
    338                 $html .= "[ <b>"._PREV_MATCH."</b> ] </a>";
    339         }
    340         if ($cur<$num_refs) {
    341                 $cur++;       
    342                         $html .= "<a href=\"modules.php?name=Elezioni&amp;op=come&amp;info=affluenze_sez&amp;id_cons_gen=$id_cons_gen&amp;num_ref=$cur&amp;num_refs=$num_refs&amp;id_comune=$id_comune\">";
    343             $html .= "[ <b>"._NEXT_MATCH."</b> ] </a>";
    344         }
    345         $html .= "</div>";
    346         }
    347 }
    348        
    349 if(!isset($style)) $style='';   
    350 if($csv==1){
    351       $data=date("d-m-y G:i");
    352       $style .="\t\t\n<br/><br/><br/><div style=\"margin:0px auto;text-align:center;\"><i>Stampato: $data</i></div>";
    353       $style .="<br/><div style=\"text-align:center;\"><i>Eleonline by luciano apolito e roberto gigli - www.eleonline.it</i></div>";           
    354       $style .= "<br/>  ";     
    355      
    356 }       
    357 //$html .= "</div>";
    358 
     19include('affluenze-inc.php');
    35920
    36021############### stampa
    36122if ($xls!='1' && $pdf!='1'){
    362       echo "$datipdf $html $style";
    363 
     23    echo "$datipdf $html $style";
    36424}elseif($xls=="1"){
    36525        $nomefile="affluenze.xls";
     
    37232        echo "$html \t\n $style";
    37333}elseif($pdf=='1'){
    374                 $nomefile="$descr_cons affluenze.pdf";
    375                
    376                 $stampa ="$datipdf $html $style";
    377                
     34        $nomefile="$descr_cons affluenze.pdf"; 
     35        $stampa ="$datipdf $html $style";
     36        if($vismf)             
     37                $html2pdf = new Html2Pdf('L','A4', 'it');
     38        else
    37839                $html2pdf = new Html2Pdf('P','A4', 'it');
    379                 $html2pdf->WriteHTML($stampa, isset($_GET['vuehtml']));
    380                 $html2pdf->Output($nomefile);
     40        $html2pdf->WriteHTML($stampa, isset($_GET['vuehtml']));
     41        $html2pdf->Output($nomefile);
    38142}
     43if($csv!=1 ) include ("footer.php");
    38244
    383 
    384 if($csv!=1 ) include ("footer.php");
    385  
    38645?>
Note: See TracChangeset for help on using the changeset viewer.