Index: trunk/admin/modules/Elezioni/controllo_votanti.php
===================================================================
--- trunk/admin/modules/Elezioni/controllo_votanti.php	(revision 64)
+++ trunk/admin/modules/Elezioni/controllo_votanti.php	(revision 256)
@@ -24,8 +24,17 @@
 $perms=ChiSei($id_cons_gen);
 if ($perms<16 or !$id_cons_gen) die("$perms ".$_SESSION['id_comune'].$_SESSION['aid'].";Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
-$res = mysql_query("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' and t2.id_comune='$id_comune'" , $dbi);
-list($tipo_cons,$id_cons) = mysql_fetch_row($res);
-$res = mysql_query("SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' " , $dbi);
-	list($genere) = mysql_fetch_row($res);
+
+	$sql="SELECT t1.descrizione,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' and t2.id_comune='$id_comune'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+$descr_consultazione=$row[0];
+$tipo_cons=$row[1];
+$id_cons=$row[2];
+	$sql="SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' ";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);	
+	$genere = $row[0];
 if (isset($param['ops'])) get_magic_quotes_gpc() ? $ops=$param['ops']:$ops=addslashes($param['ops']); else $ops='';
 if (isset($param['pag'])) $pag=intval($param['pag']); else $pag=0;
@@ -54,9 +63,15 @@
 		if (!IsSet($num_ref)) { 
 			$num_ref=1;
-			$resg = mysql_query("SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
-			$num_refs= mysql_num_rows($resg); //quante pagine?
-		}
-		$resg = mysql_query("SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref", $dbi);
-		list($idg,$numg) = mysql_fetch_row($resg);
+			$sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons";
+			$sth = $dbi->prepare("$sql");
+			$sth->execute();
+			$num_refs= $sth->rowCount(); //quante pagine?
+		}
+			$sql="SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref";
+			$sth = $dbi->prepare("$sql");
+			$sth->execute();
+			$row = $sth->fetch(PDO::FETCH_BOTH);	
+			$idg=$row[0];
+			$numg=$row[1];
 		$id_gruppo=$idg;
 		$cond= "and id_gruppo=$id_gruppo";
@@ -64,7 +79,9 @@
 	}
 	$i=1;
-	$res = mysql_query("SELECT num_sez,id_sez,t1.id_sede, t2.id_circ,maschi,femmine,(maschi+femmine) as elettori FROM ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez", $dbi);
-	while ($linka[$i++] = mysql_fetch_array($res));
-	$num_sez = mysql_num_rows($res); //numero totale delle sezioni
+	$sql"SELECT num_sez,id_sez,t1.id_sede, t2.id_circ,maschi,femmine,(maschi+femmine) as elettori FROM ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();
+	while ($linka[$i++] = $sth->fetch(PDO::FETCH_BOTH));
+	$num_sez = $sth->rowCount(); //numero totale delle sezioni
 	$tot_compl=0;$tot_u=0;$tot_d=0;
 //	$ar['riga1'][0]="<hr>";
@@ -85,13 +102,26 @@
 	$ar['perc'][1]=" ";
 //	$ar['riga2'][1]="<hr>";
-		$resuo = mysql_query("SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1", $dbi);
-		list($ultora,$ultdata)=mysql_fetch_row($resuo);
-
-	$resril = mysql_query("SELECT data,orario FROM ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data,orario", $dbi);
-	$num_ril= mysql_num_rows($resril);  //numero delle rilevazioni previste
+	$sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();
+	$row = $sth->fetch(PDO::FETCH_BOTH);	
+	$ultora=$row[0];
+	$ultdata=$row[1];
+
+	$sql = "SELECT data,orario FROM ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data,orario";
+	$resril = $dbi->prepare("$sql");
+	$resril->execute();	
+	$num_ril = $resril->rowCount();  //numero delle rilevazioni previste
 	echo "\n<table border=\"0\" width=\"100%\"  align=\"center\">";
 	echo "<tr bgcolor=\"$bgcolor1\" align=\"center\"><td width=\"5%\"><b>"._SEZIONI."</b></td><td><b>"._ISCRITTI."<br>"._INSEZ."</b></td>";
-	$ressomma = mysql_query("SELECT  data,orario,sum(voti_complessivi),sum(voti_uomini),sum(voti_donne) from ".$prefix."_ele_voti_parziale where id_cons=$id_cons $cond group by data,orario", $dbi);
-	while (list($data,$ora,$somma,$votiu,$votid) = mysql_fetch_row($ressomma)) {
+	$sql="SELECT  data,orario,sum(voti_complessivi),sum(voti_uomini),sum(voti_donne) from ".$prefix."_ele_voti_parziale where id_cons=$id_cons $cond group by data,orario";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();
+	while ($row = $sth->fetch(PDO::FETCH_BOTH)) {
+		$data=$row[0];
+		$ora=$row[1];
+		$somma=$row[2];
+		$votiu=$row[3];
+		$votid=$row[4];
 		$perc_u='';$perc_d='';$perc_c='';
 #		if($votiu or $votid)
@@ -107,6 +137,8 @@
 	}
 	$ud=0;$ora_rif="";
-	while (list($data1,$ora1) = mysql_fetch_row($resril)) 
+	while ($row2 = $resril->fetch(PDO::FETCH_BOTH)) 
 	{
+		$data1=$row2[0];
+		$ora1=$row2[1];
 		$ud++;	
 		list($hour, $minute, $second) = explode(":", $ora1);
@@ -115,6 +147,8 @@
 		if ($ud==$num_ril) {$ora_rif="$data1.$ora1";}
 		echo ">".form_data($data1)."<br>"._ORE." ".$ora_ril;
-		$resaff = mysql_query("SELECT count(data) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and data='$data1' and orario='$ora_ril' $cond", $dbi);
-		list($num_scr) = mysql_fetch_row($resaff);  //numero delle sezioni inserite
+		$sql="SELECT count(data) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and data='$data1' and orario='$ora_ril' $cond";
+		$resaff = $dbi->prepare("$sql");
+		$resaff->execute();
+		$num_scr=$resaff->rowCount(); //numero delle sezioni inserite
 		echo "<br>"._SEZIONI." $num_scr "._SU." $num_sez";
 		if ($ud==$num_ril) echo "<br>\n<table width=\"100%\"><tr align=\"center\"><td width=\"30%\">"._UOMINI."</td><td width=\"30%\">"._DONNE."</td><td>"._COMPLESSIVI."</td></tr></table>\n";
@@ -142,7 +176,15 @@
 	}
 	}
-	$resvoti = mysql_query("SELECT  data,orario,t2.num_sez,voti_uomini, voti_donne, voti_complessivi from ".$prefix."_ele_voti_parziale as t1, ".$prefix."_ele_sezioni as t2 where t1.id_cons=$id_cons and t1.id_sez=t2.id_sez $cond order by data,orario,t2.num_sez", $dbi);
+	$sql="SELECT  data,orario,t2.num_sez,voti_uomini, voti_donne, voti_complessivi from ".$prefix."_ele_voti_parziale as t1, ".$prefix."_ele_sezioni as t2 where t1.id_cons=$id_cons and t1.id_sez=t2.id_sez $cond order by data,orario,t2.num_sez";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();
 	$ud=0;
-	while (list($data,$ora,$numsez,$uomini,$donne,$complessivi) = mysql_fetch_row($resvoti)) {
+	while ($row = $sth->fetch(PDO::FETCH_BOTH)) {
+		$data=$row[0];
+		$ora=$row[1];
+		$numsez=$row[2];
+		$uomini=$row[3];
+		$donne=$row[4];
+		$complessivi=$row[5];
 		if ($ora_rif=="$data.$ora")
 			$ar[$numsez][$data.$ora]="\n<table width=\"100%\"><tr align=\"center\"><td width=\"30%\">$uomini</td><td width=\"30%\">$donne</td><td>$complessivi</td></tr></table>\n";
