Index: trunk/admin/modules/Elezioni/ele.php
===================================================================
--- trunk/admin/modules/Elezioni/ele.php	(revision 357)
+++ trunk/admin/modules/Elezioni/ele.php	(revision 358)
@@ -58,5 +58,5 @@
 
 if (!$perms) $perms=ChiSei($id_cons_gen);
-	//include("modules/Elezioni/language/lang-$currentlang.php");
+	include_once("modules/Elezioni/language/lang-$currentlang.php");
 	//**************************************************************************
 	//        ELE
@@ -71,5 +71,5 @@
 #	include("modules/Elezioni/testa.php");
         //immagine bullet
-        $bullet="<img src=\"temi/$tema/images/bullet.gif\" alt =\" \" align=\"left\" border=\"0\">";
+    $bullet="<img src=\"temi/$tema/images/bullet.gif\" alt =\" \" align=\"left\" border=\"0\">";
 	$bullet_red="<img src=\"temi/$tema/images/bullet_red.gif\" alt =\" \" align=\"left\" border=\"0\">";
 	$bgcolor1='#e7e7e7';
@@ -264,5 +264,5 @@
 		</td>
 	<td valign=\"top\" width=\"150\">";
-	if ($op!='consultazione' and $perms>0 and $nrcirco and ($nrlista or $nrgruppo)) {
+	if ($op!='consultazione' and $perms>0 and $nrcirco and ($nrlista or $nrgruppo) and ! $espandi) {
 			echo "<a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;do=spoglio\">$bullet "._GEST." "._SPOGLIO."</a><br>";
 		if ($nraff) {
Index: trunk/admin/modules/Elezioni/ele_candidato.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_candidato.php	(revision 357)
+++ trunk/admin/modules/Elezioni/ele_candidato.php	(revision 358)
@@ -303,4 +303,5 @@
 					$num_cand++;
 				}
+				###################
 				$sql="select id_gruppo,num_lista from ".$prefix."_ele_lista where id_lista='$id_lista'";
 				$sth = $dbi->prepare("$sql");
@@ -311,5 +312,6 @@
 				$sth->execute();
 				$result=$sth->rowCount();
-				$sql="insert into ".$prefix."_ele_log values ('$id_cons','$id_sez','$username','$data','$tempo','','ADD:id_lista:$id_lista,num_lista:$num_lista,cognome:$cognome,nome:$nome','".$prefix."_ele_candidati')";
+				$sql="insert into ".$prefix."_ele_log values ('$id_cons','$id_sez','$username','$data','$tempo','','ADD:id_lista:$id_lista,num_lista:$num_lista,cognome:$cognome,nome:$nome','".$prefix."_ele_candidati')";				
+#########				
 				$sth = $dbi->prepare("$sql");
 				$sth->execute();
@@ -324,5 +326,5 @@
 		}elseif ($do == "update") {
 		$pro= $sthcan->fetch(PDO::FETCH_BOTH);
-		
+		################
 		$sql="select id_gruppo,num_lista from ".$prefix."_ele_lista where id_lista='$id_lista'";
 		$sth = $dbi->prepare("$sql");
@@ -333,4 +335,5 @@
 		if (isset($simbolo)) {$cond.=", simbolo='$simbolo'";}
 		$sql="update  ".$prefix."_ele_candidati set id_lista='$id_lista', num_lista='$num_lista', cognome='$cognome', nome='$nome', num_cand='$num_cand' $cond where id_cand='$id_cand' ";
+######
 		$sth = $dbi->prepare("$sql");
 		$sth->execute();
Index: trunk/admin/modules/Elezioni/ele_consultazioni.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_consultazioni.php	(revision 357)
+++ trunk/admin/modules/Elezioni/ele_consultazioni.php	(revision 358)
@@ -83,4 +83,36 @@
 	echo "} \n";
 	echo "</script>\n";
+	
+	##############  onsubmit=\"check_aid()\"
+/*	echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
+	."//-->\n";
+	echo "function check_aid() {
+          var elem=document.getElementById('descrcons'); var num=elem.length; alert (\"Please fill in your first name.\".num);
+    for (i=0; i < elem.length; i++) { var sel=elem[i].value;
+        if (elem[i].value == document.consultazione.descr_cons2.value) {
+            document.consultazione.descr_cons2.style.backgroundColor = \"#ccc\";
+               document.consultazione.descr_cons2.focus();
+               return false;
+        }
+    }
+	return false;
+	}
+	
+	    function hide(){
+          var elem = document.getElementById('descrcons');
+          elem.style.display = 'none';
+        }";
+
+	echo "</script>\n"; */
+###################
+	$sql="select descrizione from ".$prefix."_ele_consultazione";
+	$sth = $dbi->prepare("$sql"); 
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_NUM);
+	echo "<select id=\"descrcons\" style=\"visibility:hidden;\">";
+	while(list($val)=$sth->fetch(PDO::FETCH_NUM)) {
+		echo "<option value=\"$val\">$val</option>";
+	}
+	echo "</select>";
 #########################
 	if (isset($help)) include("language/$language/ele_consultazioni.html");
@@ -127,9 +159,12 @@
 		echo "<option value=\"$dfa1\" selected>$dfa1</option>"; anno();
 		echo "</td></tr><tr>";
-		$resdel = daticonscom();
-		if(count($resdel)==0)
-			echo "<td><fieldset><legend>"._SPUNTALABEL1."</legend><label id=\"prov\">"._VIASPUNTAELIMINA." <input type=\"checkbox\" id=\"pwd3\"name=\"pwd3\" value=\"\" onclick=\"del_cons()\"></label></fieldset></td>";
+		$sql="SELECT t1.tipo_cons,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen'";
+		$sth = $dbi->prepare("$sql");
+		$sth->execute();
+		$resdel=$sth->rowCount();	
+		if($resdel==0)
+			echo "<td colspan=\"2\"><fieldset><legend>"._SPUNTALABEL1."</legend><label id=\"prov\">"._VIASPUNTAELIMINA." <input type=\"checkbox\" id=\"pwd3\"name=\"pwd3\" value=\"\" onclick=\"del_cons()\" size=\"200px\"></label></fieldset></td>";
 		else echo "<td></td>";
-		echo "<td><input type=\"submit\" id=\"update\" name=\"update\" value=\""._MODIFY."\">"
+		echo "</tr><tr><td><input type=\"submit\" id=\"update\" name=\"update\" value=\""._MODIFY."\">"
 		."</td></tr></table></form>";
 	} else {
@@ -249,7 +284,13 @@
 				$id_consulta=$id_cons_gen;
 				$sql="insert into ".$prefix."_ele_consultazione (descrizione,data_inizio,data_fine,tipo_cons) values ('$descr_cons2','$data_inizio','$data_fine','$tipocons')";
-				$sth = $dbi->prepare("$sql");
-				$sth->execute();	
-
+				try {
+					$sth = $dbi->prepare("$sql");
+					$sth->execute();
+				}catch(PDOException $e) {
+					if ($e->getCode() == 23000) 
+						echo "<h2 style=\"color:red;\">     Inserimento fallito: Esiste giÃ  una consultazione con il nome \"$descr_cons2\"</h2";
+					else
+						echo "<h2 style=\"color:red;\">     Inserimento fallito: ". $e->getMessage()."</h2";
+				}	
 			} else {
 		        OpenTable();
@@ -262,6 +303,13 @@
 			$data_fine="$dfa-$dfm-$dfg";
 			$sql="update  ".$prefix."_ele_consultazione set  descrizione='$descr_cons2',data_inizio='$data_inizio',data_fine='$data_fine' WHERE id_cons_gen='$id_cons_gen'";
-			$sth = $dbi->prepare("$sql");
-			$sth->execute();	
+			try {
+				$sth = $dbi->prepare("$sql");
+				$sth->execute();
+			}catch(PDOException $e) {
+				if ($e->getCode() == 23000) 
+					echo "<h2 style=\"color:red;\">     Inserimento fallito: Esiste giÃ  una consultazione con il nome \"$descr_cons2\"</h2";
+				else
+					echo "<h2 style=\"color:red;\">     Inserimento fallito: ". $e->getMessage()."</h2";
+			}	
 			if (!$sth->rowCount()) return;
 			Header("Location: admin.php?op=consultazione&id_cons_gen=$id_cons_gen");
Index: trunk/admin/modules/Elezioni/ele_controlli.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_controlli.php	(revision 357)
+++ trunk/admin/modules/Elezioni/ele_controlli.php	(revision 358)
@@ -388,8 +388,13 @@
 
 	if($err){
-		if(!$id_lista) $id_lista=0; //$controllo;
-		$sql="insert into ".$prefix."_ele_controlli value('$id_cons','$id_sez','$tipo','$id_lista')";
-		$res = $dbi->prepare("$sql");
-		$res->execute();		
+		$sql="select * from ".$prefix."_ele_controlli where tipo='lista' and id_sez='$id_sez' "; 
+		$res = $dbi->prepare("$sql");
+		$res->execute();
+		if(!$res->rowCount()) {
+			if(!$id_lista) $id_lista=0; //$controllo;
+			$sql="insert into ".$prefix."_ele_controlli value('$id_cons','$id_sez','$tipo','$id_lista')";
+			$res = $dbi->prepare("$sql");
+			$res->execute();	
+		}
 	}
 
Index: trunk/admin/modules/Elezioni/ele_operatori.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_operatori.php	(revision 357)
+++ trunk/admin/modules/Elezioni/ele_operatori.php	(revision 358)
@@ -26,4 +26,5 @@
 if (isset($_GET['passwd'])) $passwd=addslashes($param['passwd']); else $passwd='';
 if (isset($_GET['passwd2'])) $passwd2=addslashes($param['passwd2']); else $passwd2='';
+if (isset($_GET['stato']) && $aid2!='admin') $stato=intval($param['stato']); else $stato=0;
 
 include("modules/Elezioni/funzionidata.php");
@@ -37,4 +38,5 @@
 	global $aid, $offset, $prefix, $dbi,$id_cons,$aid2,$id_sede,$id_cons_gen,$mex,$perms;
         //echo $perms;die();
+
 	$bgcolor1=$_SESSION['bgcolor1'];
 	$id_comune=$_SESSION['id_comune'];
@@ -44,8 +46,8 @@
 	$rescom->execute();	
 	list($descr_com) = $rescom->fetch(PDO::FETCH_NUM);
-	$sql="SELECT aid,name,email FROM ".$prefix."_authors where aid='$aid2' and id_comune='$id_comune'";
+	$sql="SELECT aid,name,email,adminop FROM ".$prefix."_authors where aid='$aid2' and id_comune='$id_comune'";
 	$resmod = $dbi->prepare("$sql");
 	$resmod->execute();	
-	list ($aid2,$name,$email) = $resmod->fetch(PDO::FETCH_NUM);
+	list ($aid2,$name,$email,$attivo) = $resmod->fetch(PDO::FETCH_NUM);
 	if (isset($_GET['mex'])){
 		echo "<table align=\"center\"><tr><td style=\"background-color: rgb(255, 0, 0)\">";
@@ -65,6 +67,6 @@
 	echo "</tr><tr align=\"center\">";
 	echo "<td><input type=\"hidden\" name=\"pag_op\" value=\"admin.php?op=operatori&amp;id_cons_gen=$id_cons_gen&amp;aid2=\">";
-	echo "<select name=\"aid2\" onChange=\"top.location.href=this.form.pag_op.value+this.form.aid2.options[this.form.aid2.selectedIndex].value;return false\">";
-	echo "<option value=\"\">";
+	echo "<select id=\"aid2\" name=\"aid2\" onChange=\"top.location.href=this.form.pag_op.value+this.form.aid2.options[this.form.aid2.selectedIndex].value;return false\">";
+	echo "<option value=\"\">Nuovo Utente";
 	while(list($utente)=$resins->fetch(PDO::FETCH_NUM)){
 		$sel= ($utente == $aid2) ? "selected":"";
@@ -86,4 +88,7 @@
 	echo "<td bgcolor=\"$bgcolor1\"><b>"._NOME."</b></td>"
 	."<td bgcolor=\"$bgcolor1\"><b>"._EMAIL."</b></td>";
+	echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
+	
+
 	echo "<td bgcolor=\"$bgcolor1\"><b>"._FUNZIONI."</b></td></tr>";
 	echo "<tr align=\"center\"><td>";
@@ -98,5 +103,7 @@
 	echo "<td  align=\"center\"><input type=password name=\"passwd2\" size=\"12\"></td>";
 	echo "<td><input name=\"name\" value=\"$name\"></td>";
-	echo "<td><input name=\"email\" value=\"$email\">";
+	echo "<td><input name=\"email\" value=\"$email\"></td>";
+	if($attivo==0) {$sel2="selected"; $sel3='';} else {$sel2=''; $sel3="selected";}
+	echo "<td><select name=\"stato\"><option value=\"0\" $sel2>Attivo<option value=\"1\" $sel3>Disattivo<option value=\"2\" >Elimina</select>";
 	echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
 	echo "<input type=\"hidden\" name=\"ok\" value=0></td>";
@@ -113,7 +120,11 @@
 }
 
-function operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune) {
+function operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune,$stato) {
 	global $aid, $prefix, $dbi, $id_cons,$id_cons_gen,$currentlang;
 	$perms=ChiSei($id_cons_gen);
+	if($passwd!=$passwd2) {
+		$mex="- Le password non coincidono! -<br>";
+		header("location:admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=$aid2&name=$name&email=$email&mex=$mex&stato=$stato");
+	}
        
 	if ($perms!=256) $id_comune=$_SESSION['id_comune'];
@@ -124,7 +135,7 @@
 			$res->execute();	
 			$max=$res->rowCount();
-			if ($passwd==$passwd2 and $max==0){
-				if ($aid2=='admin') $super='1,0,0,'; else $super = '0,1,0,';
-				$sql="insert into ".$prefix."_authors (aid,name,id_comune,email,pwd,counter,adminop,admincomune,adminsuper,admlanguage) values ('$aid2','$name','$id_comune' , '$email','".md5($passwd)."',0,$super'$currentlang')";
+			if ($max==0){
+				if ($aid2=='admin') $super='0,1,0,'; else $super = '0,0,0,';
+				$sql="insert into ".$prefix."_authors (aid,name,id_comune,email,pwd,counter,adminop,admincomune,adminsuper,admlanguage) values ('$aid2','$name','$id_comune' , '$email','".md5($passwd)."','0',$super'$currentlang')";
 				$res = $dbi->prepare("$sql");
 				$res->execute();	
@@ -133,17 +144,27 @@
 					$res = $dbi->prepare("$sql");
 					$res->execute();	
-				}
-			Header("Location: admin.php?op=operatori&id_cons_gen=$id_cons_gen");
+			}
+			Header("Location: admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=$aid2");
 			}else{
 				$mex='';
-				if($passwd!=$passwd2) $mex="- Le password non coincidono! -<br>";
 				if($max>0) $mex.=" - Utente <b>$aid2</b> presente in archivio! - ";
-				header("location:admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=$aid2&name=$name&email=$email&mex=$mex");
 			}
 		} elseif ($do == "update") {
-			$sql="update  ".$prefix."_authors set name='$name',pwd='".md5($passwd)."', email='$email' where id_comune='$id_comune' and aid='$aid2' ";
-			$res = $dbi->prepare("$sql");
-			$res->execute();
+			if($passwd!='') $mexpwd="pwd='".md5($passwd)."',"; else $mexpwd='';
+			if($stato==2){
+				$sql="delete from ".$prefix."_authors where aid='$aid2' and id_comune=$id_comune";
+				$res = $dbi->prepare("$sql");
+				$res->execute();					
+			}else{
+				$sql="update  ".$prefix."_authors set name='$name', $mexpwd email='$email', adminop='$stato' where id_comune='$id_comune' and aid='$aid2' ";
+				$res = $dbi->prepare("$sql");
+				$res->execute();
+			}
 			$result=$res->rowCount();
+			if($stato!=0){
+				$sql="delete from ".$prefix."_ele_operatori where id_comune='$id_comune' and aid='$aid2' ";
+				$res = $dbi->prepare("$sql");
+				$res->execute();
+			}
 			if (!$result) return;
 			if ($aid2==$aid) $_SESSION['pwd']=md5($passwd);
@@ -157,5 +178,5 @@
 // switch
 //****************************
-	if ($do) operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune);
+	if ($do) operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune,$stato);
 	ele();
 	all();
Index: trunk/admin/modules/Elezioni/ele_permessi.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_permessi.php	(revision 357)
+++ trunk/admin/modules/Elezioni/ele_permessi.php	(revision 358)
@@ -24,5 +24,5 @@
 list($tipo_cons,$id_cons) = $res->fetch(PDO::FETCH_NUM);
 if (isset($param['aid2'])) $aid2=addslashes($param['aid2']); else $aid2='';
-if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede='';
+if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede=0;
 if (isset($param['do'])) $do=addslashes($param['do']); else $do='';
 if (isset($param['permessi'])) $permessi=addslashes($param['permessi']); else $permessi='';
@@ -30,4 +30,5 @@
 if (isset($param['ok'])) $ok=intval($param['ok']); else $ok='';
 if (isset($param['mex'])) $mex=addslashes($param['mex']); else $mex='';
+if (isset($param['id_sez'])) $id_sez=intval($param['id_sez']); else $id_sez=0;
 
 include("modules/Elezioni/funzionidata.php");
@@ -39,6 +40,20 @@
 //crea la pagina delle affluenze
 function all() {
-	global $adminop,$adminsuper,$admincomune,$aid, $offset, $prefix, $dbi,$id_cons,$aid2,$permessi,$id_sede,$id_cons_gen,$id_comune,$mex;
+	global $adminop,$adminsuper,$admincomune,$aid, $offset, $prefix, $dbi,$id_cons,$aid2,$permessi,$id_sede,$id_cons_gen,$id_comune,$mex,$id_sez;
 	$bgcolor1=$_SESSION['bgcolor1'];
+  		echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
+		
+		."//-->\n";
+		echo "function controlloref(idsede,idsez) {\n";
+		echo "let element = window.document.getElementById(idsede); \n";
+		echo "let elecontr = window.document.getElementById(idsez); \n";
+		echo "element.selectedIndex = 0 ; \n";
+		echo "}\n";
+		echo "function controllosez(idsez, idsede) {\n";
+		echo "let element = window.document.getElementById(idsez); \n";
+		echo "let elecontr = window.document.getElementById(idsede); \n";
+		echo "element.selectedIndex = 0; \n";
+		echo "}\n";
+		echo "</script>\n";  
 	if (isset($mex)){
 		echo "<table align=\"center\"><tr><td style=\"background-color: rgb(255, 0, 0)\">";
@@ -54,4 +69,5 @@
 	echo "<td><b>"._UTENTE."</b></td>"
 	."<td bgcolor=\"$bgcolor1\"><b>"._SEDE."</b></td>"
+	."<td bgcolor=\"$bgcolor1\"><b>"._SEZIONE."</b></td>"
 	."<td bgcolor=\"$bgcolor1\"><b>"._PERMESSI."</b></td>";
 	echo "<td bgcolor=\"$bgcolor1\"><b>"._FUNZIONI."</b></td></tr>";
@@ -71,9 +87,8 @@
         
 	if (!$listmp) $listmp="''";
-	$sql="select aid from ".$prefix."_authors where id_comune=$id_comune and (admincomune=1 and aid not in ($listmp)) order by aid"; // operatori registrati ma non ancora autorizzati
+	$sql="select aid from ".$prefix."_authors where id_comune=$id_comune and (admincomune=0 and adminop=0 and aid not in ($listmp)) order by aid"; // operatori registrati ma non ancora autorizzati
 	$resins = $dbi->prepare("$sql");
 	$resins->execute();				
-	
-         
+    
 	echo "<form name=\"autorizza\" action=\"admin.php\">"
 	."<input type=\"hidden\" name=\"op\" value=\"permessi\">";
@@ -90,5 +105,5 @@
 	$ressede = $dbi->prepare("$sql");
 	$ressede->execute();				
-	echo "<td><select name=\"id_sede\">";
+	echo "<td><select id=\"id_sede\" name=\"id_sede\" onchange=controllosez('id_sez','id_sede')>";
 	echo "<option value=\"0\"> "._TUTTESEDI;
 	if($ressede->rowCount())
@@ -99,4 +114,16 @@
 	}
 	echo "</select></td>";
+	$sql="SELECT id_sez, num_sez from ".$prefix."_ele_sezioni where id_cons=$id_cons order by num_sez";
+	$ressez = $dbi->prepare("$sql");
+	$ressez->execute();				
+	echo "<td><select id=\"id_sez\" name=\"id_sez\" onchange=controlloref('id_sede','id_sez')>";
+	echo "<option value=\"0\"> ";
+	if($ressez->rowCount())
+	while(list($id,$descr)=$ressez->fetch(PDO::FETCH_NUM)){
+		$sel= ($id == $id_sez) ? "selected":"";
+		$arr[$id]=$descr;
+		echo "<option value=\"$id\" $sel>$descr";
+	}
+	echo "</select></td>";	
 	echo "<td><select name=\"permessi\">";
 	if(!isset($permessi)) $permessi=16;
@@ -115,5 +142,5 @@
 	if($resmod->rowCount()){
 		$i=1;
-		while (list($id_cons2,$id_sede2,$id_comunetemp,$perm,$utente) = $resmod->fetch(PDO::FETCH_NUM)){ 
+		while (list($id_cons2,$id_sede2,$id_comunetemp,$perm,$utente,$id_circ2,$id_sez2) = $resmod->fetch(PDO::FETCH_NUM)){ 
 			$bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
 			echo "<form name=\"modello$i\" action=\"admin.php\">"
@@ -128,6 +155,9 @@
 			$ressede = $dbi->prepare("$sql");
 			$ressede->execute();				
-			echo "<td><select name=\"id_sede\">";
-			echo "<option value=\"0\"> "._TUTTESEDI;
+			echo "<td><select id=\"id_sede$i\" name=\"id_sede\"  onchange=controllosez('id_sez$i','id_sede$i')>";
+#			if($id_sez2)
+#				echo "<option value=\"0\"> ";
+#			else
+				echo "<option value=\"0\"> "._TUTTESEDI;
 			while(list($id,$descr)=$ressede->fetch(PDO::FETCH_NUM)){
 				$sel= ($id == $id_sede2) ? "selected":"";
@@ -136,4 +166,16 @@
 			}
 			echo "</select></td>";
+			$sql="SELECT id_sez, num_sez from ".$prefix."_ele_sezioni where id_cons=$id_cons order by num_sez";
+			$ressez = $dbi->prepare("$sql");
+			$ressez->execute();				
+			echo "<td><select id=\"id_sez$i\" name=\"id_sez\"  onchange=controlloref('id_sede$i','id_sez$i')>";
+			echo "<option value=\"0\"> ";
+			if($ressez->rowCount())
+			while(list($id,$descr)=$ressez->fetch(PDO::FETCH_NUM)){
+				$sel= ($id == $id_sez2) ? "selected":"";
+				$arr[$id]=$descr;
+				echo "<option value=\"$id\" $sel>$descr";
+			}
+			echo "</select></td>";				
 			echo "<td><select name=\"permessi\">";
 			if(!isset($perm)) $perm=16;
@@ -153,5 +195,5 @@
 }
 
-function permessi($ok, $do,$aid2,$id_sede,$permessi,$id_comune) {
+function permessi($ok, $do,$aid2,$id_sede,$permessi,$id_comune,$id_sez) {
 	global $prefix, $dbi, $id_cons,$id_cons_gen,$currentlang;
 	$perms=ChiSei($id_cons_gen);
@@ -159,10 +201,10 @@
 	if ($perms>32 and $permessi<$perms and $aid2) {
 		if ($do == "autorizza") {
-			$sql="insert into ".$prefix."_ele_operatori (id_cons,id_sede,id_comune,permessi,aid) values ('$id_cons','$id_sede','$id_comune','$permessi','$aid2')";
+			$sql="insert into ".$prefix."_ele_operatori (id_cons,id_sede,id_comune,permessi,aid,id_sez) values ('$id_cons','$id_sede','$id_comune','$permessi','$aid2','$id_sez')";
 			$res = $dbi->prepare("$sql");
 			$res->execute();				
 			Header("Location: admin.php?op=permessi&id_cons_gen=$id_cons_gen");
 		} elseif ($do == "update") {
-			$sql="update  ".$prefix."_ele_operatori set id_sede='$id_sede' , permessi='$permessi' where id_cons='$id_cons' and aid='$aid2' ";
+			$sql="update  ".$prefix."_ele_operatori set id_sede='$id_sede', permessi='$permessi', id_sez='$id_sez' where id_cons='$id_cons' and aid='$aid2' ";
 			$res = $dbi->prepare("$sql");
 			$res->execute();
@@ -178,5 +220,5 @@
 // switch
 //****************************
-	if ($do) permessi($ok, $do,$aid2,$id_sede,$permessi,$id_comune);
+	if ($do) permessi($ok, $do,$aid2,$id_sede,$permessi,$id_comune,$id_sez);
 	ele();
 	all();
Index: trunk/admin/modules/Elezioni/ele_voti.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_voti.php	(revision 357)
+++ trunk/admin/modules/Elezioni/ele_voti.php	(revision 358)
@@ -413,5 +413,5 @@
 $result = $dbi->prepare("$sql");
 $result->execute();
- 
+
 
 list($numprefs,$fascia,$id_conf,$flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
@@ -677,6 +677,6 @@
 			echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>"
 			."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
-			if($dettnulli && !$disgiunto  && $tipo_cons!=18 && $tipo_cons!=19)
-			echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NULLI_LISTE."</b></td>";
+#			if($dettnulli && !$disgiunto  && $tipo_cons!=18 && $tipo_cons!=19)
+#			echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NULLI_LISTE."</b></td>";
 			if($disgiunto){
 			echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLOLIS."</b></td>";
@@ -775,5 +775,5 @@
 				$cond_sele="and id_lista=$id_lista3";
 				echo "<td align=\"right\" $errcolor><input  name=\"voti$i\" value=\"".$voti."\" size=\"7\"  style=\"text-align:right\">";
-				if($dettnulli && !$disgiunto  && $tipo_cons!=18 && $tipo_cons!=19) { echo "</td><td align=\"right\"><input  name=\"vnpl$i\" value=\"".$vnpl."\" size=\"7\"  style=\"text-align:right\">"; $tvnpl+=$vnpl;}
+#				if($dettnulli && !$disgiunto  && $tipo_cons!=18 && $tipo_cons!=19) { echo "</td><td align=\"right\"><input  name=\"vnpl$i\" value=\"".$vnpl."\" size=\"7\"  style=\"text-align:right\">"; $tvnpl+=$vnpl;}
 				if($disgiunto) {echo "</td><td align=\"right\"><input  name=\"slpl$i\" value=\"".$slpl."\" size=\"7\"  style=\"text-align:right\">"; $tslpl+=$slpl;}
 				echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td>";
@@ -786,6 +786,6 @@
 		if(!$id_lista) {
 			echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><font size=\"3\">"._TOT._VOTI_LISTA."</font></td><td align=\"center\"><font size=\"3\">$tot_pref</font></td>";
-			if($dettnulli && !$disgiunto  && $tipo_cons!=18 && $tipo_cons!=19)
-				echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><font size=\"3\">".$tvnpl."</font></td>";
+#			if($dettnulli && !$disgiunto  && $tipo_cons!=18 && $tipo_cons!=19)
+#				echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><font size=\"3\">".$tvnpl."</font></td>";
 			if($disgiunto)
 				echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><font size=\"3\">".$tslpl."</font></td>";
Index: trunk/admin/modules/Elezioni/query.sql
===================================================================
--- trunk/admin/modules/Elezioni/query.sql	(revision 357)
+++ trunk/admin/modules/Elezioni/query.sql	(revision 358)
@@ -65,5 +65,6 @@
 		$sql = "SELECT tipo_cons,descrizione,id_cons_gen FROM ".$prefix."_ele_consultazione order by data_fine desc limit 0,1 ";
 	else
-		$sql = "SELECT t1.tipo_cons,t1.descrizione,t2.id_cons_gen FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_operatori as t3 where t3.id_comune=$id_comune and t3.id_comune=t2.id_comune and t1.id_cons_gen=t2.id_cons_gen and t2.chiusa='0' and (t3.id_cons=t2.id_cons or t3.id_cons=0) and t3.permessi>0 and t3.aid='$aid' order by t1.data_fine desc limit 0,1 ";
+		$sql = "SELECT t1.tipo_cons,t1.descrizione,t2.id_cons_gen FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".
+		$prefix."_ele_operatori as t3 where t3.id_comune=$id_comune and t3.id_comune=t2.id_comune and t1.id_cons_gen=t2.id_cons_gen and t2.chiusa='0' and (t3.id_cons=t2.id_cons or t3.id_cons=0) and t3.permessi>0 and t3.aid='$aid' order by t1.data_fine desc limit 0,1 ";
 }
 	$sth = $dbi->prepare("$sql");
Index: trunk/admin/modules/Elezioni/salva_aff.php
===================================================================
--- trunk/admin/modules/Elezioni/salva_aff.php	(revision 357)
+++ trunk/admin/modules/Elezioni/salva_aff.php	(revision 358)
@@ -48,11 +48,10 @@
 $res = $dbi->prepare("$query");
 $res->execute();
-$BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
-list($id_cons)=$res->fetch(PDO::FETCH_NUM); 
+list($id_cons)=$res->fetch(PDO::FETCH_NUM);
 $query="select id_parz from ".$prefix."_ele_voti_parziale where data='$data' and orario='$orario' and id_sez='$id_sez' and id_gruppo='$id_gruppo'";
 $res = $dbi->prepare("$query");
 $res->execute();         
 $righe=$res->rowCount();
-list($id_parz)=$res->fetch(PDO::FETCH_NUM);
+list($id_parz)=$res->fetch(PDO::FETCH_NUM); 
 if($righe){ #la riga Ãš presente e viene aggiorata
 	$arr=$res->fetch(PDO::FETCH_BOTH);
@@ -88,4 +87,5 @@
 controllo_aff($id_cons,$id_sez,$id_parz);
 include("ele_colora_sez.php");
+$BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
 
 Header("Location: ".$BASE."admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&ops=1&do=spoglio");
Index: trunk/admin/modules/Elezioni/salva_gruppi.php
===================================================================
--- trunk/admin/modules/Elezioni/salva_gruppi.php	(revision 357)
+++ trunk/admin/modules/Elezioni/salva_gruppi.php	(revision 358)
@@ -123,4 +123,5 @@
 $BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
 Header("Location: ".$BASE."admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&do=spoglio&ops=$ops");
+
 #################################
 
Index: trunk/admin/modules/Elezioni/salva_liste.php
===================================================================
--- trunk/admin/modules/Elezioni/salva_liste.php	(revision 357)
+++ trunk/admin/modules/Elezioni/salva_liste.php	(revision 358)
@@ -58,5 +58,4 @@
 $res->execute();
 list($circo)=$res->fetch(PDO::FETCH_NUM);
-
 if ($circo) $iscirco="and id_circ=$id_circ"; else $iscirco=''; 
 if($id_lista){
@@ -90,7 +89,10 @@
 
 ##################
-# if($id_lista){
+# if($id_lista){ 
+
+#$andlis="and 
 	if($pwd3==1) {
-		$sql="delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez'";
+		if($id_lista) $condiz="and id_cand in (select id_cand from ".$prefix."_ele_candidati where id_cons='$id_cons' and id_lista='$id_lista')"; else $condiz='';
+		$sql="delete from ".$prefix."_ele_voti_candidati where id_sez='$id_sez' $condiz";
 		$res = $dbi->prepare("$sql");
 		$res->execute();
@@ -111,4 +113,5 @@
 		
 	}elseif($id_lista){
+
 		foreach($idcand as $idkey=>$idc){			
 			$sql="select num_cand from ".$prefix."_ele_voti_candidati where id_sez='$id_sez' and id_cand='$idc'";
@@ -161,4 +164,8 @@
 $BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
 Header("Location: ".$BASE."admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&do=spoglio&ops=$ops");
+
+
+
+
 #################################
 
