Index: trunk/admin/modules/Elezioni/ele_colora_sez.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_colora_sez.php	(revision 327)
+++ trunk/admin/modules/Elezioni/ele_colora_sez.php	(revision 328)
@@ -43,7 +43,11 @@
 				if($genere)
 					$sql="SELECT id_gruppo FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'";
-				else
+				else{
+					$sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons'";
+					$res = $dbi->prepare("$sql");
+					$res->execute();
+					$righeref=$res->rowCount();
 					$sql="SELECT id_gruppo FROM ".$prefix."_ele_voti_ref where id_sez='$id_sez'";
-
+				}
 				$res = $dbi->prepare("$sql");
 				$res->execute();
@@ -52,5 +56,7 @@
 			if($righe){ 
 				$sezstat=4;
-				$sql="UPDATE ".$prefix."_ele_sezioni set colore='#B0C4DE' where id_cons='$id_cons' and id_sez='$id_sez'"; #"LIGHTSTEELBLUE"
+				if($genere==0 and $righe==$righeref)
+					$sql="UPDATE ".$prefix."_ele_sezioni set colore='#99CC33' where id_cons='$id_cons' and id_sez='$id_sez'"; #VERDE					
+				else $sql="UPDATE ".$prefix."_ele_sezioni set colore='#B0C4DE' where id_cons='$id_cons' and id_sez='$id_sez'"; #"LIGHTSTEELBLUE"
 				$res = $dbi->prepare("$sql");
 				$res->execute();
Index: trunk/admin/modules/Elezioni/ele_controlli.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_controlli.php	(revision 327)
+++ trunk/admin/modules/Elezioni/ele_controlli.php	(revision 328)
@@ -79,5 +79,5 @@
 			$rifscru++;
 			list($si,$no,$validi,$nulli,$bianchi,$contestati)=$res2->fetch(PDO::FETCH_NUM);
-			if(($si+$no==$validi) and ($validi+$nulli+$bianchi+$contestati==$voti)) 
+			if($validi and ($si+$no==$validi) and ($validi+$nulli+$bianchi+$contestati==$voti)) 
 				continue;
 			else {$err=1; break;}	
@@ -207,5 +207,5 @@
 		$rifscru++;
 		list($si,$no,$validi,$nulli,$bianchi,$contestati)=$res2->fetch(PDO::FETCH_NUM);
-		if(($si+$no==$validi) and ($validi+$nulli+$bianchi+$contestati==$voti)) 
+		if(!$validi or (($si+$no==$validi) and ($validi+$nulli+$bianchi+$contestati==$voti))) 
 			continue;
 		else {$err=1; $idrg=$idrefgruppo; break;}	
Index: trunk/admin/modules/Elezioni/ele_riepilogo.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_riepilogo.php	(revision 327)
+++ trunk/admin/modules/Elezioni/ele_riepilogo.php	(revision 328)
@@ -84,5 +84,5 @@
 		$resref = $dbi->prepare("$sql");
 		$resref->execute();	
-		list($numgruppo,$descrizione) = mysql_fetch_row($resref);
+		list($numgruppo,$descrizione) = $resref->fetch(PDO::FETCH_NUM);
 		echo "<fieldset><legend>"._GRUPPO."N. $numgruppo - $descrizione</legend>";
 		echo "<table border=\"1\" width=\"100%\"><tr><th><b> "._SI." </b></th><th><b>"._NO."</b></th><th><b>"._VALIDI."</b></th><th>"._NULLI."</th><th>"._BIANCHI."</th><th>"._CONTESTATI."</th><th>"._TOTNON."</th></TR>";
Index: trunk/admin/modules/Elezioni/ele_voti.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_voti.php	(revision 327)
+++ trunk/admin/modules/Elezioni/ele_voti.php	(revision 328)
@@ -1454,12 +1454,17 @@
 		echo "<td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
 		."</td><td align=\"left\" width=\"50%\"><b> $descr[0] </b>";
-        $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'0';
-        $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'0';
-        $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'0';
-        $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'0';
-        $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'0';
-        $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'0';
-		$tot_nulli=$pro['nulli']+$pro['bianchi']+$pro['contestati'];
-		$tot_voti=$pro['validi']+$tot_nulli;
+        $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'';
+        $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'';
+        $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'';
+        $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'';
+        $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'';
+        $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'';
+		if($pro['validi']=='' or $pro['nulli']=='' or $pro['bianchi']=='' or $pro['contestati']==''){
+			$tot_nulli=0;
+			$tot_voti=0;
+		}else{
+			$tot_nulli=$pro['nulli']+$pro['bianchi']+$pro['contestati'];
+			$tot_voti=$pro['validi']+$tot_nulli;
+		}
 		echo "</td><td align=\"right\" width=\"3%\"><input  name=\"si$i\" value=\"".$pro['si']."\" size=\"7\"  style=\"text-align:right\"></td>";
 		echo "</td><td align=\"right\" width=\"3%\"><input  name=\"no$i\" value=\"".$pro['no']."\" size=\"7\"  style=\"text-align:right\"></td>";
Index: trunk/admin/modules/Elezioni/salva_ref.php
===================================================================
--- trunk/admin/modules/Elezioni/salva_ref.php	(revision 327)
+++ trunk/admin/modules/Elezioni/salva_ref.php	(revision 328)
@@ -56,4 +56,7 @@
 		$res = $dbi->prepare("$sql");
 		$res->execute();
+		$sql="delete from ".$prefix."_ele_controlli where id_cons='$id_cons' and id_sez=$id_sez";
+		$res = $dbi->prepare("$sql");
+		$res->execute();
 	}else{
 		while(list($i,$idgruppo)=$resultg->fetch(PDO::FETCH_BOTH)) {
@@ -74,5 +77,5 @@
 				$res = $dbi->prepare("$sql");
 				$res->execute();
-			}else{
+			}elseif($val[$i]!=''){
 				$sql="insert into  ".$prefix."_ele_voti_ref values('$id_cons','$idgruppo','$id_sez','$i','".$si[$i]."','".$no[$i]."','".$val[$i]."','".$nul[$i]."','".$bia[$i]."','".$con[$i]."')";  
 				$res = $dbi->prepare("$sql");
@@ -81,9 +84,10 @@
 			}
 		}
-}
+		include("ele_controlli.php");
+		controllo_votir($id_cons,$id_sez);
+	}
 
 
-include("ele_controlli.php");
-controllo_votir($id_cons,$id_sez);
+
 include("ele_colora_sez.php");
 if ($fileout) fclose($fp);
