Index: trunk/client/modules/Elezioni/affluenze.php
===================================================================
--- trunk/client/modules/Elezioni/affluenze.php	(revision 121)
+++ trunk/client/modules/Elezioni/affluenze.php	(revision 265)
@@ -19,6 +19,8 @@
 if (isset($param['xls'])) $xls=intval($param['xls']);
 if (isset($param['pdf'])) $pdf=intval($param['pdf']);
-$res = mysql_query("SELECT t1.tipo_cons,t3.genere,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.tipo_cons=t3.tipo_cons and 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,$genere,$id_cons) = mysql_fetch_row($res);
+$sql="SELECT t1.tipo_cons,t3.genere,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.tipo_cons=t3.tipo_cons and t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'";
+$res = $dbi->prepare("$sql");
+$res->execute();
+list($tipo_cons,$genere,$id_cons) = $res->fetch(PDO::FETCH_NUM);
 global $lang,$circo,$id_circ;
 
@@ -31,6 +33,8 @@
 	include_once("modules/Elezioni/funzioni.php");
 	
-	$res = mysql_query("SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ", $dbi);
-	list($descr_com) = mysql_fetch_row($res);
+	$sql="SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
+	$res = $dbi->prepare("$sql");
+	$res->execute();
+	list($descr_com) = $res->fetch(PDO::FETCH_NUM);
         $descr_com =stripslashes($descr_com); 
 	$datipdf .= "<div style=\"margin:0px auto; text-align:center;\">";
@@ -110,10 +114,14 @@
 	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?
+		$sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons'";
+		$resg = $dbi->prepare("$sql");
+		$resg->execute();
+		$num_refs= $resg->rowCount(); //quante pagine?
 	}	
 	if($genere=='0'){
-		$resg = mysql_query("SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' and num_gruppo='$num_ref'", $dbi);	
-		list($id_gruppo)=mysql_fetch_array($resg);
+		$sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' and num_gruppo='$num_ref'";	
+		$resg = $dbi->prepare("$sql");
+		$resg->execute();
+		list($id_gruppo)=$resg->fetch(PDO::FETCH_NUM);
 	$posref="&amp;num_ref=$num_ref&amp;num_refs=$num_refs";
 	
@@ -140,6 +148,8 @@
 	// descrizione
 	 if ($genere==0){
-	 $des = mysql_query("select descrizione from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'", $dbi);
-		list($descrizione)=mysql_fetch_array($des);
+	 $sql="select descrizione from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
+	$des = $dbi->prepare("$sql");
+	$des->execute();
+		list($descrizione)=$des->fetch(PDO::FETCH_NUM);
 	        if(!isset($html)) $html='';
 		$html .= "<div><h4>$descrizione</h4></div>";
@@ -151,8 +161,10 @@
 	
 	
-	$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 $circos order by num_sez", $dbi);
-	while ($linka[$i++] = mysql_fetch_array($res));
+	$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 $circos order by num_sez";
+	$res = $dbi->prepare("$sql");
+	$res->execute();
+	while ($linka[$i++] = $res->fetch(PDO::FETCH_BOTH));
 #	while (list($appo) = mysql_fetch_array($res)) {$i=$appo['num_sez']; $linka[$i] = $appo;echo "\nnum:$i:".$linka[$i]['num_sez'];}die();
-	$num_sez = mysql_num_rows($res); //numero totale delle sezioni
+	$num_sez = $res->rowCount(); //numero totale delle sezioni
 	$sez_da=$linka[1]['num_sez'];
 	$sez_a=$sez_da+$num_sez-1;
@@ -181,21 +193,25 @@
 
 	$perc_u=0;$perc_d=0;$perc_c=0;
-#	$resril = mysql_query("SELECT t1.data,t1.orario FROM ".$prefix."_ele_rilaff as t1 where t1.id_cons_gen='$id_cons_gen' and 0<(select count(0) from ".$prefix."_ele_voti_parziale as t2, ".$prefix."_ele_cons_comune as t3 where t3.id_cons_gen=t1.id_cons_gen and t3.id_cons=t2.id_cons and t2.data=t1.data and t2.orario=t1.orario) order by t1.data,t1.orario", $dbi);
-	$resril = mysql_query("SELECT t1.data,t1.orario FROM ".$prefix."_ele_rilaff as t1 left join ".$prefix."_ele_voti_parziale as t2 on t2.data=t1.data and t2.orario=t1.orario left join ".$prefix."_ele_cons_comune as t3 on t3.id_cons_gen=t1.id_cons_gen where t1.id_cons_gen='$id_cons_gen' and t3.id_cons=t2.id_cons group by t1.data,t1.orario order by t1.data,t1.orario", $dbi);
-	$num_ril= mysql_num_rows($resril);  //numero delle rilevazioni previste
+	$sql="SELECT t1.data,t1.orario FROM ".$prefix."_ele_rilaff as t1 left join ".$prefix."_ele_voti_parziale as t2 on t2.data=t1.data and t2.orario=t1.orario left join ".$prefix."_ele_cons_comune as t3 on t3.id_cons_gen=t1.id_cons_gen where t1.id_cons_gen='$id_cons_gen' and t3.id_cons=t2.id_cons group by t1.data,t1.orario order by t1.data,t1.orario";
+	$resril = $dbi->prepare("$sql");
+	$resril->execute();
+	$num_ril= $resril->rowCount();  //numero delle rilevazioni previste
         if(!isset($html)) $html='';
 	$html .= "<table class=\"td-89\">";
 	$html .= "<tr class=\"bggray\"><td class=\"\">"._SEZIONI."</td><td>"._ISCR_SEZ."</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,id_gruppo", $dbi);
-
-		$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);
-		
-
-  	$ressomma = mysql_query("select t3.data,t3.orario,sum(t3.voti_complessivi),sum(t3.voti_uomini),sum(t3.voti_donne)  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' $circos $cond group by t3.data,t3.orario,t3.id_gruppo order by t3.data,t3.orario",$dbi);
-
-#die("select t3.data,t3.orario,sum(t3.voti_complessivi),sum(t3.voti_uomini),sum(t3.voti_donne)  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' $circos  group by t3.data,t3.orario,t3.id_gruppo ");
+
+		$sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
+		$resuo = $dbi->prepare("$sql");
+		$resuo->execute();
+		list($ultora,$ultdata)=$resuo->fetch(PDO::FETCH_NUM);
+		
+
+  	$sql="select t3.data,t3.orario,sum(t3.voti_complessivi),sum(t3.voti_uomini),sum(t3.voti_donne)  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' $circos $cond group by t3.data,t3.orario,t3.id_gruppo order by t3.data,t3.orario";
+	$ressomma = $dbi->prepare("$sql");
+	$ressomma->execute();
+
+
 $perc_u=array(); $perc_d=array(); $perc_c=array();
-	while (list($data,$ora,$somma,$votiu,$votid) = mysql_fetch_row($ressomma)) {
+	while (list($data,$ora,$somma,$votiu,$votid) = $ressomma->fetch(PDO::FETCH_NUM)) {
 		$perc_u[$data.$ora]=0;
 		$perc_d[$data.$ora]=0;
@@ -217,5 +233,5 @@
 	}
 	$ud=0;$ora_rif="";
-	while (list($data1,$ora1) = mysql_fetch_row($resril)) 
+	while (list($data1,$ora1) = $resril->fetch(PDO::FETCH_NUM)) 
 	{
 		$ud++;	
@@ -227,6 +243,8 @@
 		$data_a=form_data($data1);
 		$html .= "".$data_a."<br />"._ORE." ".$ora_ril;
-		$resaff = mysql_query("SELECT count(data) 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 t1.id_cons='$id_cons' and data='$data1' and orario='$ora_ril' $circos group by t3.id_gruppo", $dbi);
-		list($num_scr) = mysql_fetch_row($resaff);  //numero delle sezioni inserite
+		$sql="SELECT count(data) 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 t1.id_cons='$id_cons' and data='$data1' and orario='$ora_ril' $circos group by t3.id_gruppo";
+		$resaff = $dbi->prepare("$sql");
+		$resaff->execute();
+		list($num_scr) = $resaff->fetch(PDO::FETCH_NUM);  //numero delle sezioni inserite
 		$html .= "<br />"._SEZIONI." $num_scr "._SU." $num_sez";
 ##		if ($ud==$num_ril and ($perc_u or $perc_d)) $html .= "<br />
@@ -261,8 +279,11 @@
 #foreach($ar[['num_sez'] as $i)
 ##########
-  	$resvoti = mysql_query("select t1.num_sez  from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t2.id_cons='$id_cons' $circos order by t1.num_sez ",$dbi);
+  	$sql="select t1.num_sez  from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t2.id_cons='$id_cons' $circos order by t1.num_sez ";
+	$resvoti = $dbi->prepare("$sql");
+	$resvoti->execute();
+
 ###########
 #		for ($i=$sez_da;$i<=$sez_a;$i++)
-		while (list($i)=mysql_fetch_row($resvoti))
+		while (list($i)=$resvoti->fetch(PDO::FETCH_NUM))
 			{
 				$ar[$i][$data1.$ora1]="<span style=\"color: rgb(255, 0, 0);\">non rilevata</span>";
@@ -271,10 +292,9 @@
 	}
 	}
-  	$resvoti = mysql_query("select t3.data,t3.orario,t1.num_sez,voti_uomini, voti_donne, voti_complessivi  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' $circos $cond order by data,orario,t1.num_sez ",$dbi);
-  	
-#	$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 t3.data,t3.orario,t1.num_sez,voti_uomini, voti_donne, voti_complessivi  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' $circos $cond order by data,orario,t1.num_sez ";
+	$resvoti = $dbi->prepare("$sql");
+	$resvoti->execute();
 	$ud=0;
-#die("select t3.data,t3.orario,t1.num_sez,voti_uomini, voti_donne, voti_complessivi  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' $circos $cond order by data,orario,t2.num_sez ");
-	while (list($data,$ora,$numsez,$uomini,$donne,$complessivi) = mysql_fetch_row($resvoti)) {
+	while (list($data,$ora,$numsez,$uomini,$donne,$complessivi) = $resvoti->fetch(PDO::FETCH_NUM)) {
 #		if ($ora_rif=="$data.$ora")
 		if(($uomini+$donne)>0)
