Index: trunk/client/modules/Elezioni/votanti.php
===================================================================
--- trunk/client/modules/Elezioni/votanti.php	(revision 127)
+++ trunk/client/modules/Elezioni/votanti.php	(revision 139)
@@ -220,20 +220,38 @@
 	$tab3="_ele_voti_lista";
 	if ($genere>0) {  //se non e' un referendum
+
+
+
 		if (!($genere==4) and $pag==0){  //se non e' una lista uninominale ed e' la prima pagina
-			$tab="SELECT 0,t2.id_sez,t2.num_sez,t2.validi,'0',t2.validi,t2.nulli,t2.bianchi,t2.contestati, t4.id_circ,t2.id_sede,'0' FROM ".$prefix."_ele_sezioni as t2 left join ".$prefix."_ele_sede as t4 on (t2.id_sede=t4.id_sede) where t2.id_cons='$id_cons' and t2.validi+t2.nulli+t2.bianchi+t2.contestati>0 group by t2.id_sez order by t2.num_sez ";
+                        
+			$tab="SELECT 0,t2.id_sez,t2.num_sez,t2.validi,'0','0',t2.validi,t2.nulli,t2.bianchi,t2.contestati, t4.id_circ,t2.id_sede,'0' FROM ".$prefix."_ele_sezioni as t2 left join ".$prefix."_ele_sede as t4 on (t2.id_sede=t4.id_sede) where t2.id_cons='$id_cons' and t2.validi+t2.nulli+t2.bianchi+t2.contestati>0 group by t2.id_sez order by t2.num_sez ";
 		
 		}else{ // e' una lista uninominale o la seconda pagina
-			$tab="SELECT '0',t1.id_sez,t1.num_sez,sum(t2.voti),t1.solo_gruppo,t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t1.id_sede,'0'
+
+
+
+			# voto disgiunto regione sicilia aggiunge il campo solo lista
+		    if(isdisgiunto()){
+			$tab="SELECT '0',t1.id_sez,t1.num_sez,sum(t2.voti),t1.solo_gruppo,t1.solo_lista,t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t1.id_sede,'0'
 			FROM ".$prefix."_ele_sezioni as t1 left join ".$prefix.$tab3." as t2 on (t1.id_sez=t2.id_sez)
 			left join ".$prefix."_ele_sede as t4 on (t1.id_sede=t4.id_sede)
 			where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons group by t2.id_sez order by t1.num_sez ";
+		     }else{
+			
+			$tab="SELECT '0',t1.id_sez,t1.num_sez,sum(t2.voti),t1.solo_gruppo,'0',t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t1.id_sede,'0'
+			FROM ".$prefix."_ele_sezioni as t1 left join ".$prefix.$tab3." as t2 on (t1.id_sez=t2.id_sez)
+			left join ".$prefix."_ele_sede as t4 on (t1.id_sede=t4.id_sede)
+			where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons group by t2.id_sez order by t1.num_sez ";
+			}
 		}
-		
+	
+
+	
 		$riga1 = "";
 		if($pag==0)$riga1 .="<h2>"._DETTAGLIO." "._VOTIE."</h2>";
-		else $riga1 .="<h2>"._DETTAGLIO." "._VOTIE." "._ASOLA_LISTA."</h2>";
-		
-	}else{ // e' un referendum
-		$tab="SELECT t1.id_gruppo,t1.id_sez,t2.num_sez,t1.si,t1.no,t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t2.id_sede,t3.num_gruppo
+		else $riga1 .="<h4>"._DETTAGLIO." "._VOTIE." "._ASOLA_LISTA."</h4>";
+		
+	}else{ // e' un referendum --> t3.id_gruppo vuota per allineare il while (da rifare con array)
+		$tab="SELECT t1.id_gruppo,t1.id_sez,t2.num_sez,t1.si,t1.no,'0',t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t2.id_sede,t3.num_gruppo
 		FROM ".$prefix."_ele_voti_ref as t1 left join ".$prefix."_ele_sezioni as t2 on (t1.id_sez=t2.id_sez)
 		left join  ".$prefix."_ele_gruppo as t3 on (t1.id_gruppo=t3.id_gruppo) left join ".$prefix."_ele_sede as t4 on (t2.id_sede=t4.id_sede)
@@ -259,6 +277,14 @@
 		$riga3 .= "<td>"._SI."</td><td>"._NO."</td>";
 	} elseif ((($genere==5) or ($genere==3)) and $pag==1){
-		$riga3 .= "<td>"._ASOLA_LISTA."</td><td>"._ASOLO_GRUPPO."</td>";
-	}
+		$riga3 .= "<td>Voti "._LISTE."</td>";
+		if(isdisgiunto()){
+			$riga3 .= "<td>Voti "._PRESI."</td>";
+			$riga3 .= "<td>"._SOLO_LISTA."</td>";
+			
+			
+		} // voto disgiunto
+		$riga3 .= "<td>"._ASOLO_GRUPPO."</td>";
+	}
+        
 	$riga3 .= "<td>"._VALIDI."</td><td>"._NULLI."</td><td>"._BIANCHI."</td><td>"._CONTESTATI."</td>"
     ."</tr>\n";
@@ -268,5 +294,7 @@
 	$scrutinate=1;
 	$tot_u=0;$tot_d=0;$tot_voti=0; $tot_si=0;$tot_no=0;$tot_validi=0;$tot_nulli=0;$tot_bianchi=0;$tot_contestati=0;
-	while (list($id_gruppo,$id,$num,$si,$no,$validi,$nulli,$bianchi,$contestati,$id_circ,$id_sede,$gruppo) = mysql_fetch_row($res)){
+	$tot_sololista=0;$tot_gruppo=0;
+	#$si e $no sono valide anche per voti lista e solo gruppo per i non referendum
+	while (list($id_gruppo,$id,$num,$si,$no,$sololista,$validi,$nulli,$bianchi,$contestati,$id_circ,$id_sede,$gruppo) = mysql_fetch_row($res)){
 	// inserimento numeri di sez non scrutinate
 		while ($scrutinate < $num) { 
@@ -274,4 +302,11 @@
 			$scrutinate++;
 		}
+
+	# voti sindaco, gruppo o presidente
+	$tab5="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id'";
+	$res3 = mysql_query("$tab5", $dbi);
+	list($sindaco) = mysql_fetch_row($res3);	
+	
+
 		$scrutinate++; 
 	// fine inserimento	
@@ -281,4 +316,5 @@
 		list($votid,$votiu,$voti) = mysql_fetch_row($res2);
 //		$voti=$votiu+$votid;
+		$tot_gruppo+=$sindaco;
 		$tot_u+=$votiu;
 		$tot_d+=$votid;
@@ -290,4 +326,5 @@
 		$tot_bianchi+=$bianchi;
 		$tot_contestati+=$contestati;
+		$tot_sololista+=$sololista;
 		$righe .= "<tr class=\"bggray2\">
 		<td>$num</td>
@@ -295,9 +332,19 @@
 		<td>".number_format($votid,0,',','.')."</td>
 		<td>".number_format($voti,0,',','.')."</td>";
-		if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){$righe 
-		.= "<td>".number_format($si,0,',','.')."</td>
-		<td>".number_format($no,0,',','.')."</td>";}
-		
+		if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){
+		$righe .= "<td>".number_format($si,0,',','.')."</td>";
+		
+		if(isdisgiunto()){
+			$righe .= "<td>".number_format($sindaco,0,',','.')."</td>";
+			$righe .= "<td>".number_format($sololista,0,',','.')."</td>";
+			}
+		$righe .= "<td>".number_format($no,0,',','.')."</td>";	
+
+
+}
+		
+
 		$righe .= "<td>".number_format($validi,0,',','.')."</td>
+
 		<td>$nulli</td>
 		<td>$bianchi</td>
@@ -320,5 +367,11 @@
 		$righet .= "<td>"._SI."</td><td>"._NO."</td>";
 	} elseif ((($genere==5) or ($genere==3)) and $pag==1){
-		$righet .= "<td>"._ASOLA_LISTA."</td><td>"._ASOLO_GRUPPO."</td>";
+		$righet .= "<td>Voti "._LISTE."</td>";
+		if(isdisgiunto()){
+			$righet .= "<td>Voti "._PRESI."</td>";
+			$righet .= "<td>"._SOLO_LISTA."</td>";
+		} // voto disgiunto	
+		$righet .= "<td>"._ASOLO_GRUPPO."</td>";
+		
 	}
 	if($totel==0) $totelrip="0.00"; else $totelrip=number_format($tot_voti*100/$totel,2);
@@ -330,16 +383,29 @@
 
 
-	<tr class=\"td-vuotoc\"><td><b>"._TOT."</b></td><td><b>".number_format($tot_u,0,',','.')."</b><br /><i>(".$totmrip." %)</i></td><td><b>".number_format($tot_d,0,',','.')."</b><br /><i>(".$totfrip." %)</i></td><td><b>".number_format($tot_voti,0,',','.')."</b><br /><i>(".$totelrip." %)</i></td>";
+	<tr class=\"td-vuotoc\"><td><b>"._TOT."</b></td><td><b>".number_format($tot_u,0,',','.')."</b><br /><i>(".$totmrip."%)</i></td><td><b>".number_format($tot_d,0,',','.')."</b><br /><i>(".$totfrip."%)</i></td><td><b>".number_format($tot_voti,0,',','.')."</b><br /><i>(".$totelrip."%)</i></td>";
 	
 	// se e' un referendum o una consultazione con raggruppamenti
 
 	if($tot_validi){
-	if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){$righet .= "<td><b>".number_format($tot_si,0,',','.')."</b><br /><i>(".number_format($tot_si*100/$tot_validi,2)." %)</i></td><td><b>".number_format($tot_no,0,',','.')."</b><br /><i>(".number_format($tot_no*100/$tot_validi,2)." %)</i></td>";}
-	$righet .= "<td><b>".number_format($tot_validi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_validi*100/$tot_voti,2):'0.00')." %)</i></td><td><b>"
-	.number_format($tot_nulli,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_nulli*100/$tot_voti,2):'0.00')." %)</i></td><td><b>".number_format($tot_bianchi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_bianchi*100/$tot_voti,2):'0.00')." %)</i></td><td><b>".number_format($tot_contestati,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_contestati*100/$tot_voti,2):'0.00')." %)</i></td></tr>";
+	if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){
+		$righet .= "<td><b>".number_format($tot_si,0,',','.')."</b><br /><i>(".number_format($tot_si*100/$tot_validi,2)."%)</i></td>";
+
+		if(isdisgiunto()){
+			$righet .="<td><b>".number_format($tot_gruppo,0,',','.')."</b><br /><i>(".number_format($tot_gruppo*100/$tot_validi,2)."%)</i></td>";
+			$righet .="<td><b>".number_format($tot_sololista,0,',','.')."</b><br /><i>(".number_format($tot_sololista*100/$tot_validi,2)."%)</i></td>";
+		}
+
+
+	$righet .="<td><b>".number_format($tot_no,0,',','.')."</b><br /><i>(".number_format($tot_no*100/$tot_validi,2)."%)</i></td>";	
+	}
+
+
+		$righet .= "<td><b>".number_format($tot_validi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_validi*100/$tot_voti,2):'0.00')."%)</i></td><td><b>"
+	.number_format($tot_nulli,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_nulli*100/$tot_voti,2):'0.00')."%)</i></td><td><b>".number_format($tot_bianchi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_bianchi*100/$tot_voti,2):'0.00')."%)</i></td><td><b>".number_format($tot_contestati,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_contestati*100/$tot_voti,2):'0.00')."%)</i></td></tr>";
 	}else{
-	if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){$righet .= "<td><b>".number_format($tot_si,0,',','.')."</b><br /><i>(0.00 %)</i></td><td><b>".number_format($tot_no,0,',','.')."</b><br /><i>(0.00 %)</i></td>";}
-	$righet .= "<td><b>0</b><br /><i>(0.00 %)</i></td><td><b>"
-	.number_format($tot_nulli,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_nulli*100/$tot_voti,2):'0,00')." %)</i></td><td><b>".number_format($tot_bianchi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_bianchi*100/$tot_voti,2):'0,00')." %)</i></td><td><b>".number_format($tot_contestati,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_contestati*100/$tot_voti,2):'0,00')." %)</i></td></tr>";
+	if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){
+	$righet .= "<td><b>".number_format($tot_si,0,',','.')."</b><br /><i>(0.00%)</i></td><td><b>".number_format($tot_no,0,',','.')."</b><br /><i>(0.00%)</i></td>";}
+	$righet .= "<td><b>0</b><br /><i>(0.00%)</i></td><td><b>"
+	.number_format($tot_nulli,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_nulli*100/$tot_voti,2):'0,00')."%)</i></td><td><b>".number_format($tot_bianchi,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_bianchi*100/$tot_voti,2):'0,00')."%)</i></td><td><b>".number_format($tot_contestati,0,',','.')."</b><br /><i>(".($tot_voti ? number_format($tot_contestati*100/$tot_voti,2):'0,00')."%)</i></td></tr>";
 	}
 	}
@@ -395,4 +461,5 @@
 
 
+
 ############### stampa
 if ($xls!='1' && $pdf!='1'){
@@ -406,7 +473,14 @@
 	echo "$html \n";
 }elseif($pdf=='1'){
+
+
 		$nomefile="$descr_cons votanti.pdf";
-		
-		$stampa ="$datipdf $html";
+
+
+
+
+
+		
+		$stampa ="<div style=\"margin:0 auto;text-align:center;\">$datipdf $html</div>";
 		
 		require_once('inc/hpdf403/html2pdf.class.php');
@@ -414,5 +488,9 @@
 		$html2pdf->WriteHTML($stampa, isset($_GET['vuehtml']));
 		$html2pdf->Output($nomefile);
-}
+
+
+}
+
+
 
 
