Index: trunk/client/modules/Elezioni/grafici.php
===================================================================
--- trunk/client/modules/Elezioni/grafici.php	(revision 130)
+++ trunk/client/modules/Elezioni/grafici.php	(revision 132)
@@ -26,5 +26,5 @@
 
 function affluenze_graf(){
-global $bgcolor1, $bgcolor2, $prefix, $dbi, $offset,$genere,$votog,$votol,$votoc,$circo, $min,$id_cons,$tipo_cons,$id_cons_gen,$csv,$id_comune,$id_circ;
+global $bgcolor1, $bgcolor2, $prefix, $dbi, $offset,$genere,$votog,$votol,$votoc,$circo, $min,$id_cons,$tipo_cons,$id_cons_gen,$csv,$id_comune,$id_circ, $tema;
 // icone
 	if ($circo) $circos="and t2.id_circ='$id_circ'";
@@ -89,7 +89,7 @@
                                                                                                                            // totali
 										  
+if($tema=='tour') $andcond='data desc,orario desc limit 0,1'; else $andcond='data,orario';    
     
-    
-    $res = mysql_query("select orario,data  from ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data,orario", $dbi);
+    $res = mysql_query("select orario,data  from ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by $andcond", $dbi);
         while(list($orario,$data) = mysql_fetch_row($res)) {
         	list ($ore,$minuti,$secondi)=explode(':',$orario);
@@ -158,5 +158,5 @@
 
 function graf_votanti(){
-global $op, $prefix, $dbi, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$tipo_cons,$id_comune,$id_cons_gen,$id_circ,$csv,$w,$l,$siteistat,$flash,$tour;
+global $op, $prefix, $dbi, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$tipo_cons,$id_comune,$id_cons_gen,$id_circ,$csv,$w,$l,$siteistat,$flash,$tour,$tema;
 
 
@@ -227,15 +227,15 @@
 	if ($numero!=0){
 
-	echo "<center><h2><br />";
+
+
+
+	$res1 = mysql_query("SELECT sum(maschi+femmine) from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' $circos",$dbi);
+	list($tot_aventi)  = mysql_fetch_row($res1);
+     
+	if ($genere!=0) {
+	echo "<center><h2>";
 	echo "<b>"._DETTAGLIO." "._VOTIE."</b> - ";
 	echo "<i> "._SEZSCRU." $numero "._SU." $sezioni </i>";
-	echo "<br /></h2></center>";
-
-
-
-	$res1 = mysql_query("SELECT sum(maschi+femmine) from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' $circos",$dbi);
-	list($tot_aventi)  = mysql_fetch_row($res1);
-        
-	if ($genere!=0) {
+	echo "</h2></center>";
 
 		$res1 = mysql_query("SELECT sum(validi+nulli+bianchi+contestati) as tot,
@@ -243,4 +243,24 @@
 		from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' $circos having tot>0",$dbi);
 	}else{
+
+		if($tema=='tour'){
+
+		  list($max_ruotag) =mysql_fetch_row($res1);
+			if (isset($_SESSION['ruotag'])) { $ruotag=$_SESSION['ruotag'];}
+			else {$ruotag=1;$_SESSION['ruotag']=1;}
+			if ($ruotag>=$max_ruotag) {$ruotag=1;}
+			else {$ruotag++;}
+			$_SESSION['ruotag']=$ruotag;
+			  		$res1 = mysql_query("SELECT count(0) from ".$prefix."_ele_voti_ref AS t1 LEFT JOIN ".$prefix."_ele_gruppo AS t2 ON t1.id_gruppo = t2.id_gruppo WHERE t1.id_cons ='$id_cons' AND t2.num_gruppo ='$ruotag'",$dbi);
+		list($numero)=mysql_fetch_row($res1);
+	echo "<center><h2>";
+	echo "<b>"._DETTAGLIO." "._VOTIE."</b> - ";
+	echo "<i> "._SEZSCRU." $numero "._SU." $sezioni </i>";
+	echo "</h2></center>";
+		
+		$res1 = mysql_query("SELECT sum( t1.validi + t1.nulli + t1.bianchi + t1.contestati ) AS tot, sum( t1.validi ) , sum( t1.nulli ) , sum( t1.bianchi ) , sum( t1.contestati ) , t1.id_gruppo
+FROM ".$prefix."_ele_voti_ref AS t1 LEFT JOIN ".$prefix."_ele_gruppo AS t2 ON t1.id_gruppo = t2.id_gruppo
+WHERE t1.id_cons ='$id_cons' AND t2.num_gruppo ='$ruotag' GROUP BY t1.id_gruppo HAVING tot >0",$dbi);
+	}	else
 		$res1 = mysql_query("SELECT sum(validi+nulli+bianchi+contestati) as tot,
 		sum(validi),sum(nulli),sum(bianchi),sum(contestati), id_gruppo
@@ -272,22 +292,23 @@
 		
 		
-
 		    
-		echo "<table  width=\"100%\" class=\"modulo\"><tr><td valign=\"top\" >";
-		
-		echo "<table width=\"500\" cellspacing=\"3\" style=\"text-align:center;\">";
-		if ($genere==0) {echo "<tr><td><h4>"._GRUPPO." $num_gruppo <br/> $descr_gruppo</h4><br/><br/></td></tr>";}
+		echo "<table  width=\"100%\" class=\"modulo\"><tr>";
+		if ($genere==0) echo "<td colspan=\"2\" valign=\"top\" >";
+		else echo "<td valign=\"top\" >";
+		
+		echo "<table cellspacing=\"5\" style=\"text-align:center;\">";
+		if ($genere==0) {echo "<tr><td colspan=\"4\"><h4>"._GRUPPO." $num_gruppo <br/> $descr_gruppo</h4></td></tr>";}
 		echo "
-		<tr class=\"bggray3\"><td ><b>"._AVENTI."</b></td><td>$tot_aventi</td><td><span class=\"red\">100%</span></td></tr>
-
-		<tr class=\"bggray3\"><td><b>"._VOTANTI."</b></td><td>$tot_votanti</td><td><span class=\"red\">$perc_votanti%</span></td></tr>
-		
-		<tr class=\"bggray3\"><td>"._VALIDI."</td><td>$validi</td><td><span class=\"red\">$perc_validi%</span></td></tr>
-		
-		<tr class=\"bggray3\"><td>"._NULLI."</td><td>$nulli</td><td><span class=\"red\">$perc_nulli%</span></td></tr>
-		
-		<tr class=\"bggray3\"><td>"._BIANCHI."</td><td>$bianchi</td><td><span class=\"red\">$perc_bianchi%</span></td></tr>
-		
-		<tr class=\"bggray3\"><td>"._CONTESTATI."</td><td>$contestati</td><td><span class=\"red\">$perc_conte%</span></td></tr>
+		<tr class=\"bggray3\"><td style=\"text-align: right;\"><b>"._AVENTI."</b></td><td>$tot_aventi</td><td><span class=\"red\">100%</span></td></td></td></tr>
+
+		<tr class=\"bggray3\"><td style=\"text-align: right;\"><b>"._VOTANTI."</b></td><td>$tot_votanti</td><td><span class=\"red\">$perc_votanti%</span></td></tr>
+		
+		<tr class=\"bggray3\"><td style=\"text-align: right;\">"._VALIDI."</td><td>$validi</td><td><span class=\"red\">$perc_validi%</span></td></tr>
+		
+		<tr class=\"bggray3\"><td style=\"text-align: right;\">"._NULLI."</td><td>$nulli</td><td><span class=\"red\">$perc_nulli%</span></td></tr>
+		
+		<tr class=\"bggray3\"><td style=\"text-align: right;\">"._BIANCHI."</td><td>$bianchi</td><td><span class=\"red\">$perc_bianchi%</span></td></tr>
+		
+		<tr class=\"bggray3\"><td style=\"text-align: right;\">"._CONTESTATI."</td><td>$contestati</td><td><span class=\"red\">$perc_conte%</span></td></tr>
 
 		</table>";
@@ -337,5 +358,5 @@
 
 function graf_gruppo(){
-global $admin, $bgcolor1, $bgcolor5, $prefix, $dbi, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$id_cons_gen,$id_comune,$id_circ,$tipo_cons,$w,$l,$op,$siteistat,$flash,$visgralista;
+global $admin, $bgcolor1, $bgcolor5, $prefix, $dbi, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$id_cons_gen,$id_comune,$id_circ,$tipo_cons,$w,$l,$op,$siteistat,$flash,$visgralista,$tema;
 if ($siteistat==$id_comune) $logo=$siteistat; else $logo=''; // logo per il  comune
 $logo=verificasimbolo(); // carica_logo da funzioni.php
@@ -540,4 +561,12 @@
 	}else{
 		// tot voti
+		if($tema=='tour'){
+				$res1 = mysql_query("SELECT count(0)
+		from ".$prefix."_ele_gruppo  where id_cons=$id_cons",$dbi);
+		  list($max_ruotag) =mysql_fetch_row($res1);
+			if (isset($_SESSION['ruotag'])) { $ruotag=$_SESSION['ruotag'];}
+			else {$ruotag=1;$_SESSION['ruotag']=1;}
+			$res = mysql_query("select sum(t1.validi),t1.id_gruppo from ".$prefix."_$tab as t1 left join soraldo_ele_gruppo as t2 on t1.id_gruppo=t2.id_gruppo where t1.id_cons='$id_cons' and t2.num_gruppo='$ruotag' group by t1.id_gruppo",  $dbi);
+		}else
 		$res = mysql_query("
 		select sum(validi),id_gruppo  from ".$prefix."_$tab where id_cons=$id_cons group by id_gruppo",  $dbi);
@@ -569,8 +598,8 @@
 				echo "<tr><td bgcolor=\"$bgcolor1\">$num_gruppo - $descrizione</b></td></tr><tr></table>
 				<table><tr>
-				<td >"._SI."</td><td>$si</td>
-				<td >%</td><td>$percsi</td>
-				<td >"._NO."</td><td>$no</td>
-				<td >%</td><td>$percno</td><tr>
+				<td ><b>"._SI.":</b> </td><td>$si</td>
+				<td ><b>%</b> </td><td>$percsi</td>
+				<td ><b>"._NO.":</b> </td><td>$no</td>
+				<td ><b>%</b> </td><td>$percno</td><tr>
 				</table></td><td><center><br />";
 
@@ -695,5 +724,5 @@
 function flash_torta($gruppos,$pre,$y,$x){
 //if (!defined('FLASH')) die();
-
+include_once ("class/charts.php");
 // inizio grafico torta flash
 		
Index: trunk/client/modules/Elezioni/index.php
===================================================================
--- trunk/client/modules/Elezioni/index.php	(revision 130)
+++ trunk/client/modules/Elezioni/index.php	(revision 132)
@@ -684,13 +684,13 @@
 				}else{ $perc_si=0;$perc_no=0;}
 
-				
-				
+				$var1="<table class=\"table-80\" style=\"text-align: center;\">";
+				
+			if($ora){	
 				list ($ore,$minuti,$secondi)=explode(':',$ora);
-				$var1="<table class=\"table-80\">
-					<tr>
+				$var1.=	"<tr>
 					<td class=\"redbig\">
 				<h2>"._PERC_ASS." $ore,$minuti:<span class=\"redbig\"> $perc_tot% </span></h2></td>
 					</tr>";
-				
+				}
 				
 				$var1 .="<tr>
@@ -711,5 +711,5 @@
 			echo "<tr>
 			<td class=\"bggray\"><h1><b>$num_gruppo</b></h1></td>
-			<td class=\"table-main\"><h1>$descr_gruppo</h1> $var1</td>";
+			<td class=\"table-main\" style=\"text-align: left;\"><h1>$descr_gruppo</h1> $var1</td>";
 			if($tipo_cons!=2 and $prognome)
 				echo "<td onmouseover=\"this.style.cursor='pointer';\" onclick=\"javascript:window.open('modules.php?name=Elezioni&amp;file=foto&amp;id_gruppo=$id_gruppo2&amp;pdfvis=1')\">";
