"; $siteistat=$id_comune; if($xls!=1) $datipdf .= "
\"mappa\""; $datipdf .= ""._COMUNE." $descr_com
"._RISULTA." "._CONSULTA."
"; $datipdf .= "

$descr_cons

"._DISCLAIMER.""; if($xls!=1) $datipdf .= "
"; $datipdf .="

"._DETTAGLIO." "._AFFLUENZE."

"; $html = ""; } // referendum 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? } 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); } // icone stampa e grafici if (!$csv){ if(!isset($html)) $html=''; $html .= "
"._VER_GRAF." \"\" "._VER_STAMPA." \"\" \"\"

"._DETTAGLIO." "._AFFLUENZE."

"; } // 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); if(!isset($html)) $html=''; $html .= "

$descrizione

"; } $cond= $genere==0 ? "and t3.id_gruppo='$id_gruppo'" : ""; $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 $circos order by num_sez", $dbi); while ($linka[$i++] = mysql_fetch_array($res)); # 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 $sez_da=$linka[1]['num_sez']; $sez_a=$sez_da+$num_sez-1; $tot_compl=0;$tot_u=0;$tot_d=0; // $ar['riga1'][0]="
"; $tot= array(); $ar[0][0]="TOTALI"; $ar['perc'][0]="Perc."; // $ar['riga2'][0]="
"; # foreach($linka['num_sez'] as $i) $y=1; for ($i=$sez_da;$i<=$sez_a;$i++,$y++) { # $ar[$i]['numsez']=$i; $ar[$i]['numsez']=$linka[$y]['num_sez']; $ar[$i]['elettori']=number_format($linka[$y]['elettori'],0,',','.'); $tot_compl+=$linka[$y]['elettori']; $tot_u+=$linka[$y]['maschi']; $tot_d+=$linka[$y]['femmine']; } $ar[0][1]="".number_format($tot_compl,0,',','.').""; $ar['perc'][1]=" "; $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 if(!isset($html)) $html=''; $html .= ""; $html .= ""; # $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); $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 group by t3.data,t3.orario,t3.id_gruppo ",$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 "); while (list($data,$ora,$somma,$votiu,$votid) = mysql_fetch_row($ressomma)) { if($votiu or $votid) { $tot[$data.$ora]="
"._SEZIONI.""._ISCR_SEZ."
".number_format($votiu,0,',','.')." ".number_format($votid,0,',','.')." ".number_format($somma,0,',','.')."
"; $perc_u=number_format($votiu*100/$tot_u,2); $perc_d=number_format($votid*100/$tot_d,2); $perc_c=number_format($somma*100/$tot_compl,2); } else $tot[$data.$ora]=$somma; } $ud=0;$ora_rif=""; while (list($data1,$ora1) = mysql_fetch_row($resril)) { $ud++; list($hour, $minute, $second) = explode(":", $ora1); $ora_ril=$hour.":".$minute; $html .= ""._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 $html .= "
"._SEZIONI." $num_scr "._SU." $num_sez"; if ($ud==$num_ril and ($perc_u or $perc_d)) $html .= "
"._UOMINI." "._DONNE." "._COMPLESSIVI."
"; $html .= ""; if (isset($tot[$data1.$ora1])){ if ($ora_rif=="$data1.$ora1") { $ar['perc'][$data1.$ora1]="
$perc_u% $perc_d% $perc_c%
"; $ar[0][$data1.$ora1]=$tot[$data1.$ora1]; } else { $ar['perc'][$data1.$ora1]=" ".number_format($tot[$data1.$ora1]*100/$tot_compl,2)."%"; $ar[0][$data1.$ora1]="".(number_format($tot[$data1.$ora1],0,',','.')).""; } if (intval(ereg("[1-9]",$tot[$data1.$ora1]))>0) { #foreach($ar[['num_sez'] as $i) for ($i=$sez_da;$i<=$sez_a;$i++) { $ar[$i][$data1.$ora1]="non rilevata"; } } } } $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); $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)) { if ($ora_rif=="$data.$ora") $ar[$numsez][$data.$ora]="
$uomini $donne $complessivi
"; else $ar[$numsez][$data.$ora]=$complessivi; } $html .= ""; foreach ($ar as $i => $arr) { $html .= ""; foreach ($arr as $valore) { $html .= "$valore"; } $html .= ""; } $html .= ""; if($genere==0){ //se e' referendum #'Pagina precedente' e 'Pagina Successiva' $html .= "
"; $cur=$num_ref; if ($cur>1) { $num_ref--; $html .= ""; $html .= "[ "._PREV_MATCH." ] "; } if ($cur<$num_refs) { $cur++; $html .= ""; $html .= "[ "._NEXT_MATCH." ] "; } $html .= "
"; } if(!isset($style)) $style=''; if($csv==1){ $data=date("d-m-y G:i"); $style .="\t\t\n


Stampato: $data
"; $style .="
Eleonline by l. apolito & r. gigli - www.eleonline.it
"; $style .= "
"; } $html .= ""; ############### stampa if ($xls!='1'){ echo "$datipdf $html $style"; }else{ $nomefile="export.xls"; header ("Content-Type: application/vnd.ms-excel"); header ("Content-Disposition: inline; filename=$nomefile"); echo "$datipdf"; echo "$html \t\n $style"; } if($csv!=1 ) include ("footer.php"); ?>