Index: trunk/CHANGES.txt
===================================================================
--- trunk/CHANGES.txt	(revision 375)
+++ trunk/CHANGES.txt	(revision 376)
@@ -1,34 +1,4 @@
-##############################################
-# Eleonline 2.0			             #
-# =================                          #
-# Copyright (c) 2012 			     #	
-# by Luciano Apolito e Roberto Gigli	     #
-# http://www.eleonline.it                    #
-# licenza Gnu-GPL 2.0			     #	
-##############################################
-
-Soraldo: release iniziale anno 2001
-
-Eleonline 1.0 : release anno 2006
-Comuni che usano eleonline 25
-
-Eleonline 2.0 : release anno 2009
-Corregge vari bug emersi durante le ultime consultazioni elettorali.
-Implementa la gestione di comuni suddivisi in piu' collegi per consultazioni regionali, europee, senato, camera.
-Implementa grafica multiuso 
-Comuni che usano eleonline 40
-
-Eleonline 2.0 rev 152 ottobre 2012
-- implementazione con le nuove norme sulla suddivisione dei seggi e leggi regione Sicilia
-- migliorie e correzioni varie
-
-Eleonline 2.0 rev 153 ottobre  2012
-- Protezione cfrs 
-
-Eleonline 2.0 rev 154 novembre  2012
-- migliorie e correzioni varie pacchetti e installazione
-
-Comuni che usano eleonline 123
- 
-
-
+Eleonline rev. 376
+CLIENT
+- modifica della pagina Informazioni - Affluenze
+- modifica della pagina Informazioni - Votanti
Index: trunk/CREDITS.txt
===================================================================
--- trunk/CREDITS.txt	(revision 375)
+++ trunk/CREDITS.txt	(revision 376)
@@ -1,4 +1,4 @@
 ##############################################
-# Eleonline 2.0			             #
+# Eleonline 			             #
 # =================                          #
 # Copyright (c) 2012 			     #	
@@ -10,5 +10,5 @@
 
 Developer:
-- Luciano Apolito email:apoluc@gmail.com cell: 3389538670
-- Roberto Gigli email: rgigli@libero.it 
+- Luciano Apolito 
+- Roberto Gigli email: roberto.gigli@eleonline.it
 
Index: trunk/README.txt
===================================================================
--- trunk/README.txt	(revision 375)
+++ trunk/README.txt	(revision 376)
@@ -41,5 +41,5 @@
 Finita l'installazione cancellare il file install.php e la directory install
 
-Note: se si vuole installare una release piu recente seguire le istruzioni presenti nel file relativo nella dir "doc"
+Link al manuale online: https://docs.google.com/document/d/17obEUipKn6KclxAU_hM-N4ogiXlXURSig5hdI3bYXmo/edit?usp=sharing
 
 
Index: trunk/admin/admin.php
===================================================================
--- trunk/admin/admin.php	(revision 375)
+++ trunk/admin/admin.php	(revision 376)
@@ -135,39 +135,52 @@
 }
 
-
-
-
-	try{
-	$dbi = new PDO("mysql:host=$dbhost;charset=utf8", $dbuname, $dbpass, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION)); 
-     	$sql = "use $dbname";
-    	$dbi->exec($sql);
-        }
-	catch(PDOException $e)
-	{
-	    echo $sql . "<br>" . $e->getMessage();
-	}                                                                                       	
-	$sth = $dbi->prepare("SET SESSION character_set_connection = 'utf8' ");
-	$sth->execute();
-	$sth = $dbi->prepare("SET SESSION character_set_client = 'utf8' ");
-	$sth->execute();
-	$sth = $dbi->prepare("SET SESSION character_set_database = 'utf8' ");
-	$sth->execute();
-	$sth = $dbi->prepare("SET CHARACTER SET utf8");
-	$sth->execute();
-
-	$sth = $dbi->prepare("SET NAMES 'utf8'");
-	$sth->execute();
-	$sth = $dbi->prepare("select * from ".$prefix."_config");
-	$sth->execute();
-	
+$dsn = "mysql:host=$dbhost";
+$opt = [
+PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+PDO::ATTR_EMULATE_PREPARES => false,
+];
+if($prefix == '') {
+	db_err ('stepBack','Non avete indicato il prefisso tabelle database.');
+}
+try 
+{
+	$dbi = new PDO($dsn, $dbuname, $dbpass, $opt);
+}
+catch(PDOException $e)
+{
+	echo $sql . "<br>" . $e->getMessage();die();
+}
+$sql = "use $dbname";
+try
+{
+	$dbi->exec($sql);
+}
+catch(PDOException $e)
+{
+	echo $sql . "<br>" . $e->getMessage();
+}                                                                                       	
+$sth = $dbi->prepare("SET SESSION character_set_connection = 'utf8' ");
+$sth->execute();
+$sth = $dbi->prepare("SET SESSION character_set_client = 'utf8' ");
+$sth->execute();
+$sth = $dbi->prepare("SET SESSION character_set_database = 'utf8' ");
+$sth->execute();
+$sth = $dbi->prepare("SET CHARACTER SET utf8");
+$sth->execute();
+
+$sth = $dbi->prepare("SET NAMES 'utf8'");
+$sth->execute();
+$sth = $dbi->prepare("select * from ".$prefix."_config");
+$sth->execute();
+
 #		$dbi=mysql_connect($dbhost, $dbuname, $dbpass) or die("Connessione non riuscita: " . mysql_error());
 #		mysql_select_db($dbname)or die("Connessione non riuscita:" . mysql_error());
 ##	mysql_query("SET NAMES 'utf8'", $dbi);
 //---10/05/2009  gestione consultazione predefinita
-	$sth = $dbi->prepare("select * from ".$prefix."_config");
-	$sth->execute();
-	$row = $sth->fetch(PDO::FETCH_ASSOC);
-	#$row = $sth->fetchAll();	
-	$siteistat=$row['siteistat'];
+$sth = $dbi->prepare("select * from ".$prefix."_config");
+$sth->execute();
+$row = $sth->fetch(PDO::FETCH_ASSOC);
+#$row = $sth->fetchAll();	
+$siteistat=$row['siteistat'];
 if (!isset($_SESSION['id_comune'])){
 	$_SESSION['sitename']=$row['sitename'];
Index: trunk/admin/aggiornadb.php
===================================================================
--- trunk/admin/aggiornadb.php	(revision 375)
+++ trunk/admin/aggiornadb.php	(revision 376)
@@ -102,9 +102,9 @@
 if(controllo($prefix.'_authors','admincomune',++$num))
 {
-	$sql="UPDATE `soraldo_authors` SET `adminop` = '1', `adminsuper` = '0',`admincomune` = '0' WHERE `soraldo_authors`.`aid` != 'admin' AND `soraldo_authors`.`aid` != 'suser'";
-	$ret=aggiorna($sql,$dbi,'',$num);
-	$sql="UPDATE `soraldo_authors` SET `adminop` = '0', `adminsuper` = '1',`admincomune` = '0' WHERE `soraldo_authors`.`aid` = 'suser'";
+	$sql="UPDATE `soraldo_authors` SET `adminop` = '1', `adminsuper` = '0',`admincomune` = '0' WHERE `soraldo_authors`.`aid` != 'admin' AND `soraldo_authors`.`adminsuper` != '1'";
 	$ret=aggiorna($sql,$dbi,'',$num);
 	$sql="UPDATE `soraldo_authors` SET `adminop` = '0', `adminsuper` = '0',`admincomune` = '1' WHERE `soraldo_authors`.`aid` = 'admin'";
+	$ret=aggiorna($sql,$dbi,'',$num);
+	$sql="UPDATE `soraldo_authors` SET `adminop` = '0', `adminsuper` = '1',`admincomune` = '0' WHERE `soraldo_authors`.`aid` = 'suser' or `soraldo_authors`.`adminsuper` = '1'";
 	$ret=aggiorna($sql,$dbi,'',$num);
 	echo "<br> La tabella dei permessi Ãš stata aggiornata<br>";
@@ -131,15 +131,15 @@
 }	
 ++$num;
-$sql="ALTER TABLE `".$prefix."_ele_come` CHANGE `title` `title` VARCHAR(150) NOT NULL DEFAULT ' ', CHANGE `preamble` `preamble` TEXT NOT NULL DEFAULT ' ', CHANGE `content` `content` TEXT NOT NULL DEFAULT ' ', CHANGE `editimage` `editimage` VARCHAR(100) NOT NULL DEFAULT ' '"; 
+$sql="ALTER TABLE `".$prefix."_ele_come` CHANGE `title` `title` VARCHAR(150) NOT NULL DEFAULT ' ', CHANGE `preamble` `preamble` TEXT, CHANGE `content` `content` TEXT, CHANGE `editimage` `editimage` VARCHAR(100) NOT NULL DEFAULT ' '"; 
 $ret=aggiorna($sql,$dbi,'',$num);
 echo "<br>";
 if(!$ret) echo "Il tuo sistema non necessita di questo aggiornamento, questo avviso di errore va ignorato<br>";
 ++$num;
-$sql="ALTER TABLE `".$prefix."_ele_link` CHANGE `title` `title` VARCHAR(150) NOT NULL DEFAULT ' ', CHANGE `preamble` `preamble` TEXT NOT NULL DEFAULT ' ', CHANGE `content` `content` TEXT NOT NULL DEFAULT ' ', CHANGE `editimage` `editimage` VARCHAR(100) NOT NULL DEFAULT ' '"; 
+$sql="ALTER TABLE `".$prefix."_ele_link` CHANGE `title` `title` VARCHAR(150) NOT NULL DEFAULT ' ', CHANGE `preamble` `preamble` TEXT, CHANGE `content` `content` TEXT, CHANGE `editimage` `editimage` VARCHAR(100) NOT NULL DEFAULT ' '"; 
 $ret=aggiorna($sql,$dbi,'',$num);
 echo "<br>";
 if(!$ret) echo "Il tuo sistema non necessita di questo aggiornamento, questo avviso di errore va ignorato<br>";
 ++$num;
-$sql="ALTER TABLE `".$prefix."_ele_servizi` CHANGE `title` `title` VARCHAR(150) NOT NULL DEFAULT ' ', CHANGE `preamble` `preamble` TEXT NOT NULL DEFAULT ' ', CHANGE `content` `content` TEXT NOT NULL DEFAULT ' ', CHANGE `editimage` `editimage` VARCHAR(100) NOT NULL DEFAULT ' '"; 
+$sql="ALTER TABLE `".$prefix."_ele_servizi` CHANGE `title` `title` VARCHAR(150) NOT NULL DEFAULT ' ', CHANGE `preamble` `preamble` TEXT, CHANGE `content` `content` TEXT, CHANGE `editimage` `editimage` VARCHAR(100) NOT NULL DEFAULT ' '"; 
 $ret=aggiorna($sql,$dbi,'',$num);
 echo "<br>";
Index: trunk/admin/modules/Elezioni/ele_controlli.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_controlli.php	(revision 375)
+++ trunk/admin/modules/Elezioni/ele_controlli.php	(revision 376)
@@ -383,5 +383,5 @@
 						$totsl+=$svl;
 						$tnl+=$nl;
-						if(($votig+$svl)<($votil+$svg+$nl) and ($solog or $disg))
+						if(($votig+$svl)<($votil+$svg+$nl) and (!$solog and !$disg))
 						{ $err=1; $tipo='lista'; break; }
 					}				
Index: trunk/admin/versione.php
===================================================================
--- trunk/admin/versione.php	(revision 375)
+++ trunk/admin/versione.php	(revision 376)
@@ -1,7 +1,7 @@
 <?php
 
-$versione = "3.0 rev 375";
+$versione = "3.0 rev 376";
 $version_number = $versione;
-$datarel = "06 settembre 2022";
+$datarel = "24 settembre 2022";
 $version = "Eleonline $version_number (<i>Data Release: $datarel</i>)";
 
Index: trunk/client/modules/Elezioni/affluenze-inc.php
===================================================================
--- trunk/client/modules/Elezioni/affluenze-inc.php	(revision 376)
+++ trunk/client/modules/Elezioni/affluenze-inc.php	(revision 376)
@@ -0,0 +1,318 @@
+<?php
+/************************************************************************/
+/* Eleonline - Raccolta e diffusione dei dati elettorali                */
+/* by Luciano Apolito & Roberto Gigli                                   */
+/* http://www.eleonline.it                                              */
+/* info@eleonline.it rgigli@libero.it               */
+/************************************************************************/
+
+if (!defined('MODULE_FILE')) {
+    die ("You can't access this file directly...");
+}
+
+if (isset($param['id_cons_gen'])) $id_cons_gen=intval($param['id_cons_gen']); else $id_cons_gen='';
+if (isset($param['num_ref'])) $num_ref=intval($param['num_ref']);
+if (isset($param['num_refs'])) $num_refs=intval($param['num_refs']);
+if (isset($param['id_comune'])) $id_comune=intval($param['id_comune']);
+if (isset($param['xls'])) $xls=intval($param['xls']);
+if (isset($param['pdf'])) $pdf=intval($param['pdf']);
+$sql="SELECT t1.tipo_cons,t3.genere,t2.id_cons,t2.vismf 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'";
+$res = $dbi->prepare("$sql");
+$res->execute();
+list($tipo_cons,$genere,$id_cons,$vismf) = $res->fetch(PDO::FETCH_NUM);
+global $lang,$circo,$id_circ;
+
+if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
+else $circos=''; 
+
+# testata
+include_once("modules/Elezioni/language/lang-$lang.php");
+$datipdf='';
+if($csv==1){
+	include_once("modules/Elezioni/funzioni.php");
+	
+	$sql="SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
+	$res = $dbi->prepare("$sql");
+	$res->execute();
+	list($descr_com) = $res->fetch(PDO::FETCH_NUM);
+        $descr_com =stripslashes($descr_com); 
+	$datipdf .= "<div style=\"margin:0px auto; text-align:center;\">";
+	$siteistat=$id_comune;
+	# salva sull'hardisk lo stemma del comune
+	$logo=verificasimbolo();
+	$immagine= "<img src=\"modules/Elezioni/images/$logo\" alt=\"logo\" align=\"left\"/>";
+
+	if($xls!=1) $datipdf .= "<table><tr><td>$immagine</td><td>";
+	
+        $datipdf .= ""._COMUNE." $descr_com <br />
+	"._RISULTA." "._CONSULTA."<br/ >";
+	$datipdf .= "$descr_cons<br />"._DISCLAIMER."
+        <br /><b>"._DETTAGLIO."  "._AFFLUENZE."</b>";
+	if($xls!=1) $datipdf .=  "</td></tr></table>";
+	$datipdf .="</div>";
+
+	$html = "<style type=\"text/css\">
+	<!--
+
+	.td-89 {
+	width: 89%;	
+	border: 1px;
+	text-align: left; 
+	}
+	.td-vuoto {
+		
+	width: 100%;	
+	border: 1px;
+	text-align: left; 
+	
+}
+
+
+	.td-5 {
+	
+	margin: 0px 0 0 0px;
+	width: 5%;	
+	/*border: none;*/
+	padding: 0px;
+        
+	text-align: center; 
+	}	
+
+	.bgw	{
+		background: #ffffff; 
+		font-size: 13px; 
+		font-family: Helvetica;
+		text-align: right;
+	}
+
+	.bggray 	{
+		background: #ffffff; 
+		FONT-SIZE: 13px; 
+		FONT-FAMILY: Helvetica;
+		text-align: center;
+	}
+
+	.bggray2 	{
+		background: #EFEFEF; 
+		FONT-SIZE: 13px; 
+		FONT-FAMILY: Helvetica;
+		text-align: right;
+		}
+	-->
+	</style>";
+}
+	// referendum
+	
+	$posref='';
+	if (!IsSet($num_ref)) { 
+		$num_ref=1;
+		$sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons'";
+		$resg = $dbi->prepare("$sql");
+		$resg->execute();
+		$num_refs= $resg->rowCount(); //quante pagine?
+	}	
+	if($genere=='0'){
+		$sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' and num_gruppo='$num_ref'";	
+		$resg = $dbi->prepare("$sql");
+		$resg->execute();
+		list($id_gruppo)=$resg->fetch(PDO::FETCH_NUM);
+		$posref="&amp;num_ref=$num_ref&amp;num_refs=$num_refs";	
+	}
+	// icone stampa e grafici	
+	if (!$csv){
+		if(!isset($html)) $html='';
+		$html .= "<div>
+		<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\">
+		"._VER_GRAF." <img class=\"image\" src=\"modules/Elezioni/images/grafici.png\" alt=\"\" /></a>
+		<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."
+		<img class=\"image\" src=\"modules/Elezioni/images/printer.png\" alt=\"\" /></a>
+		<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\">
+		<img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"\" /></a>
+		<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\">
+		<img class=\"image\" src=\"modules/Elezioni/images/pdf.gif\" alt=\"\" /></a>
+		</div>
+		<h2><b>"._DETTAGLIO."  "._AFFLUENZE."</b></h2>";
+	}  	
+	// descrizione
+	 if ($genere==0){
+		$sql="select descrizione from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
+		$des = $dbi->prepare("$sql");
+		$des->execute();
+		list($descrizione)=$des->fetch(PDO::FETCH_NUM);
+	        if(!isset($html)) $html='';
+		$html .= "<div><h4>$descrizione</h4></div>";
+	}	
+	$cond= $genere==0 ? "and t3.id_gruppo='$id_gruppo'" : "";
+	$i=1;	
+	$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";
+	$res = $dbi->prepare("$sql");
+	$res->execute();
+	while ($linka[$i++] = $res->fetch(PDO::FETCH_BOTH));
+#	while (list($appo) = mysql_fetch_array($res)) {$i=$appo['num_sez']; $linka[$i] = $appo;echo "\nnum:$i:".$linka[$i]['num_sez'];}die();
+	$num_sez = $res->rowCount(); //numero totale delle sezioni
+	if (isset($linka[1]['num_sez']))  $sez_da=$linka[1]['num_sez']; else $sez_da=0;
+	$sez_a=$sez_da+$num_sez-1;
+	$tot_compl=0;$tot_u=0;$tot_d=0;
+//	$ar['riga1'][0]="<hr>";
+	$tot= array();
+	$ar[0][0]="<b>TOTALI</b>";
+	$ar['perc'][0]="Perc.";
+//	$ar['riga2'][0]="<hr>";
+#	foreach($linka['num_sez'] as $i)
+	$y=1;
+	for ($i=$sez_da;$i<=$sez_a;$i++,$y++)	{	
+#		$ar[$i]['numsez']=$i;
+		if(!isset($linka[$y]['num_sez'])) { $linka[$y]['num_sez']=0; $linka[$y]['elettori']=0;}
+		$z=$linka[$y]['num_sez'];
+		$ar[$z]['numsez']=$linka[$y]['num_sez'];
+		$ar[$z]['elettori']=number_format($linka[$y]['elettori'],0,',','.');
+		$tot_compl+=$linka[$y]['elettori'];
+		$tot_u+=$linka[$y]['maschi'];
+		$tot_d+=$linka[$y]['femmine'];
+	}
+	$ar[0][1]="<b>".number_format($tot_compl,0,',','.')."</b>";
+	$ar['perc'][1]=" ";
+	$perc_u=0;$perc_d=0;$perc_c=0;
+	$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";
+	$resril = $dbi->prepare("$sql");
+	$resril->execute();
+	$num_ril= $resril->rowCount();  //numero delle rilevazioni previste
+    if(!isset($html)) $html='';
+	$html .= "<table class=\"td-89\">";
+	$html .= "<tr class=\"bggray\"><td>"._SEZIONI."</td><td>"._ISCR_SEZ."</td>";
+	$sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
+	$resuo = $dbi->prepare("$sql");
+	$resuo->execute();
+	list($ultora,$ultdata)=$resuo->fetch(PDO::FETCH_NUM);
+ 	$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";
+	$ressomma = $dbi->prepare("$sql");
+	$ressomma->execute();
+	$perc_u=array(); $perc_d=array(); $perc_c=array();
+	while (list($data,$ora,$somma,$votiu,$votid) = $ressomma->fetch(PDO::FETCH_NUM)) {
+		$perc_u[$data.$ora]=0;
+		$perc_d[$data.$ora]=0;
+		$perc_c[$data.$ora]=0;
+		if($votiu or $votid)
+#		if(($data==$ultdata) and ($ora==$ultora))
+		{
+			$tot[$data.$ora]="<table style=\"width:180px;\"><tr class=\"bggray2\"><td style=\"width:33%;text-align:center;\">
+			<b>".number_format($votiu,0,',','.')."</b></td><td style=\"width:33%;text-align:center;\">
+			<b>".number_format($votid,0,',','.')."</b></td><td style=\"width:33%;text-align:center;\">
+			<b>".number_format($somma,0,',','.')."</b></td>
+			</tr></table>";
+			$perc_u[$data.$ora]=number_format($votiu*100/$tot_u,2);
+			$perc_d[$data.$ora]=number_format($votid*100/$tot_d,2);
+			$perc_c[$data.$ora]=number_format($somma*100/$tot_compl,2);
+		}
+		else
+			$tot[$data.$ora]=$somma;
+	}
+	$ud=0;$ora_rif="";
+	while (list($data1,$ora1) = $resril->fetch(PDO::FETCH_NUM)) 
+	{
+		$ud++;	
+		list($hour, $minute, $second) = explode(":", $ora1);
+		$ora_ril=$hour.":".$minute;
+		$html .= "<td"; 
+		if ($ud==$num_ril and (isset($perc_u[$data1.$ora1]) or isset($perc_d[$data1.$ora1]))) {$ora_rif="$data1.$ora1";}
+		$html .= ">";
+		$data_a=form_data($data1);
+		$html .= "".$data_a."<br />"._ORE." ".$ora_ril;
+		$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";
+		$resaff = $dbi->prepare("$sql");
+		$resaff->execute();
+		list($num_scr) = $resaff->fetch(PDO::FETCH_NUM);  //numero delle sezioni inserite
+		$html .= "<br />"._SEZIONI." $num_scr "._SU." $num_sez";
+##		if ($ud==$num_ril and ($perc_u or $perc_d)) $html .= "<br />
+		$html .= "<br /><table style=\"width:180px;\"><tr class=\"bggray\">";
+		if ((isset($perc_u[$data1.$ora1]) or isset($perc_d[$data1.$ora1])) and ($perc_u[$data1.$ora1]+$perc_d[$data1.$ora1])>0) 
+			$html .= "<th style=\"width:28%;text-align:center;\">"._UOMINI."</th><th style=\"width:28%;text-align:center;\">"._DONNE."</th>";
+		$html .= "<th style=\"width:28%;text-align:center;\">"._COMPLESSIVI."</th></tr></table></td>";
+
+		if (isset($tot[$data1.$ora1])){
+	##		if ($ora_rif=="$data1.$ora1")
+			if (($perc_u[$data1.$ora1] or $perc_d[$data1.$ora1])){
+				$ar['perc'][$data1.$ora1]="<table style=\"width:180px;\"><tr class=\"bggray2\">
+				<td style=\"width:33%;text-align:center;\"><b><i><span class=\"red\">".$perc_u[$data1.$ora1]."%</span></i></b></td>
+				<td style=\"width:33%;text-align:center;\"><b><i><span class=\"red\">".$perc_d[$data1.$ora1]."%</span></i></b></td>
+				<td style=\"width:33%;text-align:center;\" ><span class=\"red\"><b><i>".$perc_c[$data1.$ora1]."%</i></b></span></td>
+				</tr></table>";
+				$ar[0][$data1.$ora1]=$tot[$data1.$ora1];
+			}
+			else
+			{
+				$ar['perc'][$data1.$ora1]="<b><span class=\"red\"><i>
+				".number_format($tot[$data1.$ora1]*100/$tot_compl,2)."%</i></span></b>";
+				$ar[0][$data1.$ora1]="<b>".(number_format($tot[$data1.$ora1],0,',','.'))."</b>";
+			}
+
+			if (intval(preg_match('/[1-9]/',$tot[$data1.$ora1]))>0) {
+	#foreach($ar[['num_sez'] as $i)
+	##########
+				$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 ";
+				$resvoti = $dbi->prepare("$sql");
+				$resvoti->execute();
+
+	###########
+	#		for ($i=$sez_da;$i<=$sez_a;$i++)
+				while (list($i)=$resvoti->fetch(PDO::FETCH_NUM))
+				{
+					$ar[$i][$data1.$ora1]="<span style=\"color: rgb(255, 0, 0);\">non rilevata</span>";
+				}
+			}
+		}
+	}
+  	$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 ";
+	$resvoti = $dbi->prepare("$sql");
+	$resvoti->execute();
+	$ud=0;
+	while (list($data,$ora,$numsez,$uomini,$donne,$complessivi) = $resvoti->fetch(PDO::FETCH_NUM)) {
+		if(($uomini+$donne)>0)
+			$ar[$numsez][$data.$ora]="<table style=\"width:180px;\"><tr>
+			<td style=\"width:33%;text-align:center;\">$uomini</td>
+			<td style=\"width:33%;text-align:center;\">$donne</td>
+			<td style=\"width:33%;text-align:center;\">$complessivi</td>
+			</tr></table>";
+		else
+			$ar[$numsez][$data.$ora]=$complessivi;
+	}
+    $html .= "</tr>";
+	foreach ($ar as $i => $arr) {
+		if(intval($i) % 2)
+			$html .= "<tr class=\"bgw\">";
+		else
+			$html .= "<tr class=\"bggray2\">";			
+		foreach ($arr as $valore)
+		{			
+			$html .= "<td>$valore</td>";
+		}
+		$html .= "</tr>";
+	}	     
+	$html .= "</table>";		
+	if($genere==0){ //se e' referendum
+	#'Pagina precedente' e 'Pagina Successiva'
+	if ($xls!='1' && $pdf!='1' && $csv!='1'){
+	$html .= "<div class=\"modulo\">";
+	$cur=$num_ref;
+	if ($cur>1) {	
+		$num_ref--;
+		$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\">";
+		$html .= "[ <b>"._PREV_MATCH."</b> ] </a>";
+	}
+	if ($cur<$num_refs) {
+		$cur++;        
+		$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\">";
+		$html .= "[ <b>"._NEXT_MATCH."</b> ] </a>";
+	}
+	$html .= "</div>";
+	}
+}	
+if(!isset($style)) $style='';	
+if($csv==1){
+	$data=date("d-m-y G:i");
+	$style .="\t\t\n<br/><br/><br/><div style=\"margin:0px auto;text-align:center;\"><i>Stampato: $data</i></div>";
+	$style .="<br/><div style=\"text-align:center;\"><i>Eleonline by luciano apolito e roberto gigli - www.eleonline.it</i></div>";		
+	$style .= "<br/>  ";	     
+}	
+
+?>
Index: trunk/client/modules/Elezioni/affluenze.php
===================================================================
--- trunk/client/modules/Elezioni/affluenze.php	(revision 375)
+++ trunk/client/modules/Elezioni/affluenze.php	(revision 376)
@@ -4,5 +4,5 @@
 /* by Luciano Apolito & Roberto Gigli                                   */
 /* http://www.eleonline.it                                              */
-/* info@eleonline.it  luciano@aniene.net rgigli@libero.it               */
+/* info@eleonline.it rgigli@libero.it                                   */
 /************************************************************************/
 
@@ -11,4 +11,5 @@
 }
 
+
 require_once('inc/hpdf5/autoload.php');
 use Spipu\Html2Pdf\Html2Pdf;
@@ -16,350 +17,9 @@
 use Spipu\Html2Pdf\Exception\ExceptionFormatter;
 
-if (isset($param['id_cons_gen'])) $id_cons_gen=intval($param['id_cons_gen']); else $id_cons_gen='';
-if (isset($param['num_ref'])) $num_ref=intval($param['num_ref']);
-if (isset($param['num_refs'])) $num_refs=intval($param['num_refs']);
-if (isset($param['id_comune'])) $id_comune=intval($param['id_comune']);
-if (isset($param['xls'])) $xls=intval($param['xls']);
-if (isset($param['pdf'])) $pdf=intval($param['pdf']);
-$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'";
-$res = $dbi->prepare("$sql");
-$res->execute();
-list($tipo_cons,$genere,$id_cons) = $res->fetch(PDO::FETCH_NUM);
-global $lang,$circo,$id_circ;
-
-if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
-else $circos=''; 
-
-# testata
-include_once("modules/Elezioni/language/lang-$lang.php");
-if($csv==1){
-	include_once("modules/Elezioni/funzioni.php");
-	
-	$sql="SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-	list($descr_com) = $res->fetch(PDO::FETCH_NUM);
-        $descr_com =stripslashes($descr_com); 
-	$datipdf .= "<div style=\"margin:0px auto; text-align:center;\">";
-	$siteistat=$id_comune;
-	# salva sull'hardisk lo stemma del comune
-	$logo=verificasimbolo();
-	$immagine= "<img src=\"modules/Elezioni/images/$logo\" alt=\"logo\" align=\"left\"/>";
-
-	if($xls!=1) $datipdf .= "<table><tr><td>$immagine</td><td>";
-	
-        $datipdf .= ""._COMUNE." $descr_com <br />
-	"._RISULTA." "._CONSULTA."<br/ >";
-	$datipdf .= "$descr_cons<br />"._DISCLAIMER."
-        <br /><b>"._DETTAGLIO."  "._AFFLUENZE."</b>";
-	if($xls!=1) $datipdf .=  "</td></tr></table>";
-	$datipdf .="</div>";
-
-	$html = "<style type=\"text/css\">
-	<!--
-
-	.td-89 {
-	width: 89%;	
-	border: 1px;
-	text-align: left; 
-	}
-	.td-vuoto {
-		
-	width: 100%;	
-	border: 1px;
-	text-align: left; 
-	
-}
-
-
-	.td-5 {
-	
-	margin: 0px 0 0 0px;
-	width: 5%;	
-	/*border: none;*/
-	padding: 0px;
-        
-	text-align: center; 
-	}	
-
-
-
-	.bggray 	{
-		background: #ffffff; 
-		FONT-SIZE: 13px; 
-		FONT-FAMILY: Helvetica;
-		border: 1px;
-	}
-
-	.bggray2 	{
-		background: #EFEFEF; 
-		FONT-SIZE: 13px; 
-		FONT-FAMILY: Helvetica;
-		border: 1px;
-		}
-	-->
-	</style>";
-
-
-
-
-}
-	
-      
-
-
-
-
-    
-	// referendum
-	
-	$posref='';
-	if (!IsSet($num_ref)) { 
-		$num_ref=1;
-		$sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons'";
-		$resg = $dbi->prepare("$sql");
-		$resg->execute();
-		$num_refs= $resg->rowCount(); //quante pagine?
-	}	
-	if($genere=='0'){
-		$sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' and num_gruppo='$num_ref'";	
-		$resg = $dbi->prepare("$sql");
-		$resg->execute();
-		list($id_gruppo)=$resg->fetch(PDO::FETCH_NUM);
-	$posref="&amp;num_ref=$num_ref&amp;num_refs=$num_refs";
-	
-	}
-	// icone stampa e grafici
-	
-	if (!$csv){
-	if(!isset($html)) $html='';
-	$html .= "<div>
-	<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\">
-	"._VER_GRAF." <img class=\"image\" src=\"modules/Elezioni/images/grafici.png\" alt=\"\" /></a>
-	<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."
-	<img class=\"image\" src=\"modules/Elezioni/images/printer.png\" alt=\"\" /></a>
-	<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\">
-	<img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"\" /></a>
-<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\">
-	<img class=\"image\" src=\"modules/Elezioni/images/pdf.gif\" alt=\"\" /></a>
-
-	</div>
-
-	<h2><b>"._DETTAGLIO."  "._AFFLUENZE."</b></h2>";
-	  }  
-	
-	// descrizione
-	 if ($genere==0){
-	 $sql="select descrizione from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
-	$des = $dbi->prepare("$sql");
-	$des->execute();
-		list($descrizione)=$des->fetch(PDO::FETCH_NUM);
-	        if(!isset($html)) $html='';
-		$html .= "<div><h4>$descrizione</h4></div>";
-	}
-	
-	
-	$cond= $genere==0 ? "and t3.id_gruppo='$id_gruppo'" : "";
-	$i=1;
-	
-	
-	$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";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-	while ($linka[$i++] = $res->fetch(PDO::FETCH_BOTH));
-#	while (list($appo) = mysql_fetch_array($res)) {$i=$appo['num_sez']; $linka[$i] = $appo;echo "\nnum:$i:".$linka[$i]['num_sez'];}die();
-	$num_sez = $res->rowCount(); //numero totale delle sezioni
-	if (isset($linka[1]['num_sez']))  $sez_da=$linka[1]['num_sez']; else $sez_da=0;
-	$sez_a=$sez_da+$num_sez-1;
-	$tot_compl=0;$tot_u=0;$tot_d=0;
-//	$ar['riga1'][0]="<hr>";
-	$tot= array();
-	$ar[0][0]="<b>TOTALI</b>";
-	$ar['perc'][0]="Perc.";
-//	$ar['riga2'][0]="<hr>";
-#	foreach($linka['num_sez'] as $i)
-$y=1;
-for ($i=$sez_da;$i<=$sez_a;$i++,$y++)	{	
-#		$ar[$i]['numsez']=$i;
-		if(!isset($linka[$y]['num_sez'])) { $linka[$y]['num_sez']=0; $linka[$y]['elettori']=0;}
-		$z=$linka[$y]['num_sez'];
-		$ar[$z]['numsez']=$linka[$y]['num_sez'];
-		$ar[$z]['elettori']=number_format($linka[$y]['elettori'],0,',','.');
-		$tot_compl+=$linka[$y]['elettori'];
-		$tot_u+=$linka[$y]['maschi'];
-		$tot_d+=$linka[$y]['femmine'];
-
-
-	}
-	$ar[0][1]="<b>".number_format($tot_compl,0,',','.')."</b>";
-
-	$ar['perc'][1]=" ";
-
-	$perc_u=0;$perc_d=0;$perc_c=0;
-	$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";
-	$resril = $dbi->prepare("$sql");
-	$resril->execute();
-	$num_ril= $resril->rowCount();  //numero delle rilevazioni previste
-        if(!isset($html)) $html='';
-	$html .= "<table class=\"td-89\">";
-	$html .= "<tr class=\"bggray\"><td class=\"\">"._SEZIONI."</td><td>"._ISCR_SEZ."</td>";
-
-		$sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
-		$resuo = $dbi->prepare("$sql");
-		$resuo->execute();
-		list($ultora,$ultdata)=$resuo->fetch(PDO::FETCH_NUM);
-		
-
-  	$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";
-	$ressomma = $dbi->prepare("$sql");
-	$ressomma->execute();
-
-
-$perc_u=array(); $perc_d=array(); $perc_c=array();
-	while (list($data,$ora,$somma,$votiu,$votid) = $ressomma->fetch(PDO::FETCH_NUM)) {
-		$perc_u[$data.$ora]=0;
-		$perc_d[$data.$ora]=0;
-		$perc_c[$data.$ora]=0;
-		if($votiu or $votid)
-#		if(($data==$ultdata) and ($ora==$ultora))
-		{
-			$tot[$data.$ora]="<table style=\"width:180px;\"><tr class=\"bggray2\"><td style=\"width:33%;text-align:center;\">
-			<b>".number_format($votiu,0,',','.')."</b></td><td style=\"width:33%;text-align:center;\">
-			<b>".number_format($votid,0,',','.')."</b></td><td style=\"width:33%;text-align:center;\">
-			<b>".number_format($somma,0,',','.')."</b></td>
-			</tr></table>";
-			$perc_u[$data.$ora]=number_format($votiu*100/$tot_u,2);
-			$perc_d[$data.$ora]=number_format($votid*100/$tot_d,2);
-			$perc_c[$data.$ora]=number_format($somma*100/$tot_compl,2);
-		}
-		else
-			$tot[$data.$ora]=$somma;
-	}
-	$ud=0;$ora_rif="";
-	while (list($data1,$ora1) = $resril->fetch(PDO::FETCH_NUM)) 
-	{
-		$ud++;	
-		list($hour, $minute, $second) = explode(":", $ora1);
-		$ora_ril=$hour.":".$minute;
-		$html .= "<td"; 
-		if ($ud==$num_ril and (isset($perc_u[$data1.$ora1]) or isset($perc_d[$data1.$ora1]))) {$ora_rif="$data1.$ora1";}
-		$html .= ">";
-		$data_a=form_data($data1);
-		$html .= "".$data_a."<br />"._ORE." ".$ora_ril;
-		$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";
-		$resaff = $dbi->prepare("$sql");
-		$resaff->execute();
-		list($num_scr) = $resaff->fetch(PDO::FETCH_NUM);  //numero delle sezioni inserite
-		$html .= "<br />"._SEZIONI." $num_scr "._SU." $num_sez";
-##		if ($ud==$num_ril and ($perc_u or $perc_d)) $html .= "<br />
-		if (isset($perc_u[$data1.$ora1]) or isset($perc_d[$data1.$ora1])) $html .= "<br />
-		
-		<table style=\"width:180px;\"><tr class=\"bggray\">
-		<th style=\"width:28%;text-align:center;\">"._UOMINI."</th>
-		<th style=\"width:28%;text-align:center;\">"._DONNE."</th>
-		<th style=\"width:28%;text-align:center;\">"._COMPLESSIVI."</th>
-		</tr></table>";
-		
-		$html .= "</td>";
-
-	if (isset($tot[$data1.$ora1])){
-##		if ($ora_rif=="$data1.$ora1")
-if (($perc_u[$data1.$ora1] or $perc_d[$data1.$ora1]))		{
-			$ar['perc'][$data1.$ora1]="<table style=\"width:180px;\"><tr class=\"bggray2\">
-			<td style=\"width:33%;text-align:center;\"><b><i><span class=\"red\">".$perc_u[$data1.$ora1]."%</span></i></b></td>
-			<td style=\"width:33%;text-align:center;\"><b><i><span class=\"red\">".$perc_d[$data1.$ora1]."%</span></i></b></td>
-			<td style=\"width:33%;text-align:center;\" ><span class=\"red\"><b><i>".$perc_c[$data1.$ora1]."%</i></b></span></td>
-			</tr></table>";
-			$ar[0][$data1.$ora1]=$tot[$data1.$ora1];
-		}
-		else
-		{
-			$ar['perc'][$data1.$ora1]="<b><span class=\"red\"><i>
-			".number_format($tot[$data1.$ora1]*100/$tot_compl,2)."%</i></span></b>";
-			$ar[0][$data1.$ora1]="<b>".(number_format($tot[$data1.$ora1],0,',','.'))."</b>";
-		}
-
-		if (intval(preg_match('/[1-9]/',$tot[$data1.$ora1]))>0) {
-#foreach($ar[['num_sez'] as $i)
-##########
-  	$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 ";
-	$resvoti = $dbi->prepare("$sql");
-	$resvoti->execute();
-
-###########
-#		for ($i=$sez_da;$i<=$sez_a;$i++)
-		while (list($i)=$resvoti->fetch(PDO::FETCH_NUM))
-			{
-				$ar[$i][$data1.$ora1]="<span style=\"color: rgb(255, 0, 0);\">non rilevata</span>";
-			}
-		}
-	}
-	}
-  	$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 ";
-	$resvoti = $dbi->prepare("$sql");
-	$resvoti->execute();
-	$ud=0;
-	while (list($data,$ora,$numsez,$uomini,$donne,$complessivi) = $resvoti->fetch(PDO::FETCH_NUM)) {
-#		if ($ora_rif=="$data.$ora")
-		if(($uomini+$donne)>0)
-			$ar[$numsez][$data.$ora]="<table style=\"width:180px;\"><tr class=\"bggray2\">
-			<td style=\"width:33%;text-align:center;\">$uomini</td>
-			<td style=\"width:33%;text-align:center;\">$donne</td>
-			<td style=\"width:33%;text-align:center;\">$complessivi</td>
-			</tr></table>";
-		else
-			$ar[$numsez][$data.$ora]=$complessivi;
-	}
-    $html .= "</tr>";
-
-	foreach ($ar as $i => $arr) {
-		$html .= "<tr class=\"bggray2\">";
-		foreach ($arr as $valore)
-		{
-		
-			$html .= "<td class=\"bggray2\" style=\"text-align:center;\">$valore</td>";
-		}
-		$html .= "</tr>";
-	}
-
-	
-	     
-	     $html .= "</table>";
-		
-	     if($genere==0){ //se e' referendum
-        #'Pagina precedente' e 'Pagina Successiva'
-	if ($xls!='1' && $pdf!='1' && $csv!='1'){
-	$html .= "<div class=\"modulo\">";
-	    $cur=$num_ref;
-        if ($cur>1) {
-		
-              	$num_ref--;
-			  $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\">";
-              	$html .= "[ <b>"._PREV_MATCH."</b> ] </a>";
-        }
-        if ($cur<$num_refs) {
-	        $cur++;        
-			$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\">";
-            $html .= "[ <b>"._NEXT_MATCH."</b> ] </a>";
-        }
-	$html .= "</div>";
-	}
-}
-	
-if(!isset($style)) $style='';	
-if($csv==1){
-      $data=date("d-m-y G:i");
-      $style .="\t\t\n<br/><br/><br/><div style=\"margin:0px auto;text-align:center;\"><i>Stampato: $data</i></div>";
-      $style .="<br/><div style=\"text-align:center;\"><i>Eleonline by luciano apolito e roberto gigli - www.eleonline.it</i></div>";		
-      $style .= "<br/>  ";	
-      
-}	
-//$html .= "</div>";
-
+include('affluenze-inc.php');
 
 ############### stampa
 if ($xls!='1' && $pdf!='1'){
-      echo "$datipdf $html $style";
-
+    echo "$datipdf $html $style";
 }elseif($xls=="1"){
 	$nomefile="affluenze.xls";
@@ -372,15 +32,14 @@
 	echo "$html \t\n $style";
 }elseif($pdf=='1'){
-		$nomefile="$descr_cons affluenze.pdf";
-		
-		$stampa ="$datipdf $html $style";
-		
+	$nomefile="$descr_cons affluenze.pdf";	
+	$stampa ="$datipdf $html $style";
+	if($vismf)		
+		$html2pdf = new Html2Pdf('L','A4', 'it');
+	else
 		$html2pdf = new Html2Pdf('P','A4', 'it');
-		$html2pdf->WriteHTML($stampa, isset($_GET['vuehtml']));
-		$html2pdf->Output($nomefile);
+	$html2pdf->WriteHTML($stampa, isset($_GET['vuehtml']));
+	$html2pdf->Output($nomefile);
 }
+if($csv!=1 ) include ("footer.php");
 
-
-if($csv!=1 ) include ("footer.php");
-  
 ?>
Index: trunk/client/modules/Elezioni/affluenzephp5.php
===================================================================
--- trunk/client/modules/Elezioni/affluenzephp5.php	(revision 375)
+++ trunk/client/modules/Elezioni/affluenzephp5.php	(revision 376)
@@ -4,5 +4,5 @@
 /* by Luciano Apolito & Roberto Gigli                                   */
 /* http://www.eleonline.it                                              */
-/* info@eleonline.it  luciano@aniene.net rgigli@libero.it               */
+/* info@eleonline.it rgigli@libero.it                                   */
 /************************************************************************/
 
@@ -13,350 +13,9 @@
 require_once('inc/hpdf403/html2pdf.class.php');
 
-if (isset($param['id_cons_gen'])) $id_cons_gen=intval($param['id_cons_gen']); else $id_cons_gen='';
-if (isset($param['num_ref'])) $num_ref=intval($param['num_ref']);
-if (isset($param['num_refs'])) $num_refs=intval($param['num_refs']);
-if (isset($param['id_comune'])) $id_comune=intval($param['id_comune']);
-if (isset($param['xls'])) $xls=intval($param['xls']);
-if (isset($param['pdf'])) $pdf=intval($param['pdf']);
-$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'";
-$res = $dbi->prepare("$sql");
-$res->execute();
-list($tipo_cons,$genere,$id_cons) = $res->fetch(PDO::FETCH_NUM);
-global $lang,$circo,$id_circ;
-
-if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
-else $circos=''; 
-
-# testata
-include_once("modules/Elezioni/language/lang-$lang.php");
-if($csv==1){
-	include_once("modules/Elezioni/funzioni.php");
-	
-	$sql="SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-	list($descr_com) = $res->fetch(PDO::FETCH_NUM);
-        $descr_com =stripslashes($descr_com); 
-	$datipdf .= "<div style=\"margin:0px auto; text-align:center;\">";
-	$siteistat=$id_comune;
-	# salva sull'hardisk lo stemma del comune
-	$logo=verificasimbolo();
-	$immagine= "<img src=\"modules/Elezioni/images/$logo\" alt=\"logo\" align=\"left\"/>";
-
-	if($xls!=1) $datipdf .= "<table><tr><td>$immagine</td><td>";
-	
-        $datipdf .= ""._COMUNE." $descr_com <br />
-	"._RISULTA." "._CONSULTA."<br/ >";
-	$datipdf .= "$descr_cons<br />"._DISCLAIMER."
-        <br /><b>"._DETTAGLIO."  "._AFFLUENZE."</b>";
-	if($xls!=1) $datipdf .=  "</td></tr></table>";
-	$datipdf .="</div>";
-
-	$html = "<style type=\"text/css\">
-	<!--
-
-	.td-89 {
-	width: 89%;	
-	border: 1px;
-	text-align: left; 
-	}
-	.td-vuoto {
-		
-	width: 100%;	
-	border: 1px;
-	text-align: left; 
-	
-}
-
-
-	.td-5 {
-	
-	margin: 0px 0 0 0px;
-	width: 5%;	
-	/*border: none;*/
-	padding: 0px;
-        
-	text-align: center; 
-	}	
-
-
-
-	.bggray 	{
-		background: #ffffff; 
-		FONT-SIZE: 13px; 
-		FONT-FAMILY: Helvetica;
-		border: 1px;
-	}
-
-	.bggray2 	{
-		background: #EFEFEF; 
-		FONT-SIZE: 13px; 
-		FONT-FAMILY: Helvetica;
-		border: 1px;
-		}
-	-->
-	</style>";
-
-
-
-
-}
-	
-      
-
-
-
-
-    
-	// referendum
-	
-	$posref='';
-	if (!IsSet($num_ref)) { 
-		$num_ref=1;
-		$sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons'";
-		$resg = $dbi->prepare("$sql");
-		$resg->execute();
-		$num_refs= $resg->rowCount(); //quante pagine?
-	}	
-	if($genere=='0'){
-		$sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' and num_gruppo='$num_ref'";	
-		$resg = $dbi->prepare("$sql");
-		$resg->execute();
-		list($id_gruppo)=$resg->fetch(PDO::FETCH_NUM);
-	$posref="&amp;num_ref=$num_ref&amp;num_refs=$num_refs";
-	
-	}
-	// icone stampa e grafici
-	
-	if (!$csv){
-	if(!isset($html)) $html='';
-	$html .= "<div>
-	<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\">
-	"._VER_GRAF." <img class=\"image\" src=\"modules/Elezioni/images/grafici.png\" alt=\"\" /></a>
-	<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."
-	<img class=\"image\" src=\"modules/Elezioni/images/printer.png\" alt=\"\" /></a>
-	<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\">
-	<img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"\" /></a>
-<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\">
-	<img class=\"image\" src=\"modules/Elezioni/images/pdf.gif\" alt=\"\" /></a>
-
-	</div>
-
-	<h2><b>"._DETTAGLIO."  "._AFFLUENZE."</b></h2>";
-	  }  
-	
-	// descrizione
-	 if ($genere==0){
-	 $sql="select descrizione from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
-	$des = $dbi->prepare("$sql");
-	$des->execute();
-		list($descrizione)=$des->fetch(PDO::FETCH_NUM);
-	        if(!isset($html)) $html='';
-		$html .= "<div><h4>$descrizione</h4></div>";
-	}
-	
-	
-	$cond= $genere==0 ? "and t3.id_gruppo='$id_gruppo'" : "";
-	$i=1;
-	
-	
-	$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";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-	while ($linka[$i++] = $res->fetch(PDO::FETCH_BOTH));
-#	while (list($appo) = mysql_fetch_array($res)) {$i=$appo['num_sez']; $linka[$i] = $appo;echo "\nnum:$i:".$linka[$i]['num_sez'];}die();
-	$num_sez = $res->rowCount(); //numero totale delle sezioni
-	if (isset($linka[1]['num_sez']))  $sez_da=$linka[1]['num_sez']; else $sez_da=0;
-	$sez_a=$sez_da+$num_sez-1;
-	$tot_compl=0;$tot_u=0;$tot_d=0;
-//	$ar['riga1'][0]="<hr>";
-	$tot= array();
-	$ar[0][0]="<b>TOTALI</b>";
-	$ar['perc'][0]="Perc.";
-//	$ar['riga2'][0]="<hr>";
-#	foreach($linka['num_sez'] as $i)
-$y=1;
-for ($i=$sez_da;$i<=$sez_a;$i++,$y++)	{	
-#		$ar[$i]['numsez']=$i;
-		if(!isset($linka[$y]['num_sez'])) { $linka[$y]['num_sez']=0; $linka[$y]['elettori']=0;}
-		$z=$linka[$y]['num_sez'];
-		$ar[$z]['numsez']=$linka[$y]['num_sez'];
-		$ar[$z]['elettori']=number_format($linka[$y]['elettori'],0,',','.');
-		$tot_compl+=$linka[$y]['elettori'];
-		$tot_u+=$linka[$y]['maschi'];
-		$tot_d+=$linka[$y]['femmine'];
-
-
-	}
-	$ar[0][1]="<b>".number_format($tot_compl,0,',','.')."</b>";
-
-	$ar['perc'][1]=" ";
-
-	$perc_u=0;$perc_d=0;$perc_c=0;
-	$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";
-	$resril = $dbi->prepare("$sql");
-	$resril->execute();
-	$num_ril= $resril->rowCount();  //numero delle rilevazioni previste
-        if(!isset($html)) $html='';
-	$html .= "<table class=\"td-89\">";
-	$html .= "<tr class=\"bggray\"><td class=\"\">"._SEZIONI."</td><td>"._ISCR_SEZ."</td>";
-
-		$sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
-		$resuo = $dbi->prepare("$sql");
-		$resuo->execute();
-		list($ultora,$ultdata)=$resuo->fetch(PDO::FETCH_NUM);
-		
-
-  	$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";
-	$ressomma = $dbi->prepare("$sql");
-	$ressomma->execute();
-
-
-$perc_u=array(); $perc_d=array(); $perc_c=array();
-	while (list($data,$ora,$somma,$votiu,$votid) = $ressomma->fetch(PDO::FETCH_NUM)) {
-		$perc_u[$data.$ora]=0;
-		$perc_d[$data.$ora]=0;
-		$perc_c[$data.$ora]=0;
-		if($votiu or $votid)
-#		if(($data==$ultdata) and ($ora==$ultora))
-		{
-			$tot[$data.$ora]="<table style=\"width:180px;\"><tr class=\"bggray2\"><td style=\"width:33%;text-align:center;\">
-			<b>".number_format($votiu,0,',','.')."</b></td><td style=\"width:33%;text-align:center;\">
-			<b>".number_format($votid,0,',','.')."</b></td><td style=\"width:33%;text-align:center;\">
-			<b>".number_format($somma,0,',','.')."</b></td>
-			</tr></table>";
-			$perc_u[$data.$ora]=number_format($votiu*100/$tot_u,2);
-			$perc_d[$data.$ora]=number_format($votid*100/$tot_d,2);
-			$perc_c[$data.$ora]=number_format($somma*100/$tot_compl,2);
-		}
-		else
-			$tot[$data.$ora]=$somma;
-	}
-	$ud=0;$ora_rif="";
-	while (list($data1,$ora1) = $resril->fetch(PDO::FETCH_NUM)) 
-	{
-		$ud++;	
-		list($hour, $minute, $second) = explode(":", $ora1);
-		$ora_ril=$hour.":".$minute;
-		$html .= "<td"; 
-		if ($ud==$num_ril and ($perc_u[$data1.$ora1] or $perc_d[$data1.$ora1])) {$ora_rif="$data1.$ora1";}
-		$html .= ">";
-		$data_a=form_data($data1);
-		$html .= "".$data_a."<br />"._ORE." ".$ora_ril;
-		$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";
-		$resaff = $dbi->prepare("$sql");
-		$resaff->execute();
-		list($num_scr) = $resaff->fetch(PDO::FETCH_NUM);  //numero delle sezioni inserite
-		$html .= "<br />"._SEZIONI." $num_scr "._SU." $num_sez";
-##		if ($ud==$num_ril and ($perc_u or $perc_d)) $html .= "<br />
-		if (($perc_u[$data1.$ora1] or $perc_d[$data1.$ora1])) $html .= "<br />
-		
-		<table style=\"width:180px;\"><tr class=\"bggray\">
-		<th style=\"width:28%;text-align:center;\">"._UOMINI."</th>
-		<th style=\"width:28%;text-align:center;\">"._DONNE."</th>
-		<th style=\"width:28%;text-align:center;\">"._COMPLESSIVI."</th>
-		</tr></table>";
-		
-		$html .= "</td>";
-
-	if (isset($tot[$data1.$ora1])){
-##		if ($ora_rif=="$data1.$ora1")
-if (($perc_u[$data1.$ora1] or $perc_d[$data1.$ora1]))		{
-			$ar['perc'][$data1.$ora1]="<table style=\"width:180px;\"><tr class=\"bggray2\">
-			<td style=\"width:33%;text-align:center;\"><b><i><span class=\"red\">".$perc_u[$data1.$ora1]."%</span></i></b></td>
-			<td style=\"width:33%;text-align:center;\"><b><i><span class=\"red\">".$perc_d[$data1.$ora1]."%</span></i></b></td>
-			<td style=\"width:33%;text-align:center;\" ><span class=\"red\"><b><i>".$perc_c[$data1.$ora1]."%</i></b></span></td>
-			</tr></table>";
-			$ar[0][$data1.$ora1]=$tot[$data1.$ora1];
-		}
-		else
-		{
-			$ar['perc'][$data1.$ora1]="<b><span class=\"red\"><i>
-			".number_format($tot[$data1.$ora1]*100/$tot_compl,2)."%</i></span></b>";
-			$ar[0][$data1.$ora1]="<b>".(number_format($tot[$data1.$ora1],0,',','.'))."</b>";
-		}
-
-		if (intval(preg_match('/[1-9]/',$tot[$data1.$ora1]))>0) {
-#foreach($ar[['num_sez'] as $i)
-##########
-  	$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 ";
-	$resvoti = $dbi->prepare("$sql");
-	$resvoti->execute();
-
-###########
-#		for ($i=$sez_da;$i<=$sez_a;$i++)
-		while (list($i)=$resvoti->fetch(PDO::FETCH_NUM))
-			{
-				$ar[$i][$data1.$ora1]="<span style=\"color: rgb(255, 0, 0);\">non rilevata</span>";
-			}
-		}
-	}
-	}
-  	$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 ";
-	$resvoti = $dbi->prepare("$sql");
-	$resvoti->execute();
-	$ud=0;
-	while (list($data,$ora,$numsez,$uomini,$donne,$complessivi) = $resvoti->fetch(PDO::FETCH_NUM)) {
-#		if ($ora_rif=="$data.$ora")
-		if(($uomini+$donne)>0)
-			$ar[$numsez][$data.$ora]="<table style=\"width:180px;\"><tr class=\"bggray2\">
-			<td style=\"width:33%;text-align:center;\">$uomini</td>
-			<td style=\"width:33%;text-align:center;\">$donne</td>
-			<td style=\"width:33%;text-align:center;\">$complessivi</td>
-			</tr></table>";
-		else
-			$ar[$numsez][$data.$ora]=$complessivi;
-	}
-    $html .= "</tr>";
-
-	foreach ($ar as $i => $arr) {
-		$html .= "<tr class=\"bggray2\">";
-		foreach ($arr as $valore)
-		{
-		
-			$html .= "<td class=\"bggray2\" style=\"text-align:center;\">$valore</td>";
-		}
-		$html .= "</tr>";
-	}
-
-	
-	     
-	     $html .= "</table>";
-		
-	     if($genere==0){ //se e' referendum
-        #'Pagina precedente' e 'Pagina Successiva'
-	if ($xls!='1' && $pdf!='1' && $csv!='1'){
-	$html .= "<div class=\"modulo\">";
-	    $cur=$num_ref;
-        if ($cur>1) {
-		
-              	$num_ref--;
-			  $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\">";
-              	$html .= "[ <b>"._PREV_MATCH."</b> ] </a>";
-        }
-        if ($cur<$num_refs) {
-	        $cur++;        
-			$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\">";
-            $html .= "[ <b>"._NEXT_MATCH."</b> ] </a>";
-        }
-	$html .= "</div>";
-	}
-}
-	
-if(!isset($style)) $style='';	
-if($csv==1){
-      $data=date("d-m-y G:i");
-      $style .="\t\t\n<br/><br/><br/><div style=\"margin:0px auto;text-align:center;\"><i>Stampato: $data</i></div>";
-      $style .="<br/><div style=\"text-align:center;\"><i>Eleonline by luciano apolito &amp roberto gigli - www.eleonline.it</i></div>";		
-      $style .= "<br/>  ";	
-      
-}	
-//$html .= "</div>";
-
+include('affluenze-inc.php');
 
 ############### stampa
 if ($xls!='1' && $pdf!='1'){
-      echo "$datipdf $html $style";
-
+    echo "$datipdf $html $style";
 }elseif($xls=="1"){
 	$nomefile="affluenze.xls";
@@ -369,15 +28,14 @@
 	echo "$html \t\n $style";
 }elseif($pdf=='1'){
-		$nomefile="$descr_cons affluenze.pdf";
-		
-		$stampa ="$datipdf $html $style";
-		
+	$nomefile="$descr_cons affluenze.pdf";	
+	$stampa ="$datipdf $html $style";
+	if($vismf)		
+		$html2pdf = new Html2Pdf('L','A4', 'it');
+	else
 		$html2pdf = new Html2Pdf('P','A4', 'it');
-		$html2pdf->WriteHTML($stampa, isset($_GET['vuehtml']));
-		$html2pdf->Output($nomefile);
+	$html2pdf->WriteHTML($stampa, isset($_GET['vuehtml']));
+	$html2pdf->Output($nomefile);
 }
+if($csv!=1 ) include ("footer.php");
 
-
-if($csv!=1 ) include ("footer.php");
-  
 ?>
Index: trunk/client/modules/Elezioni/foto.php
===================================================================
--- trunk/client/modules/Elezioni/foto.php	(revision 375)
+++ trunk/client/modules/Elezioni/foto.php	(revision 376)
@@ -52,6 +52,6 @@
 
 // nessuno stemma immagine vuota
-if ($stemma=="" && is_readable('modules/Elezioni/images/vuoto.jpg')){
-	$stemma =  fread( fopen( 'modules/Elezioni/images/vuoto.jpg', 'r' ), filesize( 'modules/Elezioni/images/vuoto.jpg' ) );}
+if ($stemma=="" && is_readable('modules/Elezioni/images/vuoto.png')){
+	$stemma =  fread( fopen( 'modules/Elezioni/images/vuoto.png', 'r' ), filesize( 'modules/Elezioni/images/vuoto.png' ) );}
 if(isset($pdf)) 
 {
Index: trunk/client/modules/Elezioni/funzioni.php
===================================================================
--- trunk/client/modules/Elezioni/funzioni.php	(revision 375)
+++ trunk/client/modules/Elezioni/funzioni.php	(revision 376)
@@ -448,5 +448,5 @@
 	global $prefix,$dbi,$id_comune,$ins_logo;
 	if($ins_logo=="0"){
-		$logo="vuoto.jpg";  //var nel config.php
+		$logo="vuoto.png";  //var nel config.php
 	}else{
 
Index: trunk/client/modules/Elezioni/votanti-inc.php
===================================================================
--- trunk/client/modules/Elezioni/votanti-inc.php	(revision 376)
+++ trunk/client/modules/Elezioni/votanti-inc.php	(revision 376)
@@ -0,0 +1,400 @@
+<?php
+/************************************************************************/
+/* Eleonline - Raccolta e diffusione dei dati elettorali                */
+/* by Luciano Apolito & Roberto Gigli                                   */
+/* http://www.eleonline.it                                              */
+/* info@eleonline.it rgigli@libero.it                                   */
+/************************************************************************/
+
+if (!defined('MODULE_FILE')) {
+    die ("You can't access this file directly...");
+}
+
+$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ?
+	$_GET : $_POST;
+
+$id_comune= (isset($param['id_comune'])) ? $param['id_comune']:$siteistat;
+if (isset($param['id_cons_gen'])) $id_cons_gen=intval($param['id_cons_gen']); else $id_cons_gen='';
+if (isset($param['op'])) $op=$param['op']; else $op='';
+if (isset($param['minsez'])) $minsez=intval($param['minsez']); else $minsez='';
+if (isset($param['id_lista'])) $id_lista=intval($param['id_lista']); else $id_lista='';
+if (isset($param['id_circ'])) $id_circ=intval($param['id_circ']); else $id_circ='';
+if (isset($param['csv'])) $csv=intval($param['csv']); else $csv='';
+if (isset($param['min'])) $min=intval($param['min']); else $min= 0;
+if (isset($param['orvert'])) $orvert=intval($param['orvert']); else $orvert='';
+if (isset($param['offset'])) $offset=intval($param['offset']); else $offset='';
+if (isset($param['offsetsez'])) $offsetsez=intval($param['offsetsez']); else $offsetsez='';
+if (isset($param['perc'])) $perc=$param['perc']; else $perc='';
+if (isset($param['info'])) $info=addslashes($param['info']); else $info='';
+if (isset($param['files'])) $files=addslashes($param['files']); else $files='';
+if (isset($param['voti_lista'])) $voti_lista=intval($param['voti_lista']); else $voti_lista= 0;
+if (isset($param['perc_lista'])) $perc_lista=$param['perc_lista']; else $perc_lista= 0;
+if (isset($param['lettera'])) $lettera=addslashes($param['lettera']); else $lettera='';
+if (isset($param['id_gruppo'])) $id_gruppo=intval($param['id_gruppo']); else $id_gruppo='';
+if (isset($param['tipo_cons'])) $tipo_cons=intval($param['tipo_cons']); else $tipo_cons='';
+if (isset($param['xls'])) $xls=intval($param['xls']); else $xls='';
+if (isset($param['pdf'])) $pdf=intval($param['pdf']); else $pdf='';
+
+# anti-xss nov. 2009 
+$id_comune=htmlentities($id_comune);
+$perc=floatval($perc);
+$perc_lista=floatval($perc_lista);
+#$datipdf= htmlentities($datipdf);
+$op= htmlentities($op);
+$info= htmlentities($info);
+$files=htmlentities($files);
+$lettera=htmlentities($lettera);
+$id_comune=intval($id_comune);
+
+//$id_cons_gen=$_GET['id_cons_gen'];
+$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'" ;
+$res = $dbi->prepare("$sql");
+$res->execute();
+list($tipo_cons,$genere,$id_cons) = $res->fetch(PDO::FETCH_NUM);
+if (isset($param['ops'])) $ops=$param['ops']; else $ops='';
+if (isset($param['pag'])) $pag=$param['pag']; else $pag=0;
+if (isset($param['num_ref'])) $num_ref=$param['num_ref'];
+if (isset($param['num_refs'])) $num_refs=$param['num_refs'];
+$bgcolor2='#cacaca';
+if (!IsSet($num_ref)) { 
+	$num_ref=1;
+	$sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons";
+	$resg = $dbi->prepare("$sql");
+	$resg->execute();
+	$num_refs= $resg->rowCount(); //quante pagine?
+}
+//**************************************************************************
+//        ELE
+//**************************************************************************
+//controllo_finale($id_cons);
+
+global $prefix, $dbi,$id_circ,$lang, $fascia, $limite, $votog;
+include_once("modules/Elezioni/language/lang-$lang.php");
+# testata
+$datipdf='';
+if($csv==1){
+	include_once("modules/Elezioni/funzioni.php");
+	$sql="SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
+	$res = $dbi->prepare("$sql");
+	$res->execute();
+	list($descr_com) = $res->fetch(PDO::FETCH_NUM);
+    $descr_com =stripslashes($descr_com); 
+	$datipdf .= "<div style=\"margin:0px auto; text-align:center;\">";
+	$siteistat=$id_comune;
+	# salva sull'hardisk lo stemma del comune    style=\"vertical-align: text-bottom;\"
+	$logo=verificasimbolo();
+	$immagine= "<img src=\"modules/Elezioni/images/$logo\" alt=\"logo\" align=\"left\"/>";
+	if($xls!=1) $datipdf .= "<table><tr><td>$immagine</td><td>";
+    $datipdf .= ""._COMUNE." $descr_com <br/>
+	"._RISULTA." "._CONSULTA."<br/>";
+	$datipdf .= "$descr_cons <br />"._DISCLAIMER."";
+	if($xls!=1) $datipdf .=  "</td></tr></table>";
+	$datipdf .="</div>";
+	$html = "<style type=\"text/css\">
+	<!--
+
+	.td-89 {
+		width: 89%;	
+		border: 1px;
+		text-align: left; 
+	}
+	.td-vuoto {
+		width: 100%;	
+		border: 1px;
+		text-align: left; 
+	}
+
+	.td-5 {
+		margin: 0px 0 0 0px;
+		width: 5%;	
+		/*border: none;*/
+		padding: 0px;
+		text-align: center; 
+	}	
+
+	.bgw	{
+		background: #ffffff; 
+		font-size: 13px; 
+		font-family: Helvetica;
+		text-align: right;
+	}
+
+	.bggray 	{
+		background: #ffffff; 
+		FONT-SIZE: 13px; 
+		FONT-FAMILY: Helvetica;
+		border: 1px;
+		text-align:right;
+	}
+
+	.bggray2 	{
+		background: #EFEFEF; 
+		FONT-SIZE: 13px; 
+		FONT-FAMILY: Helvetica;
+		border: 1px;
+		text-align:right;
+		}
+	-->
+	</style>";
+}
+// icone stampa e grafici   style=\"margin:0px auto;
+if ($csv!=1){
+	if(isset($num_ref)) $curref="&amp;num_ref=$num_ref"; else $curref='';
+	if (!isset($html)) $html='';
+	$html .= "<div>
+	<a href=\"modules.php?name=Elezioni&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;op=graf_votanti\">
+	"._VER_GRAF." <img class=\"image\" src=\"modules/Elezioni/images/grafici.png\" alt=\"\" /></a>
+	<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=votanti&amp;csv=1&amp;pag=$pag&amp;num_ref=$num_ref&amp;num_refs=$num_refs\">"._VER_STAMPA."
+	<img class=\"image\" src=\"modules/Elezioni/images/printer.png\" alt=\"\" /></a>
+	<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=votanti&amp;xls=1&csv=1;&amp;pag=$pag&amp;num_ref=$num_ref&amp;num_refs=$num_refs\">
+	<img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"\" /></a>
+	<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=votanti&amp;pdf=1&csv=1;&amp;pag=$pag&amp;num_ref=$num_ref&amp;num_refs=$num_refs\">
+	<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=votanti&amp;pdf=1&csv=1;&amp;pag=$pag$curref\">
+	<img class=\"image\" src=\"modules/Elezioni/images/pdf.gif\" alt=\"\" /></a>
+	</div>";
+}
+$sql="SELECT sum(maschi),sum(femmine) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'";
+$res = $dbi->prepare("$sql");
+$res->execute();
+list($totm,$totf) = $res->fetch(PDO::FETCH_NUM);
+$totel=$totm+$totf;
+if (!IsSet($pag)) {$pag=0;} //inizializza il numero di pagina 
+/*
+if (!IsSet($num_ref)) { 
+	$num_ref=1;
+	$resg = mysql_query("SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
+	$num_refs= mysql_num_rows($resg); //quante pagine?
+}
+*/
+if(($genere!=4) and $pag==0){ //diverso da liste a piu' candidati
+	$ops=4;	//gestione gruppi (anche liste uninominali)
+}else{
+	$ops=3; //gestione liste
+}
+$sql="SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref";
+$resg = $dbi->prepare("$sql");
+$resg->execute();
+list($idg,$numg) = $resg->fetch(PDO::FETCH_NUM);
+$sql="SELECT id_sez,num_sez,t1.id_sede as id_sede,t2.id_circ as id_circ FROM ".$prefix."_ele_sezioni as t1,".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez ";
+$res = $dbi->prepare("$sql");
+$res->execute();
+$max = $res->rowCount(); //quante sezioni?
+$sql="SELECT id_sez,num_sez,t1.id_sede as id_sede,t2.id_circ as id_circ FROM ".$prefix."_ele_sezioni as t1,".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez ";
+$res = $dbi->prepare("$sql");
+$res->execute();
+$num_sez = $res->rowCount(); //quante sezioni?
+for ($i=1;$i<=$num_sez;$i++){
+	$sezione[$i]=$res->fetch(PDO::FETCH_BOTH); //inizializza l'array delle sezioni
+	$ar[$i]=0;
+}
+$tab3="_ele_voti_lista";
+if ($genere>0) {  //se non e' un referendum
+	if (!($genere==4) and $pag==0){  //se non e' una lista uninominale ed e' la prima pagina
+		$tab="SELECT 0,t2.id_sez,t2.num_sez,t2.validi,'0','0',t2.validi,t2.nulli,t2.bianchi,t2.contestati, t4.id_circ,t2.id_sede,'0',t2.voti_nulli FROM ".$prefix."_ele_sezioni as t2 left join ".$prefix."_ele_sede as t4 on (t2.id_sede=t4.id_sede) where t2.id_cons='$id_cons' and t2.validi+t2.nulli+t2.bianchi+t2.contestati>0 group by t2.id_sez,t2.num_sez,t2.validi,t2.nulli,t2.bianchi,t2.contestati, t4.id_circ,t2.id_sede,t2.voti_nulli order by t2.num_sez ";
+	}else{ // e' una lista uninominale o la seconda pagina
+		# voto disgiunto regione sicilia aggiunge il campo solo lista
+		if(isdisgiunto()){
+		$tab="SELECT '0',t1.id_sez,t1.num_sez,sum(t2.voti),t1.solo_gruppo,t1.solo_lista,t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t1.id_sede,'0',t1.voti_nulli
+		FROM ".$prefix."_ele_sezioni as t1 left join ".$prefix.$tab3." as t2 on (t1.id_sez=t2.id_sez)
+		left join ".$prefix."_ele_sede as t4 on (t1.id_sede=t4.id_sede)
+		where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons group by t1.id_sez,t1.num_sez,t1.solo_gruppo,t1.solo_lista,t1.validi,t1.nulli,t1.bianchi,t1.contestati,t4.id_circ,t1.id_sede,t1.voti_nulli order by t1.num_sez ";
+		}else{
+		$tab="SELECT '0',t1.id_sez,t1.num_sez,sum(t2.voti),t1.solo_gruppo,'0',t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t1.id_sede,'0',t1.voti_nulli
+		FROM ".$prefix."_ele_sezioni as t1 left join ".$prefix.$tab3." as t2 on (t1.id_sez=t2.id_sez)
+		left join ".$prefix."_ele_sede as t4 on (t1.id_sede=t4.id_sede)
+		where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons group by t1.id_sez,t1.num_sez,t1.solo_gruppo,t1.validi,t1.nulli,t1.bianchi,t1.contestati,t4.id_circ,t1.id_sede,t1.voti_nulli order by t1.num_sez ";
+		}
+	}
+	$riga1 = "";
+	if($pag==0)$riga1 .="<div style=\"text-align: center;\"><h2>"._DETTAGLIO." "._VOTIE."</h2></div>";
+	else $riga1 .="<h4>"._DETTAGLIO." "._VOTIE." "._ASOLA_LISTA."</h4>";
+}else{ // e' un referendum --> t3.id_gruppo vuota per allineare il while (da rifare con array)
+	$tab="SELECT t1.id_gruppo,t1.id_sez,t2.num_sez,t1.si,t1.no,'0',t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t2.id_sede,t3.num_gruppo,'0'
+	FROM ".$prefix."_ele_voti_ref as t1 left join ".$prefix."_ele_sezioni as t2 on (t1.id_sez=t2.id_sez)
+	left join  ".$prefix."_ele_gruppo as t3 on (t1.id_gruppo=t3.id_gruppo) left join ".$prefix."_ele_sede as t4 on (t2.id_sede=t4.id_sede)
+	where t1.id_cons='$id_cons' and t1.id_gruppo='$idg' order by t2.num_sez ";
+	$riga1  = "<div style=\"margin:0px auto;text-align:center;\">";
+	$riga1  .="<h2>"._DETTAGLIO." "._VOTIE."</h2></div>";
+	$sql="select descrizione from ".$prefix."_ele_gruppo where id_gruppo='$idg'";
+	$des = $dbi->prepare("$sql");
+	$des->execute();
+	list($descrizione)=$des->fetch(PDO::FETCH_BOTH);
+	$riga1 .="<h4>$descrizione</h4>";
+}
+$sql="$tab ";
+$res = $dbi->prepare("$sql");
+$res->execute();
+$num_scr = $res->rowCount();
+//$riga2= "<div>"._SEZSCR." $num_scr su $num_sez</div>";//sezioni scrutinate
+$riga2 = "<table style=\"border:1px solid #6A6A6A;\" summary=\"Tabella dei voti espressi\">";
+$riga3 = "<tr class=\"bggray2\">
+<td>"._SEZIONI."</td>
+<td>"._VOTIU."</td>
+<td>"._VOTID."</td>
+<td>"._VOTIE."</td>"; //testata con nomi dei campi
+if ($genere==0) {  //se e' un referendum
+	$riga3 .= "<td>"._SI."</td><td>"._NO."</td>";
+} elseif ((($genere==5) or ($genere==3)) and $pag==1){
+	$riga3 .= "<td>Voti "._LISTE."</td>";
+	if(isdisgiunto()){
+		$riga3 .= "<td>Voti "._PRESI."</td>";
+		$riga3 .= "<td>"._SOLO_LISTA."</td>";
+	} // voto disgiunto
+	if (!$votog) $riga3 .= "<td>"._ASOLO_GRUPPO."</td>";
+}
+$riga3 .= "<td>"._VALIDI."</td><td>"._NULLI."</td><td>"._BIANCHI."</td><td>"._CONTESTATI."</td>"
+."</tr>\n";
+$sql="$tab ";
+$res = $dbi->prepare("$sql");
+$res->execute();
+$num_scr = $res->rowCount();
+$righe= "";
+$scrutinate=1;
+$tot_u=0;$tot_d=0;$tot_voti=0; $tot_si=0;$tot_no=0;$tot_validi=0;$tot_nulli=0;$tot_bianchi=0;$tot_contestati=0;
+$tot_sololista=0;$tot_gruppo=0;
+#$si e $no sono valide anche per voti lista e solo gruppo per i non referendum
+while (list($id_gruppo,$id,$num,$si,$no,$sololista,$validi,$nulli,$bianchi,$contestati,$id_circ,$id_sede,$gruppo,$votinulli) = $res->fetch(PDO::FETCH_NUM)){
+	$nulli+=$votinulli;
+	// inserimento numeri di sez non scrutinate
+	while ($scrutinate < $num) { 
+		$righe.= "<tr><td><span style=\"color: rgb(255, 0, 0);\">$scrutinate</span></td></tr>\n";
+		$scrutinate++;
+	}
+	# voti sindaco, gruppo o presidente
+	$tab5="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id'";
+	$sql="$tab5";
+	$res3 = $dbi->prepare("$sql");
+	$res3->execute();
+	list($sindaco) = $res3->fetch(PDO::FETCH_NUM);	
+	$scrutinate++; 
+	// fine inserimento	
+	$tab2="SELECT max(voti_donne),max(voti_uomini),max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id'";
+	if ($genere==0) $tab2 .= " and id_gruppo=$id_gruppo";
+	$sql=$tab2;
+	$res2 = $dbi->prepare("$sql");
+	$res2->execute();
+	list($votid,$votiu,$voti) = $res2->fetch(PDO::FETCH_NUM);
+//		$voti=$votiu+$votid;
+	$tot_gruppo+=$sindaco;
+	$tot_u+=$votiu;
+	$tot_d+=$votid;
+	$tot_voti+=$voti;
+	$tot_si+=$si;
+	$tot_no+=$no;
+	$tot_validi+=$validi;
+	$tot_nulli+=$nulli;
+	$tot_bianchi+=$bianchi;
+	$tot_contestati+=$contestati;
+	$tot_sololista+=$sololista;
+	if($num % 2)
+		$righe .= "<tr class=\"bgw\">";
+	else
+		$righe .= "<tr class=\"bggray2\">";
+	$righe .= "<td>$num</td>
+	<td>".number_format($votiu,0,',','.')."</td>
+	<td>".number_format($votid,0,',','.')."</td>
+	<td>".number_format($voti,0,',','.')."</td>";
+	if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){
+		$righe .= "<td>".number_format($si,0,',','.')."</td>";
+		if(isdisgiunto()){
+			$righe .= "<td>".number_format($sindaco,0,',','.')."</td>";
+			$righe .= "<td>".number_format($sololista,0,',','.')."</td>";
+		}
+		if (!$votog) $righe .= "<td>".number_format($no,0,',','.')."</td>";	
+	}
+	$righe .= "<td>".number_format($validi,0,',','.')."</td>
+	<td>$nulli</td>
+	<td>$bianchi</td>
+	<td>$contestati</td></tr>";
+}
+if ($num<$num_sez) {
+	for (;$scrutinate<=$num_sez;$scrutinate++) {
+		$righe .= "<tr><td>";
+		$righe .="<span style=\"color: rgb(255, 0, 0);\">$scrutinate</span></td></tr>";
+	}
+}
+$righet='';
+if($num_scr){
+	$righet = "<tr class=\"bggray\">
+	<td ></td>
+	<td>"._VOTIU."</td>
+	<td>"._VOTID."</td>
+	<td>"._VOTIE."</td>"; //testata con nomi dei campi
+	if ($genere==0) {  //se e' un referendum
+		$righet .= "<td>"._SI."</td><td>"._NO."</td>";
+	} elseif ((($genere==5) or ($genere==3)) and $pag==1){
+		$righet .= "<td>Voti "._LISTE."</td>";
+		if(isdisgiunto()){
+			$righet .= "<td>Voti "._PRESI."</td>";
+			$righet .= "<td>"._SOLO_LISTA."</td>";
+		} // voto disgiunto	
+		if (!$votog) $righet .= "<td>"._ASOLO_GRUPPO."</td>";		
+	}
+	if($totel==0) $totelrip="0.00"; else $totelrip=number_format($tot_voti*100/$totel,2);
+	if($totf==0) $totfrip="0.00"; else $totfrip=number_format($tot_d*100/$totf,2);
+	if($totm==0) $totmrip="0.00"; else $totmrip=number_format($tot_u*100/$totm,2);
+	$righet .= "<td>"._VALIDI."</td><td>"._NULLI."</td><td>"._BIANCHI."</td><td>"._CONTESTATI."</td>"
+	."</tr><tr class=\"bgw\"><td><b>"._TOT."</b></td><td><b>".number_format($tot_u,0,',','.')."</b><br /><i>(".$totmrip."%)</i></td><td><b>".number_format($tot_d,0,',','.')."</b><br /><i>(".$totfrip."%)</i></td><td><b>".number_format($tot_voti,0,',','.')."</b><br /><i>(".$totelrip."%)</i></td>";
+		// se e' un referendum o una consultazione con raggruppamenti
+	if($tot_validi){
+		if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){
+			$righet .= "<td><b>".number_format($tot_si,0,',','.')."</b><br /><i>(".number_format($tot_si*100/$tot_validi,2)."%)</i></td>";
+			if(isdisgiunto()){
+				$righet .="<td><b>".number_format($tot_gruppo,0,',','.')."</b><br /><i>(".number_format($tot_gruppo*100/$tot_validi,2)."%)</i></td>";
+				$righet .="<td><b>".number_format($tot_sololista,0,',','.')."</b><br /><i>(".number_format($tot_sololista*100/$tot_validi,2)."%)</i></td>";
+			}
+			if(!$votog) $righet .="<td><b>".number_format($tot_no,0,',','.')."</b><br /><i>(".number_format($tot_no*100/$tot_validi,2)."%)</i></td>";	
+		}
+		$righet .= "<td><b>".number_format($tot_validi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_validi*100/$tot_voti,2):'0.00')."%)</i></td><td><b>"
+		.number_format($tot_nulli,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_nulli*100/$tot_voti,2):'0.00')."%)</i></td><td><b>".number_format($tot_bianchi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_bianchi*100/$tot_voti,2):'0.00')."%)</i></td><td><b>".number_format($tot_contestati,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_contestati*100/$tot_voti,2):'0.00')."%)</i></td></tr>";
+	}else{
+		if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){
+			$righet .= "<td><b>".number_format($tot_si,0,',','.')."</b><br /><i>(0.00%)</i></td><td><b>".number_format($tot_no,0,',','.')."</b><br /><i>(0.00%)</i></td>";
+		}
+		$righet .= "<td><b>0</b><br /><i>(0.00%)</i></td><td><b>"
+		.number_format($tot_nulli,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_nulli*100/$tot_voti,2):'0,00')."%)</i></td><td><b>".number_format($tot_bianchi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_bianchi*100/$tot_voti,2):'0,00')."%)</i></td><td><b>".number_format($tot_contestati,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_contestati*100/$tot_voti,2):'0,00')."%)</i></td></tr>";
+	}
+}
+$righe .= "</table>";
+if(!isset($html)) $html='';
+$html .= "$riga1";
+$html .= $riga2."";
+$html .= $righet;
+$html .= $riga3;
+$html .= $righe;
+$html .="<div>";
+if($genere==0){ //se e' referendum
+	if ($xls!='1' && $pdf!='1' && $csv!='1'){
+		#'Pagina precedente' e 'Pagina Successiva'
+		$cur=$num_ref;
+		if ($cur>1) {
+			  $num_ref--;
+			  $html .= "<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=votanti&amp;num_ref=$num_ref&amp;num_refs=$num_refs&amp;csv=$csv&amp;xls=$xls&amp;pdf=$pdf\">";
+			  $html .= "[ <b>"._PREV_MATCH."</b> ]</a>";
+		}
+		if ($cur<$num_refs) {
+			$cur++;        
+			$html .= "<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=votanti&amp;num_ref=$cur&amp;num_refs=$num_refs&amp;csv=$csv&amp;xls=$xls&amp;pdf=$pdf\">";
+			
+			$html .= "[ <b>"._NEXT_MATCH."</b> ]</a>";
+		}
+	}
+}
+if($genere==5 or $genere==3){ //se vi sono raggruppamenti
+	if($csv!=1 and $fascia>$limite){
+		$pag=($pag==0 ? 1:0);
+		$html .= "<a href=\"modules.php?name=Elezioni&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;op=come&amp;info=votanti&amp;pag=$pag&amp;csv=$csv\"><b>";
+		if($pag) $html .=  _VOTIL;
+		   //_CONTR_CONS;
+		else $html .= _VOTIE; 
+		//_CONTR_ESPR;
+		$html .= "</b></a>";
+	}
+}
+if($csv==1){
+  $data=date("d-m-y G:i");
+  $html .="<br/><div style=\"margin:0 auto;text-align:center;\"><i>Stampato: $data</i>";
+  $html .="<br/><i>Eleonline by l. apolito & r. gigli - www.eleonline.it</i></div>";		
+}	
+$html .= "</div>";
+?>
Index: trunk/client/modules/Elezioni/votanti.php
===================================================================
--- trunk/client/modules/Elezioni/votanti.php	(revision 375)
+++ trunk/client/modules/Elezioni/votanti.php	(revision 376)
@@ -4,5 +4,5 @@
 /* by Luciano Apolito & Roberto Gigli                                   */
 /* http://www.eleonline.it                                              */
-/* info@eleonline.it  luciano@aniene.net rgigli@libero.it               */
+/* info@eleonline.it rgigli@libero.it                                   */
 /************************************************************************/
 
@@ -15,494 +15,9 @@
 use Spipu\Html2Pdf\Exception\ExceptionFormatter;
 
-$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ?
-	$_GET : $_POST;
-
-$id_comune= (isset($param['id_comune'])) ? $param['id_comune']:$siteistat;
-if (isset($param['id_cons_gen'])) $id_cons_gen=intval($param['id_cons_gen']); else $id_cons_gen='';
-if (isset($param['op'])) $op=$param['op']; else $op='';
-if (isset($param['minsez'])) $minsez=intval($param['minsez']); else $minsez='';
-if (isset($param['id_lista'])) $id_lista=intval($param['id_lista']); else $id_lista='';
-if (isset($param['id_circ'])) $id_circ=intval($param['id_circ']); else $id_circ='';
-if (isset($param['csv'])) $csv=intval($param['csv']); else $csv='';
-if (isset($param['min'])) $min=intval($param['min']); else $min= 0;
-if (isset($param['orvert'])) $orvert=intval($param['orvert']); else $orvert='';
-if (isset($param['offset'])) $offset=intval($param['offset']); else $offset='';
-if (isset($param['offsetsez'])) $offsetsez=intval($param['offsetsez']); else $offsetsez='';
-if (isset($param['perc'])) $perc=$param['perc']; else $perc='';
-if (isset($param['info'])) $info=addslashes($param['info']); else $info='';
-if (isset($param['files'])) $files=addslashes($param['files']); else $files='';
-if (isset($param['voti_lista'])) $voti_lista=intval($param['voti_lista']); else $voti_lista= 0;
-if (isset($param['perc_lista'])) $perc_lista=$param['perc_lista']; else $perc_lista= 0;
-if (isset($param['lettera'])) $lettera=addslashes($param['lettera']); else $lettera='';
-if (isset($param['id_gruppo'])) $id_gruppo=intval($param['id_gruppo']); else $id_gruppo='';
-if (isset($param['tipo_cons'])) $tipo_cons=intval($param['tipo_cons']); else $tipo_cons='';
-if (isset($param['xls'])) $xls=intval($param['xls']); else $xls='';
-if (isset($param['pdf'])) $pdf=intval($param['pdf']); else $pdf='';
-
-# anti-xss nov. 2009 
-$id_comune=htmlentities($id_comune);
-$perc=floatval($perc);
-$perc_lista=floatval($perc_lista);
-#$datipdf= htmlentities($datipdf);
-$op= htmlentities($op);
-$info= htmlentities($info);
-$files=htmlentities($files);
-$lettera=htmlentities($lettera);
-
-$id_comune=intval($id_comune);
-
-
-//$id_cons_gen=$_GET['id_cons_gen'];
-$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'" ;
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-
-list($tipo_cons,$genere,$id_cons) = $res->fetch(PDO::FETCH_NUM);
-
-if (isset($param['ops'])) $ops=$param['ops']; else $ops='';
-if (isset($param['pag'])) $pag=$param['pag']; else $pag=0;
-if (isset($param['num_ref'])) $num_ref=$param['num_ref'];
-if (isset($param['num_refs'])) $num_refs=$param['num_refs'];
-$bgcolor2='#cacaca';
-
-
-if (!IsSet($num_ref)) { 
-		$num_ref=1;
-		$sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons";
-		$resg = $dbi->prepare("$sql");
-		$resg->execute();
-
-		$num_refs= $resg->rowCount(); //quante pagine?
-	}
-
-
-
-//**************************************************************************
-//        ELE
-//**************************************************************************
-//controllo_finale($id_cons);
-
-global $prefix, $dbi,$id_circ,$lang, $fascia, $limite, $votog;
-
-include_once("modules/Elezioni/language/lang-$lang.php");
-# testata
-
-if($csv==1){
-	include_once("modules/Elezioni/funzioni.php");
-	
-	$sql="SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-
-	list($descr_com) = $res->fetch(PDO::FETCH_NUM);
-        $descr_com =stripslashes($descr_com); 
-	$datipdf .= "<div style=\"margin:0px auto; text-align:center;\">";
-	$siteistat=$id_comune;
-	# salva sull'hardisk lo stemma del comune    style=\"vertical-align: text-bottom;\"
-	$logo=verificasimbolo();
-	$immagine= "<img src=\"modules/Elezioni/images/$logo\" alt=\"logo\" align=\"left\"/>";
-
-	
-
-
-
-	if($xls!=1) $datipdf .= "<table><tr><td>$immagine</td><td>";
-        $datipdf .= ""._COMUNE." $descr_com <br/>
-	"._RISULTA." "._CONSULTA."<br/>";
-	$datipdf .= "$descr_cons <br />"._DISCLAIMER."";
-	if($xls!=1) $datipdf .=  "</td></tr></table>";
-	$datipdf .="</div>";
-	  
-
-$html = "<style type=\"text/css\">
-	<!--
-
-	.td-89 {
-	width: 89%;	
-	border: 1px;
-	text-align: left; 
-	}
-	.td-vuoto {
-		
-	width: 100%;	
-	border: 1px;
-	text-align: left; 
-	
-}
-
-
-	.td-5 {
-	
-	margin: 0px 0 0 0px;
-	width: 5%;	
-	/*border: none;*/
-	padding: 0px;
-        
-	text-align: center; 
-	}	
-
-
-
-	.bggray 	{
-		background: #ffffff; 
-		FONT-SIZE: 13px; 
-		FONT-FAMILY: Helvetica;
-		border: 1px;
-	}
-
-	.bggray2 	{
-		background: #EFEFEF; 
-		FONT-SIZE: 13px; 
-		FONT-FAMILY: Helvetica;
-		border: 1px;
-		}
-	-->
-	</style>";
-
-
-
-
-}
-	
-
-
-
-
-
-
-
-
-
-    
-    // icone stampa e grafici
-	if ($csv!=1){
-	if(isset($num_ref)) $curref="&amp;num_ref=$num_ref"; else $curref='';
-	if (!isset($html)) $html='';
-	$html .= "<div>
-	<a href=\"modules.php?name=Elezioni&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;op=graf_votanti\">
-	"._VER_GRAF." <img class=\"image\" src=\"modules/Elezioni/images/grafici.png\" alt=\"\" /></a>
-
-	 <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=votanti&amp;csv=1&amp;pag=$pag&amp;num_ref=$num_ref&amp;num_refs=$num_refs\">"._VER_STAMPA."
-
-	
-	<img class=\"image\" src=\"modules/Elezioni/images/printer.png\" alt=\"\" /></a>
-
-	<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=votanti&amp;xls=1&csv=1;&amp;pag=$pag&amp;num_ref=$num_ref&amp;num_refs=$num_refs\">
-
-	
-		<img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"\" /></a>
-
-<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=votanti&amp;pdf=1&csv=1;&amp;pag=$pag&amp;num_ref=$num_ref&amp;num_refs=$num_refs\">
-<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=votanti&amp;pdf=1&csv=1;&amp;pag=$pag$curref\">
-		<img class=\"image\" src=\"modules/Elezioni/images/pdf.gif\" alt=\"\" /></a>
-
-
-	</div>";
-	}
-       
-    
-    
-	$sql="SELECT sum(maschi),sum(femmine) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-
-	list($totm,$totf) = $res->fetch(PDO::FETCH_NUM);
-	$totel=$totm+$totf;
-	if (!IsSet($pag)) {$pag=0;} //inizializza il numero di pagina 
-	/*
-	if (!IsSet($num_ref)) { 
-		$num_ref=1;
-		$resg = mysql_query("SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
-		$num_refs= mysql_num_rows($resg); //quante pagine?
-	}
-	*/
-	if(($genere!=4) and $pag==0){ //diverso da liste a piu' candidati
-		$ops=4;	//gestione gruppi (anche liste uninominali)
-	}else{
-		$ops=3; //gestione liste
-	}
-	
-	$sql="SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref";
-	$resg = $dbi->prepare("$sql");
-	$resg->execute();
-
-	list($idg,$numg) = $resg->fetch(PDO::FETCH_NUM);
-	$sql="SELECT id_sez,num_sez,t1.id_sede as id_sede,t2.id_circ as id_circ FROM ".$prefix."_ele_sezioni as t1,".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez ";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-
-	$max = $res->rowCount(); //quante sezioni?
-	$sql="SELECT id_sez,num_sez,t1.id_sede as id_sede,t2.id_circ as id_circ FROM ".$prefix."_ele_sezioni as t1,".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez ";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-
-	$num_sez = $res->rowCount(); //quante sezioni?
-	for ($i=1;$i<=$num_sez;$i++){
-		$sezione[$i]=$res->fetch(PDO::FETCH_BOTH); //inizializza l'array delle sezioni
-		$ar[$i]=0;
-	}
-	$tab3="_ele_voti_lista";
-	if ($genere>0) {  //se non e' un referendum
-
-
-
-		if (!($genere==4) and $pag==0){  //se non e' una lista uninominale ed e' la prima pagina
-                        
-			$tab="SELECT 0,t2.id_sez,t2.num_sez,t2.validi,'0','0',t2.validi,t2.nulli,t2.bianchi,t2.contestati, t4.id_circ,t2.id_sede,'0',t2.voti_nulli FROM ".$prefix."_ele_sezioni as t2 left join ".$prefix."_ele_sede as t4 on (t2.id_sede=t4.id_sede) where t2.id_cons='$id_cons' and t2.validi+t2.nulli+t2.bianchi+t2.contestati>0 group by t2.id_sez,t2.num_sez,t2.validi,t2.nulli,t2.bianchi,t2.contestati, t4.id_circ,t2.id_sede,t2.voti_nulli order by t2.num_sez ";
-		
-		}else{ // e' una lista uninominale o la seconda pagina
-
-
-
-			# voto disgiunto regione sicilia aggiunge il campo solo lista
-		    if(isdisgiunto()){
-			$tab="SELECT '0',t1.id_sez,t1.num_sez,sum(t2.voti),t1.solo_gruppo,t1.solo_lista,t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t1.id_sede,'0',t1.voti_nulli
-			FROM ".$prefix."_ele_sezioni as t1 left join ".$prefix.$tab3." as t2 on (t1.id_sez=t2.id_sez)
-			left join ".$prefix."_ele_sede as t4 on (t1.id_sede=t4.id_sede)
-			where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons group by t1.id_sez,t1.num_sez,t1.solo_gruppo,t1.solo_lista,t1.validi,t1.nulli,t1.bianchi,t1.contestati,t4.id_circ,t1.id_sede,t1.voti_nulli order by t1.num_sez ";
-		     }else{
-			
-			$tab="SELECT '0',t1.id_sez,t1.num_sez,sum(t2.voti),t1.solo_gruppo,'0',t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t1.id_sede,'0',t1.voti_nulli
-			FROM ".$prefix."_ele_sezioni as t1 left join ".$prefix.$tab3." as t2 on (t1.id_sez=t2.id_sez)
-			left join ".$prefix."_ele_sede as t4 on (t1.id_sede=t4.id_sede)
-			where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons group by t1.id_sez,t1.num_sez,t1.solo_gruppo,t1.validi,t1.nulli,t1.bianchi,t1.contestati,t4.id_circ,t1.id_sede,t1.voti_nulli order by t1.num_sez ";
-			}
-		}
-	
-
-	
-		$riga1 = "";
-		if($pag==0)$riga1 .="<h2>"._DETTAGLIO." "._VOTIE."</h2>";
-		else $riga1 .="<h4>"._DETTAGLIO." "._VOTIE." "._ASOLA_LISTA."</h4>";
-		
-	}else{ // e' un referendum --> t3.id_gruppo vuota per allineare il while (da rifare con array)
-		$tab="SELECT t1.id_gruppo,t1.id_sez,t2.num_sez,t1.si,t1.no,'0',t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t2.id_sede,t3.num_gruppo,'0'
-		FROM ".$prefix."_ele_voti_ref as t1 left join ".$prefix."_ele_sezioni as t2 on (t1.id_sez=t2.id_sez)
-		left join  ".$prefix."_ele_gruppo as t3 on (t1.id_gruppo=t3.id_gruppo) left join ".$prefix."_ele_sede as t4 on (t2.id_sede=t4.id_sede)
-		where t1.id_cons='$id_cons' and t1.id_gruppo='$idg' order by t2.num_sez ";
-		$riga1  = "<div style=\"margin:0px auto;text-align:center;\">";
-		$riga1  .="<h2>"._DETTAGLIO." "._VOTIE."</h2></div>";
-		
-		$sql="select descrizione from ".$prefix."_ele_gruppo where id_gruppo='$idg'";
-		$des = $dbi->prepare("$sql");
-		$des->execute();
-
-		list($descrizione)=$des->fetch(PDO::FETCH_BOTH);
-		$riga1 .="<h4>$descrizione</h4>";
-	}
-	$sql="$tab ";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-
-	$num_scr = $res->rowCount();
-	//$riga2= "<div>"._SEZSCR." $num_scr su $num_sez</div>";//sezioni scrutinate
-
-	$riga2 = "<table style=\"border:1px solid #6A6A6A;\" summary=\"Tabella dei voti espressi\">";
-	$riga3 = "<tr class=\"bggray2\">
-	<td>"._SEZIONI."</td>
-    	<td>"._VOTIU."</td>
-	<td>"._VOTID."</td>
-	<td>"._VOTIE."</td>"; //testata con nomi dei campi
-	if ($genere==0) {  //se e' un referendum
-		$riga3 .= "<td>"._SI."</td><td>"._NO."</td>";
-	} elseif ((($genere==5) or ($genere==3)) and $pag==1){
-		$riga3 .= "<td>Voti "._LISTE."</td>";
-		if(isdisgiunto()){
-			$riga3 .= "<td>Voti "._PRESI."</td>";
-			$riga3 .= "<td>"._SOLO_LISTA."</td>";
-			
-			
-		} // voto disgiunto
-		if (!$votog) $riga3 .= "<td>"._ASOLO_GRUPPO."</td>";
-	}
-        
-	$riga3 .= "<td>"._VALIDI."</td><td>"._NULLI."</td><td>"._BIANCHI."</td><td>"._CONTESTATI."</td>"
-    ."</tr>\n";
-	$sql="$tab ";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-
-	$num_scr = $res->rowCount();
-	$righe= "";
-	$scrutinate=1;
-	$tot_u=0;$tot_d=0;$tot_voti=0; $tot_si=0;$tot_no=0;$tot_validi=0;$tot_nulli=0;$tot_bianchi=0;$tot_contestati=0;
-	$tot_sololista=0;$tot_gruppo=0;
-	#$si e $no sono valide anche per voti lista e solo gruppo per i non referendum
-	while (list($id_gruppo,$id,$num,$si,$no,$sololista,$validi,$nulli,$bianchi,$contestati,$id_circ,$id_sede,$gruppo,$votinulli) = $res->fetch(PDO::FETCH_NUM)){
-	$nulli+=$votinulli;
-	// inserimento numeri di sez non scrutinate
-		while ($scrutinate < $num) { 
-			$righe.= "<tr><td><span style=\"color: rgb(255, 0, 0);\">$scrutinate</span></td></tr>\n";
-			$scrutinate++;
-		}
-
-	# voti sindaco, gruppo o presidente
-	$tab5="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id'";
-	$sql="$tab5";
-	$res3 = $dbi->prepare("$sql");
-	$res3->execute();
-
-	list($sindaco) = $res3->fetch(PDO::FETCH_NUM);	
-	
-
-		$scrutinate++; 
-	// fine inserimento	
-		$tab2="SELECT max(voti_donne),max(voti_uomini),max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id'";
-		if ($genere==0) $tab2 .= " and id_gruppo=$id_gruppo";
-		$sql=$tab2;
-	$res2 = $dbi->prepare("$sql");
-	$res2->execute();
-
-		list($votid,$votiu,$voti) = $res2->fetch(PDO::FETCH_NUM);
-//		$voti=$votiu+$votid;
-		$tot_gruppo+=$sindaco;
-		$tot_u+=$votiu;
-		$tot_d+=$votid;
-		$tot_voti+=$voti;
-		$tot_si+=$si;
-		$tot_no+=$no;
-		$tot_validi+=$validi;
-		$tot_nulli+=$nulli;
-		$tot_bianchi+=$bianchi;
-		$tot_contestati+=$contestati;
-		$tot_sololista+=$sololista;
-		$righe .= "<tr class=\"bggray2\">
-		<td>$num</td>
-		<td>".number_format($votiu,0,',','.')."</td>
-		<td>".number_format($votid,0,',','.')."</td>
-		<td>".number_format($voti,0,',','.')."</td>";
-		if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){
-		$righe .= "<td>".number_format($si,0,',','.')."</td>";
-		
-		if(isdisgiunto()){
-			$righe .= "<td>".number_format($sindaco,0,',','.')."</td>";
-			$righe .= "<td>".number_format($sololista,0,',','.')."</td>";
-			}
-		if (!$votog) $righe .= "<td>".number_format($no,0,',','.')."</td>";	
-
-
-}
-		
-
-		$righe .= "<td>".number_format($validi,0,',','.')."</td>
-
-		<td>$nulli</td>
-		<td>$bianchi</td>
-		<td>$contestati</td></tr>";
-	}
-	if ($num<$num_sez) {
-		for (;$scrutinate<=$num_sez;$scrutinate++) {
-			$righe .= "<tr><td>";
-			$righe .="<span style=\"color: rgb(255, 0, 0);\">$scrutinate</span></td></tr>";
-		}
-	}
-	$righet='';
-	if($num_scr){
-	$righet = "<tr class=\"bggray\">
-	<td ></td>
-    	<td>"._VOTIU."</td>
-	<td>"._VOTID."</td>
-	<td>"._VOTIE."</td>"; //testata con nomi dei campi
-	if ($genere==0) {  //se e' un referendum
-		$righet .= "<td>"._SI."</td><td>"._NO."</td>";
-	} elseif ((($genere==5) or ($genere==3)) and $pag==1){
-		$righet .= "<td>Voti "._LISTE."</td>";
-		if(isdisgiunto()){
-			$righet .= "<td>Voti "._PRESI."</td>";
-			$righet .= "<td>"._SOLO_LISTA."</td>";
-		} // voto disgiunto	
-		if (!$votog) $righet .= "<td>"._ASOLO_GRUPPO."</td>";
-		
-	}
-	if($totel==0) $totelrip="0.00"; else $totelrip=number_format($tot_voti*100/$totel,2);
-	if($totf==0) $totfrip="0.00"; else $totfrip=number_format($tot_d*100/$totf,2);
- 	if($totm==0) $totmrip="0.00"; else $totmrip=number_format($tot_u*100/$totm,2);
-	$righet .= "<td>"._VALIDI."</td><td>"._NULLI."</td><td>"._BIANCHI."</td><td>"._CONTESTATI."</td>"
-    ."</tr>
-
-
-
-	<tr class=\"td-vuotoc\"><td><b>"._TOT."</b></td><td><b>".number_format($tot_u,0,',','.')."</b><br /><i>(".$totmrip."%)</i></td><td><b>".number_format($tot_d,0,',','.')."</b><br /><i>(".$totfrip."%)</i></td><td><b>".number_format($tot_voti,0,',','.')."</b><br /><i>(".$totelrip."%)</i></td>";
-	
-	// se e' un referendum o una consultazione con raggruppamenti
-
-	if($tot_validi){
-	if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){
-		$righet .= "<td><b>".number_format($tot_si,0,',','.')."</b><br /><i>(".number_format($tot_si*100/$tot_validi,2)."%)</i></td>";
-
-		if(isdisgiunto()){
-			$righet .="<td><b>".number_format($tot_gruppo,0,',','.')."</b><br /><i>(".number_format($tot_gruppo*100/$tot_validi,2)."%)</i></td>";
-			$righet .="<td><b>".number_format($tot_sololista,0,',','.')."</b><br /><i>(".number_format($tot_sololista*100/$tot_validi,2)."%)</i></td>";
-		}
-
-
-	if(!$votog) $righet .="<td><b>".number_format($tot_no,0,',','.')."</b><br /><i>(".number_format($tot_no*100/$tot_validi,2)."%)</i></td>";	
-	}
-
-
-		$righet .= "<td><b>".number_format($tot_validi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_validi*100/$tot_voti,2):'0.00')."%)</i></td><td><b>"
-	.number_format($tot_nulli,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_nulli*100/$tot_voti,2):'0.00')."%)</i></td><td><b>".number_format($tot_bianchi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_bianchi*100/$tot_voti,2):'0.00')."%)</i></td><td><b>".number_format($tot_contestati,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_contestati*100/$tot_voti,2):'0.00')."%)</i></td></tr>";
-	}else{
-	if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){
-	$righet .= "<td><b>".number_format($tot_si,0,',','.')."</b><br /><i>(0.00%)</i></td><td><b>".number_format($tot_no,0,',','.')."</b><br /><i>(0.00%)</i></td>";}
-	$righet .= "<td><b>0</b><br /><i>(0.00%)</i></td><td><b>"
-	.number_format($tot_nulli,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_nulli*100/$tot_voti,2):'0,00')."%)</i></td><td><b>".number_format($tot_bianchi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_bianchi*100/$tot_voti,2):'0,00')."%)</i></td><td><b>".number_format($tot_contestati,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_contestati*100/$tot_voti,2):'0,00')."%)</i></td></tr>";
-	}
-	}
-	$righe .= "</table>";
-        if(!isset($html)) $html='';
-	$html .= "$riga1";
-	$html .= $riga2."";
-	$html .= $righet;
-	$html .= $riga3;
-	$html .= $righe;
-	
-
-    $html .="<div>";
-    if($genere==0){ //se e' referendum
-	if ($xls!='1' && $pdf!='1' && $csv!='1'){
-        #'Pagina precedente' e 'Pagina Successiva'
-	    $cur=$num_ref;
-        if ($cur>1) {
-              $num_ref--;
-			  $html .= "<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=votanti&amp;num_ref=$num_ref&amp;num_refs=$num_refs&amp;csv=$csv&amp;xls=$xls&amp;pdf=$pdf\">";
-              $html .= "[ <b>"._PREV_MATCH."</b> ]</a>";
-        }
-        if ($cur<$num_refs) {
-	        $cur++;        
-			$html .= "<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=votanti&amp;num_ref=$cur&amp;num_refs=$num_refs&amp;csv=$csv&amp;xls=$xls&amp;pdf=$pdf\">";
-			
-            $html .= "[ <b>"._NEXT_MATCH."</b> ]</a>";
-        }
-}
-}
-if($genere==5 or $genere==3){ //se vi sono raggruppamenti
-	      if($csv!=1 and $fascia>$limite){
-
-		$pag=($pag==0 ? 1:0);
-		$html .= "<a href=\"modules.php?name=Elezioni&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;op=come&amp;info=votanti&amp;pag=$pag&amp;csv=$csv\"><b>";
-		if($pag) $html .=  _VOTIL;
-	       //_CONTR_CONS;
-		else $html .= _VOTIE; 
-		//_CONTR_ESPR;
-		$html .= "</b></a>";
-	      }
-	}
-	
-
-if($csv==1){
-      $data=date("d-m-y G:i");
-      $html .="<br/><div style=\"margin:0 auto;text-align:center;\"><i>Stampato: $data</i>";
-      $html .="<br/><i>Eleonline by l. apolito & r. gigli - www.eleonline.it</i></div>";		
-      //$html .= $html;	
-      
-}	
-$html .= "</div>";
-
-
+include('votanti-inc.php');
 
 ############### stampa
 if ($xls!='1' && $pdf!='1'){
-      echo "$datipdf $html";
+	  echo "$datipdf $html";
 }elseif($xls=="1"){
 	$nomefile="votanti.xls";
@@ -515,29 +30,11 @@
 	echo "$html \n";
 }elseif($pdf=='1'){
-
-
-		$nomefile="$descr_cons votanti.pdf";
-
-
-
-
-
-		
-#		$stampa ="<div style=\"margin:0 auto;text-align:center;\">$datipdf $html</div>";
-		$stampa ="$datipdf $html";
-		
-		$html2pdf = new Html2Pdf('P','A4', 'it');
-		$html2pdf->WriteHTML($stampa, isset($_GET['vuehtml']));
-		$html2pdf->Output($nomefile);
-
-
+	$nomefile="$descr_cons votanti.pdf";
+	$stampa ="$datipdf $html";		
+	$html2pdf = new Html2Pdf('P','A4', 'it');
+	$html2pdf->WriteHTML($stampa, isset($_GET['vuehtml']));
+	$html2pdf->Output($nomefile);
 }
-
-
-
-
 if($csv!=1 ) include ("footer.php");
 
-
-
 ?>
Index: trunk/client/modules/Elezioni/votantiphp5.php
===================================================================
--- trunk/client/modules/Elezioni/votantiphp5.php	(revision 375)
+++ trunk/client/modules/Elezioni/votantiphp5.php	(revision 376)
@@ -4,5 +4,5 @@
 /* by Luciano Apolito & Roberto Gigli                                   */
 /* http://www.eleonline.it                                              */
-/* info@eleonline.it  luciano@aniene.net rgigli@libero.it               */
+/* info@eleonline.it rgigli@libero.it                                   */
 /************************************************************************/
 
@@ -12,526 +12,26 @@
 require_once('inc/hpdf403/html2pdf.class.php');
 
-$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ?
-	$_GET : $_POST;
-
-$id_comune= (isset($param['id_comune'])) ? $param['id_comune']:$siteistat;
-if (isset($param['id_cons_gen'])) $id_cons_gen=intval($param['id_cons_gen']); else $id_cons_gen='';
-if (isset($param['op'])) $op=$param['op']; else $op='';
-if (isset($param['minsez'])) $minsez=intval($param['minsez']); else $minsez='';
-if (isset($param['id_lista'])) $id_lista=intval($param['id_lista']); else $id_lista='';
-if (isset($param['id_circ'])) $id_circ=intval($param['id_circ']); else $id_circ='';
-if (isset($param['csv'])) $csv=intval($param['csv']); else $csv='';
-if (isset($param['min'])) $min=intval($param['min']); else $min= 0;
-if (isset($param['orvert'])) $orvert=intval($param['orvert']); else $orvert='';
-if (isset($param['offset'])) $offset=intval($param['offset']); else $offset='';
-if (isset($param['offsetsez'])) $offsetsez=intval($param['offsetsez']); else $offsetsez='';
-if (isset($param['perc'])) $perc=$param['perc']; else $perc='';
-if (isset($param['info'])) $info=addslashes($param['info']); else $info='';
-if (isset($param['files'])) $files=addslashes($param['files']); else $files='';
-if (isset($param['voti_lista'])) $voti_lista=intval($param['voti_lista']); else $voti_lista= 0;
-if (isset($param['perc_lista'])) $perc_lista=$param['perc_lista']; else $perc_lista= 0;
-if (isset($param['lettera'])) $lettera=addslashes($param['lettera']); else $lettera='';
-if (isset($param['id_gruppo'])) $id_gruppo=intval($param['id_gruppo']); else $id_gruppo='';
-if (isset($param['tipo_cons'])) $tipo_cons=intval($param['tipo_cons']); else $tipo_cons='';
-if (isset($param['xls'])) $xls=intval($param['xls']); else $xls='';
-if (isset($param['pdf'])) $pdf=intval($param['pdf']); else $pdf='';
-
-# anti-xss nov. 2009 
-$id_comune=htmlentities($id_comune);
-$perc=floatval($perc);
-$perc_lista=floatval($perc_lista);
-$datipdf= htmlentities($datipdf);
-$op= htmlentities($op);
-$info= htmlentities($info);
-$files=htmlentities($files);
-$lettera=htmlentities($lettera);
-
-$id_comune=intval($id_comune);
-
-
-//$id_cons_gen=$_GET['id_cons_gen'];
-$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'" ;
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-
-list($tipo_cons,$genere,$id_cons) = $res->fetch(PDO::FETCH_NUM);
-
-if (isset($param['ops'])) $ops=$param['ops']; else $ops='';
-if (isset($param['pag'])) $pag=$param['pag']; else $pag=0;
-if (isset($param['num_ref'])) $num_ref=$param['num_ref'];
-if (isset($param['num_refs'])) $num_refs=$param['num_refs'];
-$bgcolor2='#cacaca';
-
-
-if (!IsSet($num_ref)) { 
-		$num_ref=1;
-		$sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons";
-		$resg = $dbi->prepare("$sql");
-		$resg->execute();
-
-		$num_refs= $resg->rowCount(); //quante pagine?
-	}
-
-
-
-//**************************************************************************
-//        ELE
-//**************************************************************************
-//controllo_finale($id_cons);
-
-global $prefix, $dbi,$id_circ,$lang, $fascia, $limite, $votog;
-
-include_once("modules/Elezioni/language/lang-$lang.php");
-# testata
-
-if($csv==1){
-	include_once("modules/Elezioni/funzioni.php");
-	
-	$sql="SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-
-	list($descr_com) = $res->fetch(PDO::FETCH_NUM);
-        $descr_com =stripslashes($descr_com); 
-	$datipdf .= "<div style=\"margin:0px auto; text-align:center;\">";
-	$siteistat=$id_comune;
-	# salva sull'hardisk lo stemma del comune
-	$logo=verificasimbolo();
-	$immagine= "<img src=\"modules/Elezioni/images/$logo\" alt=\"logo\" align=\"left\"/>";
-
-	
-
-
-
-	if($xls!=1) $datipdf .= "<table><tr><td>$immagine</td><td>";
-        $datipdf .= ""._COMUNE." $descr_com <br/>
-	"._RISULTA." "._CONSULTA."<br/>";
-	$datipdf .= "$descr_cons <br />"._DISCLAIMER."";
-	if($xls!=1) $datipdf .=  "</td></tr></table>";
-	$datipdf .="</div>";
-	  
-
-$html = "<style type=\"text/css\">
-	<!--
-
-	.td-89 {
-	width: 89%;	
-	border: 1px;
-	text-align: left; 
-	}
-	.td-vuoto {
-		
-	width: 100%;	
-	border: 1px;
-	text-align: left; 
-	
-}
-
-
-	.td-5 {
-	
-	margin: 0px 0 0 0px;
-	width: 5%;	
-	/*border: none;*/
-	padding: 0px;
-        
-	text-align: center; 
-	}	
-
-
-
-	.bggray 	{
-		background: #ffffff; 
-		FONT-SIZE: 13px; 
-		FONT-FAMILY: Helvetica;
-		border: 1px;
-	}
-
-	.bggray2 	{
-		background: #EFEFEF; 
-		FONT-SIZE: 13px; 
-		FONT-FAMILY: Helvetica;
-		border: 1px;
-		}
-	-->
-	</style>";
-
-
-
-
-}
-	
-
-
-
-
-
-
-
-
-
-    
-    // icone stampa e grafici
-	if ($csv!=1){
-	if(isset($num_ref)) $curref="&amp;num_ref=$num_ref"; else $curref='';
-	if (!isset($html)) $html='';
-	$html .= "<div>
-	<a href=\"modules.php?name=Elezioni&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;op=graf_votanti\">
-	"._VER_GRAF." <img class=\"image\" src=\"modules/Elezioni/images/grafici.png\" alt=\"\" /></a>
-
-	 <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=votanti&amp;csv=1&amp;pag=$pag&amp;num_ref=$num_ref&amp;num_refs=$num_refs\">"._VER_STAMPA."
-
-	
-	<img class=\"image\" src=\"modules/Elezioni/images/printer.png\" alt=\"\" /></a>
-
-	<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=votanti&amp;xls=1&csv=1;&amp;pag=$pag&amp;num_ref=$num_ref&amp;num_refs=$num_refs\">
-
-	
-		<img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"\" /></a>
-
-<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=votanti&amp;pdf=1&csv=1;&amp;pag=$pag&amp;num_ref=$num_ref&amp;num_refs=$num_refs\">
-<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=votanti&amp;pdf=1&csv=1;&amp;pag=$pag$curref\">
-		<img class=\"image\" src=\"modules/Elezioni/images/pdf.gif\" alt=\"\" /></a>
-
-
-	</div>";
-	}
-       
-    
-    
-	$sql="SELECT sum(maschi),sum(femmine) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-
-	list($totm,$totf) = $res->fetch(PDO::FETCH_NUM);
-	$totel=$totm+$totf;
-	if (!IsSet($pag)) {$pag=0;} //inizializza il numero di pagina 
-	/*
-	if (!IsSet($num_ref)) { 
-		$num_ref=1;
-		$resg = mysql_query("SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
-		$num_refs= mysql_num_rows($resg); //quante pagine?
-	}
-	*/
-	if(($genere!=4) and $pag==0){ //diverso da liste a piu' candidati
-		$ops=4;	//gestione gruppi (anche liste uninominali)
-	}else{
-		$ops=3; //gestione liste
-	}
-	
-	$sql="SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref";
-	$resg = $dbi->prepare("$sql");
-	$resg->execute();
-
-	list($idg,$numg) = $resg->fetch(PDO::FETCH_NUM);
-	$sql="SELECT id_sez,num_sez,t1.id_sede as id_sede,t2.id_circ as id_circ FROM ".$prefix."_ele_sezioni as t1,".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez ";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-
-	$max = $res->rowCount(); //quante sezioni?
-	$sql="SELECT id_sez,num_sez,t1.id_sede as id_sede,t2.id_circ as id_circ FROM ".$prefix."_ele_sezioni as t1,".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez ";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-
-	$num_sez = $res->rowCount(); //quante sezioni?
-	for ($i=1;$i<=$num_sez;$i++){
-		$sezione[$i]=$res->fetch(PDO::FETCH_BOTH); //inizializza l'array delle sezioni
-		$ar[$i]=0;
-	}
-	$tab3="_ele_voti_lista";
-	if ($genere>0) {  //se non e' un referendum
-
-
-
-		if (!($genere==4) and $pag==0){  //se non e' una lista uninominale ed e' la prima pagina
-                        
-			$tab="SELECT 0,t2.id_sez,t2.num_sez,t2.validi,'0','0',t2.validi,t2.nulli,t2.bianchi,t2.contestati, t4.id_circ,t2.id_sede,'0',t2.voti_nulli FROM ".$prefix."_ele_sezioni as t2 left join ".$prefix."_ele_sede as t4 on (t2.id_sede=t4.id_sede) where t2.id_cons='$id_cons' and t2.validi+t2.nulli+t2.bianchi+t2.contestati>0 group by t2.id_sez order by t2.num_sez ";
-		
-		}else{ // e' una lista uninominale o la seconda pagina
-
-
-
-			# voto disgiunto regione sicilia aggiunge il campo solo lista
-		    if(isdisgiunto()){
-			$tab="SELECT '0',t1.id_sez,t1.num_sez,sum(t2.voti),t1.solo_gruppo,t1.solo_lista,t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t1.id_sede,'0',t1.voti_nulli
-			FROM ".$prefix."_ele_sezioni as t1 left join ".$prefix.$tab3." as t2 on (t1.id_sez=t2.id_sez)
-			left join ".$prefix."_ele_sede as t4 on (t1.id_sede=t4.id_sede)
-			where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons group by t2.id_sez order by t1.num_sez ";
-		     }else{
-			
-			$tab="SELECT '0',t1.id_sez,t1.num_sez,sum(t2.voti),t1.solo_gruppo,'0',t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t1.id_sede,'0',t1.voti_nulli
-			FROM ".$prefix."_ele_sezioni as t1 left join ".$prefix.$tab3." as t2 on (t1.id_sez=t2.id_sez)
-			left join ".$prefix."_ele_sede as t4 on (t1.id_sede=t4.id_sede)
-			where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons group by t2.id_sez order by t1.num_sez ";
-			}
-		}
-	
-
-	
-		$riga1 = "";
-		if($pag==0)$riga1 .="<h2>"._DETTAGLIO." "._VOTIE."</h2>";
-		else $riga1 .="<h4>"._DETTAGLIO." "._VOTIE." "._ASOLA_LISTA."</h4>";
-		
-	}else{ // e' un referendum --> t3.id_gruppo vuota per allineare il while (da rifare con array)
-		$tab="SELECT t1.id_gruppo,t1.id_sez,t2.num_sez,t1.si,t1.no,'0',t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t2.id_sede,t3.num_gruppo,'0'
-		FROM ".$prefix."_ele_voti_ref as t1 left join ".$prefix."_ele_sezioni as t2 on (t1.id_sez=t2.id_sez)
-		left join  ".$prefix."_ele_gruppo as t3 on (t1.id_gruppo=t3.id_gruppo) left join ".$prefix."_ele_sede as t4 on (t2.id_sede=t4.id_sede)
-		where t1.id_cons='$id_cons' and t1.id_gruppo='$idg' order by t2.num_sez ";
-		$riga1  = "<div style=\"margin:0px auto;text-align:center;\">";
-		$riga1  .="<h2>"._DETTAGLIO." "._VOTIE."</h2></div>";
-		
-		$sql="select descrizione from ".$prefix."_ele_gruppo where id_gruppo='$idg'";
-		$des = $dbi->prepare("$sql");
-		$des->execute();
-
-		list($descrizione)=$des->fetch(PDO::FETCH_BOTH);
-		$riga1 .="<h4>$descrizione</h4>";
-	}
-	$sql="$tab ";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-
-	$num_scr = $res->rowCount();
-	//$riga2= "<div>"._SEZSCR." $num_scr su $num_sez</div>";//sezioni scrutinate
-
-	$riga2 = "<table style=\"border:1px solid #6A6A6A;\" summary=\"Tabella dei voti espressi\">";
-	$riga3 = "<tr class=\"bggray2\">
-	<td>"._SEZIONI."</td>
-    	<td>"._VOTIU."</td>
-	<td>"._VOTID."</td>
-	<td>"._VOTIE."</td>"; //testata con nomi dei campi
-	if ($genere==0) {  //se e' un referendum
-		$riga3 .= "<td>"._SI."</td><td>"._NO."</td>";
-	} elseif ((($genere==5) or ($genere==3)) and $pag==1){
-		$riga3 .= "<td>Voti "._LISTE."</td>";
-		if(isdisgiunto()){
-			$riga3 .= "<td>Voti "._PRESI."</td>";
-			$riga3 .= "<td>"._SOLO_LISTA."</td>";
-			
-			
-		} // voto disgiunto
-		if (!$votog) $riga3 .= "<td>"._ASOLO_GRUPPO."</td>";
-	}
-        
-	$riga3 .= "<td>"._VALIDI."</td><td>"._NULLI."</td><td>"._BIANCHI."</td><td>"._CONTESTATI."</td>"
-    ."</tr>\n";
-	$sql="$tab ";
-	$res = $dbi->prepare("$sql");
-	$res->execute();
-
-	$num_scr = $res->rowCount();
-	$righe= "";
-	$scrutinate=1;
-	$tot_u=0;$tot_d=0;$tot_voti=0; $tot_si=0;$tot_no=0;$tot_validi=0;$tot_nulli=0;$tot_bianchi=0;$tot_contestati=0;
-	$tot_sololista=0;$tot_gruppo=0;
-	#$si e $no sono valide anche per voti lista e solo gruppo per i non referendum
-	while (list($id_gruppo,$id,$num,$si,$no,$sololista,$validi,$nulli,$bianchi,$contestati,$id_circ,$id_sede,$gruppo,$votinulli) = $res->fetch(PDO::FETCH_NUM)){
-	$nulli+=$votinulli;
-	// inserimento numeri di sez non scrutinate
-		while ($scrutinate < $num) { 
-			$righe.= "<tr><td><span style=\"color: rgb(255, 0, 0);\">$scrutinate</span></td></tr>\n";
-			$scrutinate++;
-		}
-
-	# voti sindaco, gruppo o presidente
-	$tab5="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id'";
-	$sql="$tab5";
-	$res3 = $dbi->prepare("$sql");
-	$res3->execute();
-
-	list($sindaco) = $res3->fetch(PDO::FETCH_NUM);	
-	
-
-		$scrutinate++; 
-	// fine inserimento	
-		$tab2="SELECT max(voti_donne),max(voti_uomini),max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id'";
-		if ($genere==0) $tab2 .= " and id_gruppo=$id_gruppo";
-		$sql=$tab2;
-	$res2 = $dbi->prepare("$sql");
-	$res2->execute();
-
-		list($votid,$votiu,$voti) = $res2->fetch(PDO::FETCH_NUM);
-//		$voti=$votiu+$votid;
-		$tot_gruppo+=$sindaco;
-		$tot_u+=$votiu;
-		$tot_d+=$votid;
-		$tot_voti+=$voti;
-		$tot_si+=$si;
-		$tot_no+=$no;
-		$tot_validi+=$validi;
-		$tot_nulli+=$nulli;
-		$tot_bianchi+=$bianchi;
-		$tot_contestati+=$contestati;
-		$tot_sololista+=$sololista;
-		$righe .= "<tr class=\"bggray2\">
-		<td>$num</td>
-		<td>".number_format($votiu,0,',','.')."</td>
-		<td>".number_format($votid,0,',','.')."</td>
-		<td>".number_format($voti,0,',','.')."</td>";
-		if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){
-		$righe .= "<td>".number_format($si,0,',','.')."</td>";
-		
-		if(isdisgiunto()){
-			$righe .= "<td>".number_format($sindaco,0,',','.')."</td>";
-			$righe .= "<td>".number_format($sololista,0,',','.')."</td>";
-			}
-		if (!$votog) $righe .= "<td>".number_format($no,0,',','.')."</td>";	
-
-
-}
-		
-
-		$righe .= "<td>".number_format($validi,0,',','.')."</td>
-
-		<td>$nulli</td>
-		<td>$bianchi</td>
-		<td>$contestati</td></tr>";
-	}
-	if ($num<$num_sez) {
-		for (;$scrutinate<=$num_sez;$scrutinate++) {
-			$righe .= "<tr><td>";
-			$righe .="<span style=\"color: rgb(255, 0, 0);\">$scrutinate</span></td></tr>";
-		}
-	}
-	$righet='';
-	if($num_scr){
-	$righet = "<tr class=\"bggray\">
-	<td ></td>
-    	<td>"._VOTIU."</td>
-	<td>"._VOTID."</td>
-	<td>"._VOTIE."</td>"; //testata con nomi dei campi
-	if ($genere==0) {  //se e' un referendum
-		$righet .= "<td>"._SI."</td><td>"._NO."</td>";
-	} elseif ((($genere==5) or ($genere==3)) and $pag==1){
-		$righet .= "<td>Voti "._LISTE."</td>";
-		if(isdisgiunto()){
-			$righet .= "<td>Voti "._PRESI."</td>";
-			$righet .= "<td>"._SOLO_LISTA."</td>";
-		} // voto disgiunto	
-		if (!$votog) $righet .= "<td>"._ASOLO_GRUPPO."</td>";
-		
-	}
-	if($totel==0) $totelrip="0.00"; else $totelrip=number_format($tot_voti*100/$totel,2);
-	if($totf==0) $totfrip="0.00"; else $totfrip=number_format($tot_d*100/$totf,2);
- 	if($totm==0) $totmrip="0.00"; else $totmrip=number_format($tot_u*100/$totm,2);
-	$righet .= "<td>"._VALIDI."</td><td>"._NULLI."</td><td>"._BIANCHI."</td><td>"._CONTESTATI."</td>"
-    ."</tr>
-
-
-
-	<tr class=\"td-vuotoc\"><td><b>"._TOT."</b></td><td><b>".number_format($tot_u,0,',','.')."</b><br /><i>(".$totmrip."%)</i></td><td><b>".number_format($tot_d,0,',','.')."</b><br /><i>(".$totfrip."%)</i></td><td><b>".number_format($tot_voti,0,',','.')."</b><br /><i>(".$totelrip."%)</i></td>";
-	
-	// se e' un referendum o una consultazione con raggruppamenti
-
-	if($tot_validi){
-	if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){
-		$righet .= "<td><b>".number_format($tot_si,0,',','.')."</b><br /><i>(".number_format($tot_si*100/$tot_validi,2)."%)</i></td>";
-
-		if(isdisgiunto()){
-			$righet .="<td><b>".number_format($tot_gruppo,0,',','.')."</b><br /><i>(".number_format($tot_gruppo*100/$tot_validi,2)."%)</i></td>";
-			$righet .="<td><b>".number_format($tot_sololista,0,',','.')."</b><br /><i>(".number_format($tot_sololista*100/$tot_validi,2)."%)</i></td>";
-		}
-
-
-	if(!$votog) $righet .="<td><b>".number_format($tot_no,0,',','.')."</b><br /><i>(".number_format($tot_no*100/$tot_validi,2)."%)</i></td>";	
-	}
-
-
-		$righet .= "<td><b>".number_format($tot_validi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_validi*100/$tot_voti,2):'0.00')."%)</i></td><td><b>"
-	.number_format($tot_nulli,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_nulli*100/$tot_voti,2):'0.00')."%)</i></td><td><b>".number_format($tot_bianchi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_bianchi*100/$tot_voti,2):'0.00')."%)</i></td><td><b>".number_format($tot_contestati,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_contestati*100/$tot_voti,2):'0.00')."%)</i></td></tr>";
-	}else{
-	if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){
-	$righet .= "<td><b>".number_format($tot_si,0,',','.')."</b><br /><i>(0.00%)</i></td><td><b>".number_format($tot_no,0,',','.')."</b><br /><i>(0.00%)</i></td>";}
-	$righet .= "<td><b>0</b><br /><i>(0.00%)</i></td><td><b>"
-	.number_format($tot_nulli,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_nulli*100/$tot_voti,2):'0,00')."%)</i></td><td><b>".number_format($tot_bianchi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_bianchi*100/$tot_voti,2):'0,00')."%)</i></td><td><b>".number_format($tot_contestati,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_contestati*100/$tot_voti,2):'0,00')."%)</i></td></tr>";
-	}
-	}
-	$righe .= "</table>";
-        if(!isset($html)) $html='';
-	$html .= "$riga1";
-	$html .= $riga2."";
-	$html .= $righet;
-	$html .= $riga3;
-	$html .= $righe;
-	
-
-    $html .="<div>";
-    if($genere==0){ //se e' referendum
-	if ($xls!='1' && $pdf!='1' && $csv!='1'){
-        #'Pagina precedente' e 'Pagina Successiva'
-	    $cur=$num_ref;
-        if ($cur>1) {
-              $num_ref--;
-			  $html .= "<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=votanti&amp;num_ref=$num_ref&amp;num_refs=$num_refs&amp;csv=$csv&amp;xls=$xls&amp;pdf=$pdf\">";
-              $html .= "[ <b>"._PREV_MATCH."</b> ]</a>";
-        }
-        if ($cur<$num_refs) {
-	        $cur++;        
-			$html .= "<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=votanti&amp;num_ref=$cur&amp;num_refs=$num_refs&amp;csv=$csv&amp;xls=$xls&amp;pdf=$pdf\">";
-			
-            $html .= "[ <b>"._NEXT_MATCH."</b> ]</a>";
-        }
-}
-}
-if($genere==5 or $genere==3){ //se vi sono raggruppamenti
-	      if($csv!=1 and $fascia>$limite){
-
-		$pag=($pag==0 ? 1:0);
-		$html .= "<a href=\"modules.php?name=Elezioni&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;op=come&amp;info=votanti&amp;pag=$pag&amp;csv=$csv\"><b>";
-		if($pag) $html .=  _VOTIL;
-	       //_CONTR_CONS;
-		else $html .= _VOTIE; 
-		//_CONTR_ESPR;
-		$html .= "</b></a>";
-	      }
-	}
-	
-
-if($csv==1){
-      $data=date("d-m-y G:i");
-      $html .="<br/><div style=\"margin:0 auto;text-align:center;\"><i>Stampato: $data</i>";
-      $html .="<br/><i>Eleonline by l. apolito & r. gigli - www.eleonline.it</i></div>";		
-      //$html .= $html;	
-      
-}	
-$html .= "</div>";
-
-
+include('votanti-inc.php');
 
 ############### stampa
 if ($xls!='1' && $pdf!='1'){
-      echo "$datipdf $html";
+	  echo "$datipdf $html";
 }elseif($xls=="1"){
 	$nomefile="votanti.xls";
 	header ("Content-Type: application/vnd.ms-excel");
 	header ("Content-Disposition: inline; filename=$nomefile");
-
+	header("Pragma: no-cache");
+	header("Expires: 0");
+	$datipdf = mb_convert_encoding($datipdf , "HTML-ENTITIES", "UTF-8");
 	echo "$datipdf";
 	echo "$html \n";
 }elseif($pdf=='1'){
-
-
-		$nomefile="$descr_cons votanti.pdf";
-
-
-
-
-
-		
-		$stampa ="<div style=\"margin:0 auto;text-align:center;\">$datipdf $html</div>";
-		
-		$html2pdf = new Html2Pdf('P','A4', 'it');
-		$html2pdf->WriteHTML($stampa, isset($_GET['vuehtml']));
-		$html2pdf->Output($nomefile);
-
-
+	$nomefile="$descr_cons votanti.pdf";
+	$stampa ="$datipdf $html";		
+	$html2pdf = new Html2Pdf('P','A4', 'it');
+	$html2pdf->WriteHTML($stampa, isset($_GET['vuehtml']));
+	$html2pdf->Output($nomefile);
 }
-
-
-
-
 if($csv!=1 ) include ("footer.php");
 
-
-
 ?>
Index: trunk/client/temi/Futura2/function_theme.php
===================================================================
--- trunk/client/temi/Futura2/function_theme.php	(revision 375)
+++ trunk/client/temi/Futura2/function_theme.php	(revision 376)
@@ -32,12 +32,12 @@
 if ($siteistat==$id_comune) $logo="$siteistat"; else $logo=''; // logo per il  comune 
 $logo=verificasimbolo(); // carica_logo da funzioni.php
-
-	if ($genere==0) $tab="ref";elseif($genere=='4' || $votog) $tab="lista";
-		 else $tab="gruppo";
+	$tab="gruppo"; $tabr="gruppo";
+	if ($genere==0) $tabr="ref";elseif($genere=='4' || $votog) {$tab="lista"; $tabr="lista";}
+#		 else $tab="gruppo";
 	if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
 	else $circos=''; 
 
 
-	$sql="select t1.id_sez from ".$prefix."_ele_voti_".$tab." as t1 left join ".$prefix."_ele_$tab as t2 on t1.id_$tab=t2.id_$tab where t1.id_cons='$id_cons' $circos group by t1.id_sez ";
+	$sql="select t1.id_sez from ".$prefix."_ele_voti_".$tabr." as t1 left join ".$prefix."_ele_$tab as t2 on t1.id_$tab=t2.id_$tab where t1.id_cons='$id_cons' $circos group by t1.id_sez ";
 	$res = $dbi->prepare("$sql");
 	$res->execute();
Index: trunk/client/versione.php
===================================================================
--- trunk/client/versione.php	(revision 375)
+++ trunk/client/versione.php	(revision 376)
@@ -1,7 +1,7 @@
 <?php
 
-$versione = "3.0 rev 375";
+$versione = "3.0 rev 376";
 $version_number = $versione;
-$datarel = "06 settembre 2022";
+$datarel = "24 settembre 2022";
 $version = "Eleonline $version_number (<i>Data Release: $datarel</i>)";
 
Index: trunk/install/install1.php
===================================================================
--- trunk/install/install1.php	(revision 375)
+++ trunk/install/install1.php	(revision 376)
@@ -14,4 +14,6 @@
 $DBpassword = mosGetParam( $_POST, 'DBpassword', 'password' );
 $DBname  	= mosGetParam( $_POST, 'DBname', 'eleonline' );
+$ELEuserName = mosGetParam( $_POST, 'ELEuserName', 'eleutente' );
+$ELEpassword = mosGetParam( $_POST, 'ELEpassword', 'elepassword' );
 $DBPrefix  	= mosGetParam( $_POST, 'DBPrefix', 'soraldo' );
 
@@ -41,4 +43,8 @@
 		alert('Inserisci un nome per il tuo nuovo Database');
 		f.DBname.focus();
+		formValid=false;
+	} else if ( f.ELEuserName.value == '' ) {
+		alert('Inserisci il nome del nuovo utente che gestirÃ  il Database');
+		f.DBuserName.focus();
 		formValid=false;
 	} else if ( f.DBPrefix.value == '' ) {
@@ -124,5 +130,5 @@
 			  			</td>
 			  			<td>
-			  				<em>Nome dell'account con permessi per creare il database</em>
+			  				<em>Nome dell'account con permessi per creare il database e GRANT</em>
 			  			</td>
   					</tr>
@@ -134,5 +140,5 @@
 			  			</td>
 			  			<td>
-			  				<em>Password per l'account mysql:</em>
+			  				<em>Password dell'account mysql:</em>
 			  			</td>
 					</tr>
@@ -144,7 +150,27 @@
   						</td>
 			  			<td>
-			  				<em>Nome del database di Eleonline.</em>
-			  			</td>
-  					</tr>
+			  				<em>Nome del database di Eleonline da creare.</em>
+			  			</td>
+  					</tr>
+					<tr>
+			  			<td colspan="2">
+			  				MySQL Nuovo utente
+			  				<br/>
+			  				<input class="inputbox" type="text" name="ELEuserName" value="<?php echo "$ELEuserName"; ?>" />
+			  			</td>
+			  			<td>
+			  				<em>Nome dell'account che gestirÃ  il database di eleonline</em>
+			  			</td>
+  					</tr>
+			  		<tr>
+			  			<td colspan="2">
+			  				MySQL Password
+			  				<br/>
+			  				<input class="inputbox" type="text" name="ELEpassword" value="<?php echo "$ELEpassword"; ?>" />
+			  			</td>
+			  			<td>
+			  				<em>Password per il nuovo account mysql:</em>
+			  			</td>
+					</tr>
 					<!--
 					<tr>
Index: trunk/install/install2.php
===================================================================
--- trunk/install/install2.php	(revision 375)
+++ trunk/install/install2.php	(revision 376)
@@ -17,4 +17,6 @@
 $DBuserName = mosGetParam( $_POST, 'DBuserName', '' );
 $DBpassword = mosGetParam( $_POST, 'DBpassword', '' );
+$ELEuserName = mosGetParam( $_POST, 'ELEuserName', '' );
+$ELEpassword = mosGetParam( $_POST, 'ELEpassword', '' );
 $DBname  	= mosGetParam( $_POST, 'DBname', '' );
 $DBPrefix  	= mosGetParam( $_POST, 'DBPrefix', 'soraldo' );
@@ -49,16 +51,42 @@
 		db_err ("stepBack3","The database details provided are incorrect and/or empty.");
 	}
-
+$dsn = "mysql:host=$DBhostname"; #dbname=$DBname";
+$opt = [
+PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+PDO::ATTR_EMULATE_PREPARES => false,
+];
+$user=$DBuserName;
+$password=$DBpassword;
 	
 	if($DBPrefix == '') {
 		db_err ('stepBack','Non avete indicato il prefisso tabelle database.');
 	}
+	try {
+		$database = new PDO($dsn, $user, $password, $opt);
+	 }
+        catch(PDOException $e)
+        {
+            echo $sql . "<br>" . $e->getMessage();die();
+        }
+#sostituire questa riga con le variabili per il nuovo utente e la sua password da inserire nella pagina precedente
+########################################
+#		$DBuserName='eleuser'; $DBpassword='elepass';
 	try{
-	$database = new PDO("mysql:host=$DBhostname;charset=latin1", $DBuserName, $DBpassword, array(PDO::ATTR_EMULATE_PREPARES => false, 
-                                                                                                PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));	
-	$sql = "CREATE DATABASE IF NOT EXISTS $DBname;
-	CREATE USER `$DBuserName`@'$DBhostname' IDENTIFIED BY '$DBpassword';
-        GRANT ALL ON `$DBname`.* TO `$DBuserName`@'$DBhostname';
-        FLUSH PRIVILEGES;";
+	$sql = "CREATE DATABASE IF NOT EXISTS $DBname;";
+    	$database->exec($sql);
+	}
+	catch(PDOException $e)
+	{
+	    echo $sql . "<br>" . $e->getMessage();die();
+	}
+	try {
+	$sql="CREATE USER if not exists `$ELEuserName`@'$DBhostname' IDENTIFIED BY '$ELEpassword';";
+    	$database->exec($sql);
+#        $sql= "GRANT ALL ON `$DBname`.* TO `roby`@'$DBhostname';";
+#    	$database->exec($sql);
+        $sql= "GRANT ALL ON `$DBname`.* TO `$ELEuserName`@'$DBhostname';";
+    	$database->exec($sql);
+        $sql= "FLUSH PRIVILEGES;";
     	$database->exec($sql);
     	$sql = "use $DBname";
Index: trunk/install/install3.php
===================================================================
--- trunk/install/install3.php	(revision 375)
+++ trunk/install/install3.php	(revision 376)
@@ -38,8 +38,8 @@
 $configArray['siteUrl'] = trim( mosGetParam( $_POST, 'siteUrl', '' ) );
 $configArray['absolutePath'] = trim( mosGetParam( $_POST, 'absolutePath', '' ) );
-if (get_magic_quotes_gpc()) {
-	$configArray['absolutePath'] = stripslashes(stripslashes($configArray['absolutePath']));
-	$sitename = stripslashes(stripslashes($sitename));
-}
+#if (get_magic_quotes_gpc()) {
+#	$configArray['absolutePath'] = stripslashes(stripslashes($configArray['absolutePath']));
+#	$sitename = stripslashes(stripslashes($sitename));
+#}
 
 
@@ -185,9 +185,12 @@
 		$url = $configArray['siteUrl'];
 	else {
-		$port = ( $_SERVER['SERVER_PORT'] == 80 ) ? '' : ":".$_SERVER['SERVER_PORT'];
-		$root = $_SERVER['SERVER_NAME'].$port.$_SERVER['PHP_SELF'];
+#		$port = ( $_SERVER['SERVER_PORT'] == 80 ) ? '' : ":".$_SERVER['SERVER_PORT'];
+		$port = ( $_SERVER['SERVER_PORT'] == 80 ) ? 'http://' : "https://";
+#		$root = $_SERVER['SERVER_NAME'].$port.$_SERVER['PHP_SELF'];
+		$root = $_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
 		$root = str_replace("install/","",$root);
 		$root = str_replace("/install3.php","",$root);
-		$url = "http://".$root."/client";
+#		$url = "http://".$root."/client";
+		$url = $port.$root."/client";
 	}
 ?>
Index: trunk/install/install4.php
===================================================================
--- trunk/install/install4.php	(revision 375)
+++ trunk/install/install4.php	(revision 376)
@@ -137,9 +137,9 @@
 
 if ($sitename) {
-	if (!get_magic_quotes_gpc()) {
+#	if (!get_magic_quotes_gpc()) {
 		$configArray['sitename'] = addslashes($sitename);
-	} else {
-		$configArray['sitename'] = $sitename;
-	}
+#	} else {
+#		$configArray['sitename'] = $sitename;
+#	}
 } else {
 	echo "<form name=\"stepBack\" method=\"post\" action=\"install3.php\">
@@ -310,5 +310,5 @@
 	$query = "INSERT INTO {$configArray['DBPrefix']}_ele_comuni VALUES ('$istat', '$nomecomune', '','','','','$Limite','$Capoluogo','','','0','')";
 	$database->exec( $query );
-	} catch(PDOException $e) {}
+	} catch(PDOException $e) { die("$query");}
 	$query = "UPDATE {$configArray['DBPrefix']}_config SET sitename='$sitename', siteurl='$siteUrl', adminmail='$adminEmail', tema='$tema', foot='',language='$Lingua',blocco='$blocco',fileout='$Replica',Versione='3', siteistat='$istat',multicomune='$Multicomune',flash='$flash', tema_on='$sceltatema'   WHERE sitename=''";
 	
