Index: trunk/client/temi/Futura2/function_theme.php
===================================================================
--- trunk/client/temi/Futura2/function_theme.php	(revision 362)
+++ trunk/client/temi/Futura2/function_theme.php	(revision 364)
@@ -39,7 +39,7 @@
 
 
-	$sql="select t1.*  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 ";
-		$res = $dbi->prepare("$sql");
-		$res->execute();
+	$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 ";
+	$res = $dbi->prepare("$sql");
+	$res->execute();
 	if($res)
 		$numero=$res->rowCount();
@@ -47,6 +47,6 @@
 	$numero=1;
 	$sql="select t1.*  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";
-		$res = $dbi->prepare("$sql");
-		$res->execute();
+	$res = $dbi->prepare("$sql");
+	$res->execute();
 	$sezioni=$res->rowCount();
 	if ($numero!=0){
@@ -187,7 +187,7 @@
 	if ($genere==4 or $visgralista){$tab="ele_voti_lista";}
 	if ($votog){$tab="ele_voti_lista";}
-	$sql="select *  from ".$prefix."_$tab where id_cons='$id_cons' group by id_sez ";
-		$res = $dbi->prepare("$sql");
-		$res->execute();
+	$sql="select id_sez from ".$prefix."_$tab where id_cons='$id_cons' group by id_sez ";
+	$res = $dbi->prepare("$sql");
+	$res->execute();
 	if ($circo){
 		$sql="select t1.*  from ".$prefix."_ele_voti_gruppo as t1, ".$prefix."_ele_gruppo as t2 where t1.id_gruppo=t2.id_gruppo and t1.id_cons='$id_cons' and t2.id_circ=$id_circ group by t1.id_sez ";
@@ -248,5 +248,5 @@
         			left join ".$prefix."_$tab as t2 on (t1.id_gruppo=t2.id_gruppo)
 				where 	t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons $circondt1
-				group by t2.id_gruppo
+				group by t1.id_gruppo, t1.num_gruppo, t1.descrizione
 				order by somma desc";
 				$cosa='id_gruppo';
@@ -474,11 +474,11 @@
 	if ($circo) $circos = "and id_circ=$id_circ" ; else $circos='';
 	if ($genere==0) $tab="ref"; else $tab="gruppo";
-	$sql="select *  from ".$prefix."_ele_voti_".$tab." where id_cons='$id_cons'  $circos group by id_sez ";
-				$res = $dbi->prepare("$sql");
-				$res->execute();
+	$sql="select id_sez from ".$prefix."_ele_voti_".$tab." where id_cons='$id_cons'  $circos group by id_sez ";
+	$res = $dbi->prepare("$sql");
+	$res->execute();
 	$numero=$res->rowCount();
 	$sql="select *  from ".$prefix."_ele_sezioni where id_cons='$id_cons' $circos ";
-				$res = $dbi->prepare("$sql");
-				$res->execute();
+	$res = $dbi->prepare("$sql");
+	$res->execute();
 	$sezioni=$res->rowCount();
 	//$res = mysql_query("select chiusa  from ".$prefix."_ele_cons_comuni where id_cons='$id_cons' $circos ",$dbi);
@@ -606,9 +606,6 @@
 				left join ".$prefix.$scelta."
 				where t1.id_cons='$id_cons'
-				group by t2.id_cand
-				 
-				order by somma desc
-				
-				";
+				group by t1.id_lista, t1.id_cand, t1.nome, t1.cognome
+				order by somma desc";
 			$res = $dbi->prepare("$sql");
 			$res->execute();
@@ -679,5 +676,5 @@
 
 	// numero sezioni 
-	$sql="select t3.*  from ".$prefix."_ele_voti_".$tab." 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  group by t3.id_sez ";
+	$sql="select t3.id_sez  from ".$prefix."_ele_voti_".$tab." 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  group by t3.id_sez ";
 	$sez_num = $dbi->prepare("$sql");
 	$sez_num->execute();
@@ -1135,5 +1132,5 @@
 	
 
-  		$sql="select t3.*  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' and t3.data='$data' and t3.orario='$orario'   group by t3.id_sez ";
+  		$sql="select t3.id_sez 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' and t3.data='$data' and t3.orario='$orario' group by t3.id_sez ";
 		$res1 = $dbi->prepare("$sql");
 		$res1->execute();
@@ -1215,5 +1212,5 @@
 if ($genere==0) $tab="ref";
 
-  	$sql="select t3.*  from ".$prefix."_ele_voti_".$tab." 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  group by t3.id_sez ";
+  	$sql="select t3.id_sez from ".$prefix."_ele_voti_".$tab." 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  group by t3.id_sez ";
 	$res = $dbi->prepare("$sql");
 	$res->execute();
