Index: trunk/admin/modules/Elezioni/ele_associazioni.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_associazioni.php	(revision 234)
+++ trunk/admin/modules/Elezioni/ele_associazioni.php	(revision 235)
@@ -45,4 +45,5 @@
 if (isset($_GET['preferenze'])) $preferenze=intval($_GET['preferenze']); else $preferenze=1;
 if (isset($_GET['vismf'])) $vismf=intval($_GET['vismf']); else $vismf=0;
+if (isset($_GET['sg'])) $sg=intval($_GET['sg']); else $sg=0;
 
 $offset=15;
@@ -55,5 +56,5 @@
 	//
 	function all() {
-	global $user, $admin, $bgcolor1, $bgcolor2, $prefix,$descr_cons, $dbi,$id_cons,$desc,$indirizzo,$centralino,$fax,$id_cons_gen,$id_collegio,$idcomune,$chiusa,$id_conf,$tipo_cons,$language,$help,$preferenze,$idfascia,$vismf;
+	global $user, $admin, $bgcolor1, $bgcolor2, $prefix,$descr_cons, $dbi,$id_cons,$desc,$indirizzo,$centralino,$fax,$id_cons_gen,$id_collegio,$idcomune,$chiusa,$id_conf,$tipo_cons,$language,$help,$preferenze,$idfascia,$vismf,$sg;
 $aid=$_SESSION['aid'];
 $dbi=$_SESSION['dbi'];
@@ -131,4 +132,5 @@
 		}
 	echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VISAFFMF."</b></td>";
+	echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._ASOLO_GRUPPO."</b></td>";
 #	echo "<input type=\"hidden\" name=\"pag_cons\" value=\"admin.php?op=associazioni&amp;id_cons_gen=\">";
 	echo "</tr>";
@@ -209,10 +211,16 @@
 	}
 	unset($sel);
-	$rescomu = mysql_query("SELECT vismf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'", $dbi);
-	list($vismf)=mysql_fetch_row($rescomu);
+	$rescomu = mysql_query("SELECT vismf,solo_gruppo from ".$prefix."_ele_cons_comune where id_cons='$id_cons'", $dbi);
+	list($vismf,$sg)=mysql_fetch_row($rescomu);
 	echo "<td><select name=\"vismf\">";
 	if ($vismf==0) $sel="selected"; else $sel="";
 	echo "<option value=\"0\" $sel>No";
 	if ($vismf==1) $sel="selected"; else $sel="";
+	echo "<option value=\"1\" $sel>Si";
+	echo "</select></td>";
+	echo "<td><select name=\"sg\">";
+	if ($sg==0) $sel="selected"; else $sel="";
+	echo "<option value=\"0\" $sel>No";
+	if ($sg==1) $sel="selected"; else $sel="";
 	echo "<option value=\"1\" $sel>Si";
 	echo "</select></td>";
@@ -245,4 +253,5 @@
 		}
 	echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VISAFFMF."</b></td>";
+#	echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SG."</b></td>";
 	echo "<td width=\"10\" bgcolor=\"$bgcolor1\"><b>&nbsp;"._FUNZIONI."</td></tr>";
 ###############
@@ -251,5 +260,5 @@
 #	$resmod = mysql_query("SELECT t1.id_collegio,t1.id_comune,t2.descrizione as descr,t1.id_cons, t3.descrizione, t4.chiusa,t4.id_conf FROM ".$prefix."_ele_comu_collegi as t1, ".$prefix."_ele_collegi as t2, ".$prefix."_ele_comuni as t3, ".$prefix."_ele_cons_comune as t4 where t1.id_cons_gen='$id_cons_gen' and t1.id_collegio=t2.id_collegio and t1.id_comune=t3.id_comune and t1.id_comune=t4.id_comune and t2.id_cons_gen=t4.id_cons_gen order by t2.descrizione, t3.descrizione", $dbi);
 #	else
-	$resmod = mysql_query("SELECT '',t1.id_comune,'',t1.id_cons, t2.descrizione, t1.chiusa, t1.id_conf, preferenze,t1.id_fascia,t1.vismf FROM ".$prefix."_ele_cons_comune as t1, ".$prefix."_ele_comuni as t2 where t1.id_cons_gen='$id_cons_gen' and t1.id_comune=t2.id_comune order by t2.descrizione", $dbi);
+	$resmod = mysql_query("SELECT '',t1.id_comune,'',t1.id_cons, t2.descrizione, t1.chiusa, t1.id_conf, preferenze,t1.id_fascia,t1.vismf,t1.solo_gruppo FROM ".$prefix."_ele_cons_comune as t1, ".$prefix."_ele_comuni as t2 where t1.id_cons_gen='$id_cons_gen' and t1.id_comune=t2.id_comune order by t2.descrizione", $dbi);
 	while (list($id_collegio,$id_comune2,$descr_coll,$id_cons_comu,$descr_comu, $chiusa,$id_conf,$preferenze2,$fasciacom,$vismf) = mysql_fetch_row($resmod)){ //elenco dei modelli inseriti
 		$resconf = mysql_query("SELECT descrizione FROM ".$prefix."_ele_conf where id_conf='$id_conf'", $dbi);
@@ -290,4 +299,6 @@
 		if ($vismf==0) $sel=_NO; else $sel=_SI;
 		echo "<td width=\"10%\">$sel</td>";
+#		if ($sg==0) $sel=_NO; else $sel=_SI;
+#		echo "<td width=\"10%\">$sel</td>";
 		echo "<td width=\"10\"><input type=\"hidden\" name=\"ok\" value=0><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
 			."</td></tr></table></form></td></tr>\n";
@@ -300,5 +311,5 @@
 
 function associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$id_comune,$chiusa,$id_conf,$preferenze) {
-	global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons,$genere,$id_cons_gen,$idcomunenew,$pwd4,$idfascia,$vismf;
+	global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons,$genere,$id_cons_gen,$idcomunenew,$pwd4,$idfascia,$vismf,$sg;
 	$delcons=0;
 	if ($do !="" and $id_cons_gen>0 and $idcomunenew>0) {
@@ -307,5 +318,5 @@
 			list($delcons)=mysql_fetch_row($rescomu);
 			if (!$max){			//se no la inserisce
-			$result = mysql_query("insert into ".$prefix."_ele_cons_comune (chiusa,id_comune,id_cons_gen,id_conf,preferenze,id_fascia,vismf) values ('0','$idcomunenew','$id_cons_gen','$id_conf','$preferenze','$idfascia','$vismf')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
+			$result = mysql_query("insert into ".$prefix."_ele_cons_comune (chiusa,id_comune,id_cons_gen,id_conf,preferenze,id_fascia,vismf,solo_gruppo) values ('0','$idcomunenew','$id_cons_gen','$id_conf','$preferenze','$idfascia','$vismf','$sg')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
 			$rescomu = mysql_query("SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'", $dbi);
 		list($id_cons_comu)=mysql_fetch_row($rescomu);
@@ -321,5 +332,5 @@
 			$result = mysql_query("update ".$prefix."_ele_comu_collegi set id_collegio= '$id_collegio' $newid where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'", $dbi) || die(mysql_error());
 			if (!$result) return;
-			$result = mysql_query("update ".$prefix."_ele_cons_comune set id_conf='$id_conf', chiusa= '$chiusa', preferenze='$preferenze',id_fascia='$idfascia',vismf='$vismf' where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'", $dbi)|| die(mysql_error());
+			$result = mysql_query("update ".$prefix."_ele_cons_comune set id_conf='$id_conf', chiusa= '$chiusa', preferenze='$preferenze',id_fascia='$idfascia',vismf='$vismf',solo_gruppo='$sg' where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'", $dbi)|| die(mysql_error());
 			Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
 		}elseif ($do == "add") {
Index: trunk/admin/modules/Elezioni/ele_riepilogo.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_riepilogo.php	(revision 234)
+++ trunk/admin/modules/Elezioni/ele_riepilogo.php	(revision 235)
@@ -58,4 +58,6 @@
 	ECHO "<TR><TH>".number_format($totel,0,',','.')."</TH><TH>".number_format($totm,0,',','.')."</TH><TH>".number_format($totf,0,',','.')."</TH><TH>".number_format($votm,0,',','.')."</TH><TH>".number_format($votf,0,',','.')."</TH><TH>".number_format($votc,0,',','.')."</TH></TR></table><br/>";
 	ECHO "</fieldset><br/><br/><br/>";
+	
+	
 	$totnulli=$nulli+$bianchi+$contestati+$votinulli;
 	if ($votog) echo "<fieldset><legend>"._VOTI_LISTA."</legend>";
@@ -64,9 +66,11 @@
 	ECHO "<TR><TH>".number_format($validi,0,',','.')."</TH><TH>".number_format($nulli,0,',','.')."</TH><TH>".number_format($bianchi,0,',','.')."</TH><TH>".number_format($contestati,0,',','.')."</TH><TH>".number_format($votinulli,0,',','.')."</TH><TH>".number_format($totnulli,0,',','.')."</TH></TR></table><br/>";
 	ECHO "</fieldset><br/><br/><br/>";
+	
+	
 	if ($genere==5 and !$votog) {
 	$totnullil=$nullilista+$contestatilista;
 	$id_conf=0;
-	$res = mysql_query("SELECT t1.id_conf,t1.id_fascia, t2.limite from ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_conf as t2 on t1.id_conf=t2.id_conf where t1.id_cons='$id_cons'", $dbi);
-	if($res) list($id_conf,$fascia,$limite) = mysql_fetch_row($res);
+	$res = mysql_query("SELECT t1.id_conf,t1.id_fascia, t2.limite, t1.solo_gruppo from ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_conf as t2 on t1.id_conf=t2.id_conf where t1.id_cons='$id_cons'", $dbi);
+	if($res) list($id_conf,$fascia,$limite,$dettnulli) = mysql_fetch_row($res);
 	if ($id_conf and $fascia<=$limite) {
 	echo "<fieldset><legend>"._VOTI_LISTA."</legend>";
@@ -74,6 +78,23 @@
 	ECHO "<TR><TH>".number_format($validi,0,',','.')."</TH><TH>".number_format($nulli,0,',','.')."</TH><TH>".number_format($bianchi,0,',','.')."</TH><TH>".number_format($contestati,0,',','.')."</TH><TH>".number_format($votinulli,0,',','.')."</TH><TH>".number_format($totnulli,0,',','.')."</TH></TR></table><br/>";
 	ECHO "</fieldset><br/><br/><br/>";
+	
 	}else{
-		echo "<fieldset><legend>"._VOTI_LISTA."</legend>";
+	if ($dettnulli){ 
+			$res = mysql_query("SELECT id_gruppo,num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_cons='$id_cons' order by num_gruppo", $dbi);
+
+	echo "<fieldset><legend>"._GRUPPO."</legend>";
+	echo "<table border=\"1\" width=\"100%\"><tr><th colspan=\"2\" rowspan=\"2\" ALIGN=\"CENTER\"><b>Candidato</b></th><th rowspan=\"2\" ALIGN=\"CENTER\">"._VALIDI."</th><th colspan=\"2\" ALIGN=\"CENTER\">"._SOLO_GRUPPO."</th></tr><tr><th ALIGN=\"CENTER\">Senza indicazione di lista</th><th>"._VOTINULLI." di Lista</th></TR>";
+	while(list($id_gruppo,$num_gruppo,$desc) = mysql_fetch_row($res)){
+		$resv = mysql_query("SELECT sum(voti),sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_gruppo='$id_gruppo'", $dbi);
+		list($voti,$solo_gruppo)=mysql_fetch_row($resv);
+		$resv = mysql_query("SELECT sum(t1.nulli_lista) from ".$prefix."_ele_voti_lista as t1 left join ".$prefix."_ele_lista as t2 on t1.id_lista=t2.id_lista where t2.id_gruppo='$id_gruppo'", $dbi);
+		list($nulli_lista)=mysql_fetch_row($resv);
+			
+		ECHO "<TR><TD>".$num_gruppo."</TD><TD>".$desc."</TD><TD ALIGN=\"RIGHT\">".number_format($voti,0,',','.')."</TD><TD ALIGN=\"RIGHT\">".number_format($solo_gruppo,0,',','.')."</TD><TD ALIGN=\"RIGHT\">".number_format($nulli_lista,0,',','.')."</TD></TD></TR>";
+	}
+	ECHO "</table><br/></fieldset><br/><br/><br/>";
+
+	}
+	echo "<fieldset><legend>"._VOTI_LISTA."</legend>";
 	echo "<table border=\"1\" width=\"100%\"><tr><th>"._VALIDI."</th><th>"._VOTINULLI."</th><th>"._CONTESTATI."</th>";
 	// if ($genere==5 and !$votog)
Index: trunk/admin/modules/Elezioni/ele_voti.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_voti.php	(revision 234)
+++ trunk/admin/modules/Elezioni/ele_voti.php	(revision 235)
@@ -43,5 +43,5 @@
 include("modules/Elezioni/funzionidata.php");
 include("modules/Elezioni/ele.php");
-global $votolista, $limite;
+global $votolista, $limite, $dettnulli;
 if(!isset($votolista)) $votolista=0;
 $res = mysql_query("SELECT tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" , $dbi);
@@ -50,4 +50,6 @@
 $res = mysql_query("SELECT count(id_circ) FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ", $dbi);
 list($num_circ)=mysql_fetch_row($res);
+$res = mysql_query("SELECT solo_gruppo FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ", $dbi);
+list($dettnulli)=mysql_fetch_row($res);
 if ($conscirc){  // or $num_circ==1
 	if (!$id_circ){
@@ -533,5 +535,6 @@
 function preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
  	global $aid, $prefix, $dbi, $id_lista,$genere,$id_cons_gen,$id_gruppo,$sezi,$circo,$votog,$votol,$votoc,$conscirc;
-global $tipo_cons,$limite;
+global $tipo_cons,$limite,$dettnulli;
+
 $bgcolor1="#7777ff";
 $bgcolor2=$_SESSION['bgcolor2'];
@@ -578,15 +581,15 @@
 			$result = mysql_query("SELECT count(t1.voti) from ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on (t1.id_cand=t2.id_cand) where t1.id_sez=$id_sez and t2.id_lista=$id_rif",$dbi);
 			list($ctrvoticand)=mysql_fetch_row($result);
-			$result = mysql_query("SELECT sum(t1.voti) from ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on (t1.id_cand=t2.id_cand) where t1.id_sez=$id_sez and t2.id_lista=$id_rif",$dbi);
+			$result = mysql_query("SELECT sum(t1.voti),0,0 from ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on (t1.id_cand=t2.id_cand) where t1.id_sez=$id_sez and t2.id_lista=$id_rif",$dbi);
 			list($votisezcand)=mysql_fetch_row($result);
 			if(($fascia>$limite or !$id_conf) or $genere==4)
-                $result = mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'", $dbi);
+                $result = mysql_query("SELECT voti,nulli_lista from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'", $dbi);
             else{
 
 				$result = mysql_query("SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_rif'", $dbi);
 				list($id_gruppo)=mysql_fetch_row($result);
-				$result = mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
+				$result = mysql_query("SELECT sum(voti),0,0 from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
             }
-			list($votisezlis)=mysql_fetch_row($result);
+			list($votisezlis,$sgpl,$vnpl)=mysql_fetch_row($result);
 			if($votisezcand>($votisezlis*$numprefs))
 				{$segna="style=\"background-color: #dd0000;\"";}
@@ -611,8 +614,13 @@
 		if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";}
 if(($genere==4 or ($genere==5 and $votog)) and !$id_lista)	
-		$result = mysql_query("SELECT sum(t1.voti),t2.validi, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli,t2.bianchi,t2.nulli,0,0 from ".$prefix."_ele_sezioni as t2 left join ".$prefix.$tab." as t1 on (t1.id_sez=t2.id_sez) where t2.id_sez=$id_sez group by t1.id_sez",$dbi);
+		$result = mysql_query("SELECT sum(t1.voti),t2.validi, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli,t2.bianchi,t2.nulli,0,0,0,0 from ".$prefix."_ele_sezioni as t2 left join ".$prefix.$tab." as t1 on (t1.id_sez=t2.id_sez) where t2.id_sez=$id_sez group by t1.id_sez",$dbi);
 else
-		$result = mysql_query("SELECT sum(t1.voti),t2.validi_lista, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli_lista,t2.bianchi,t2.nulli,t2.contestati,t2.voti_nulli from ".$prefix."_ele_sezioni as t2 left join ".$prefix.$tab." as t1 on (t1.id_sez=t2.id_sez) where t2.id_sez='$id_sez' group by t1.id_sez",$dbi);
-		list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2) = mysql_fetch_row($result);
+	if($tab=="_ele_voti_lista")
+		$result = mysql_query("SELECT sum(t1.voti),t2.validi_lista, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli_lista,t2.bianchi,t2.nulli,t2.contestati,t2.voti_nulli,0,t1.nulli_lista from ".$prefix."_ele_sezioni as t2 left join ".$prefix.$tab." as t1 on (t1.id_sez=t2.id_sez) where t2.id_sez='$id_sez' group by t1.id_sez",$dbi);
+	else
+		$result = mysql_query("SELECT sum(t1.voti),t2.validi_lista, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli_lista,t2.bianchi,t2.nulli,t2.contestati,t2.voti_nulli,0,0 from ".$prefix."_ele_sezioni as t2 left join ".$prefix.$tab." as t1 on (t1.id_sez=t2.id_sez) where t2.id_sez='$id_sez' group by t1.id_sez",$dbi);
+
+// aggiunte le variabili $sgpl e $vnpl per la gestione dei voti 1) al solo presidente per singola lista - 2) al solo presidente per singola lista perché nullo o contestato quello di lista		
+		list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2,$sgpl,$vnpl) = mysql_fetch_row($result);
 		$valista=$validi2;
 		if(!$id_lista or $genere==3){	//controllo di congruenza
@@ -666,4 +674,7 @@
 			echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>"
 			."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
+			if($dettnulli){
+			echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NULLI_LISTE."</b></td>";
+			}
 		}
 		echo "</tr>\n";
@@ -703,5 +714,5 @@
 			} 
 		}else {
-			$result1 = mysql_query("select t2.voti,t1.id_lista, descrizione,simbolo,num_lista 
+			$result1 = mysql_query("select t2.voti,t1.id_lista, descrizione,simbolo,num_lista,t2.nulli_lista 
 			from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2
 			where t1.id_cons='$id_cons' 
@@ -715,5 +726,5 @@
 				order by t1.num_lista", $dbi);
 			}
-			while (list($pro['voti'],$id_lista3,$descr_lista,$simb_lista,$num_lista)=mysql_fetch_row($result1)){
+			while (list($pro['voti'],$id_lista3,$descr_lista,$simb_lista,$num_lista,$vnpl)=mysql_fetch_row($result1)){
 				echo "<tr bgcolor=\"$bgcolor2\">";
 //				if ($genere<4 or $votoc){
@@ -724,5 +735,9 @@
 				$cond_sele="and id_lista=$id_lista3";
 				echo "<td align=\"right\"><input  name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\"  style=\"text-align:right\">";
-				echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td></tr>\n";
+
+				if($dettnulli) echo "</td><td align=\"right\"><input  name=\"vnpl$i\" value=\"".$vnpl."\" size=\"7\"  style=\"text-align:right\"><input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td>";
+				else echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td>";
+//				echo "<td align=\"right\">$sgpl";
+				echo "</tr>\n";
 				$i++;
 				$tot_pref+=$pro['voti'];
@@ -780,5 +795,6 @@
 
 function rec_voti() {
-	global $prefix, $dbi,$aid,$id_cons,$ops,$genere,$votog,$fileout,$id_comune,$limite,$update;
+	global $prefix, $dbi,$aid,$id_cons,$ops,$genere,$votog,$fileout,$id_comune,$limite,$update,$dettnulli;
+	
 	$sqlcomu="select id_fascia,id_conf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
 	$res = mysql_query($sqlcomu);
@@ -815,19 +831,21 @@
 	
 	}else{
-	for($i=8,$y--;$i< $y;$i++) {
+	for($i=8,$y--;$i< $y;$i++) {		
 		$voti = intval($arg[$i++]);
-		$id_cand = intval($arg[$i]);
+		if($dettnulli) {$vnpl = intval($arg[$i++]); $vnriga=",nulli_lista='$vnpl'"; $vnrigains=",'".$vnpl."'";} else {$vnriga=''; $vnrigains=",''";}
+		$id_cand = intval($arg[$i]); 
 		$result = mysql_query("select * from ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'", $dbi);
-        	$ar=mysql_fetch_array($result);
+        	$ar=mysql_fetch_array($result);		
+
 		if ($ar){
-			if ($ar['voti']!=$voti) {
-				mysql_query("update  ".$prefix."$tab set voti='$voti' where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'", $dbi);
+			if ($ar['voti']!=$voti or (isset($vnpl) and $ar['nulli_lista']!=$vnpl)) {
+				mysql_query("update  ".$prefix."$tab set voti='$voti'$vnriga where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'", $dbi);
 				if ($fileout) fwrite($fp,"update  ".$prefix."$tab set voti='$voti' where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand';\n");
 	        	mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','voti=".$ar['voti']."','$condizione:$id_cand voti: $voti','$tab')", $dbi);
 			}
-		} else {
+		} else {//die ("insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti'$vnrigains)");
 			if ($voti)
-	    		mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario',' ','$condizione:$id_cand voti: $voti','$tab')", $dbi);
-			mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti')", $dbi);
+	    		mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario',' ','$condizione:$id_cand voti: $voti','$tab')", $dbi); 
+			mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti'$vnrigains)", $dbi);
 			if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti');\n");
 		}
@@ -1194,9 +1212,10 @@
 
 function preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
- global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo;
+ global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo,$dettnulli;
 ////////////////////////////////////////////
 // da qua va la sezione per le preferenze ai gruppi
 ///////////////////////////////////////////
 // Controllo immmissioni
+
 $bgcolor1="#7777ff";
 $bgcolor2=$_SESSION['bgcolor2'];
@@ -1277,4 +1296,5 @@
 	}else{
 		echo "<td width=\"5%\"><b>"._VOTI."</b></td>";
+		if($dettnulli)		echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLO_GRUPPO."</b></td>";
 	}
     echo "</tr>";
@@ -1326,4 +1346,5 @@
 		$pro= mysql_fetch_array($res, 3);
 		echo "</td><td align=\"right\"><input  name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\"  style=\"text-align:right\"></td>";
+		if($dettnulli) echo "</td><td align=\"right\"><input  name=\"solog$i\" value=\"".$pro['solo_gruppo']."\" size=\"7\"  style=\"text-align:right\"></td>";
 		$tot_pref += $pro['voti'];
 	}
@@ -1367,4 +1388,6 @@
 global $prefix, $dbi,$aid, $tipo_cons, $genere,$id_cons,$ops,$fileout;
 if ($fileout) while (!$fp = fopen($fileout,"a"));
+
+$detnulli=1;
 $username="$aid";
 $log_data= date("Y/m/d");
@@ -1416,10 +1439,13 @@
 			$voti = "'$si','$no','$val','$nul','$bia','$con'";
 			$riga="si=$si,no=$no,validi=$val,nulli=$nul,bianchi=$bia,contestati=$con";
+			$sgriga='';
 			}
 			break;
 		default:
 			$voti = intval($arg[$i++]);
+			if($detnulli) { $sg=intval($arg[$i++]); $sgriga = ', solo_gruppo='.$sg;} else {$sgriga=''; $sg=0;}
 			if (!$voti) {$voti="0";}
-			$riga="voti=$voti";
+			$riga="voti=$voti".$sgriga;
+			$sgriga=",'$sg'";
 			break;
 	}
@@ -1439,5 +1465,5 @@
 				break;
 			default:
-				if ($ar['voti']!=$voti) {
+				if ($ar['voti']!=$voti or $ar['solo_gruppo']!=$sg) {
 					$oldval="voti:".$ar['voti'];
 					$voti.=",null";
@@ -1445,6 +1471,6 @@
 				if (isset($ar['num_gruppo'])) $dstgruppo=$ar['num_gruppo'];
 				break;
-		}
-		if ($oldval) {
+		} 
+		if ($oldval) { 
 			mysql_query("update  ".$prefix."$tab set $riga where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
 			if ($fileout) fwrite($fp,"update  ".$prefix."$tab set $riga where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo';\n");
@@ -1453,6 +1479,6 @@
 	} else { #die ("test in corso: insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti)");
 		mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','".$log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']."','','num_gruppo:$num_gruppo $riga','$tab')", $dbi);
-		mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti)", $dbi);
-		if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti);\n");
+		mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti $sgriga)", $dbi);
+		if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti $sgriga);\n");
 	//
 	}
