prepare("$sql"); $res->execute(); list($tipo_cons,$genere,$id_cons,$vismf) = $res->fetch(PDO::FETCH_NUM); global $lang,$circo,$id_circ; if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'"; else $circos=''; # testata include_once("modules/Elezioni/language/lang-$lang.php"); $datipdf=''; if($csv==1){ include_once("modules/Elezioni/funzioni.php"); $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 .= "
"; $siteistat=$id_comune; # salva sull'hardisk lo stemma del comune $logo=verificasimbolo(); $immagine= "\"logo\""; if($xls!=1) $datipdf .= "
$immagine"; $datipdf .= ""._COMUNE." $descr_com
"._RISULTA." "._CONSULTA."
"; $datipdf .= "$descr_cons
"._DISCLAIMER."
"._DETTAGLIO." "._AFFLUENZE.""; if($xls!=1) $datipdf .= "
"; $datipdf .="
"; $html = ""; } // referendum $posref=''; if (!IsSet($num_ref)) { $num_ref=1; $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'){ $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="&num_ref=$num_ref&num_refs=$num_refs"; } // icone stampa e grafici if (!$csv){ if(!isset($html)) $html=''; $html .= "
"._VER_GRAF." \"\" "._VER_STAMPA." \"\" \"\" \"\"

"._DETTAGLIO." "._AFFLUENZE."

"; } // descrizione if ($genere==0){ $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 .= "

$descrizione

"; } $cond= $genere==0 ? "and t3.id_gruppo='$id_gruppo'" : ""; $i=1; $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 = $res->rowCount(); //numero totale delle sezioni if (isset($linka[1]['num_sez'])) $sez_da=$linka[1]['num_sez']; else $sez_da=0; $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; if(!isset($linka[$y]['num_sez'])) { $linka[$y]['num_sez']=0; $linka[$y]['elettori']=0;} $z=$linka[$y]['num_sez']; $ar[$z]['numsez']=$linka[$y]['num_sez']; $ar[$z]['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; $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=''; if($csv && $pdf) $tabpdf="style=\"width:45%; margin:0px auto;text-align:center;\""; else $tabpdf=''; $html .= ""; $html .= ""; $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) = $ressomma->fetch(PDO::FETCH_NUM)) { $perc_u[$data.$ora]=0; $perc_d[$data.$ora]=0; $perc_c[$data.$ora]=0; if($votiu or $votid) # if(($data==$ultdata) and ($ora==$ultora)) { $tot[$data.$ora]="
"._SEZIONI.""._ISCR_SEZ."
".number_format($votiu,0,',','.')." ".number_format($votid,0,',','.')." ".number_format($somma,0,',','.')."
"; $perc_u[$data.$ora]=number_format($votiu*100/$tot_u,2); $perc_d[$data.$ora]=number_format($votid*100/$tot_d,2); $perc_c[$data.$ora]=number_format($somma*100/$tot_compl,2); } else $tot[$data.$ora]=$somma; } $ud=0;$ora_rif=""; while (list($data1,$ora1) = $resril->fetch(PDO::FETCH_NUM)) { $ud++; list($hour, $minute, $second) = explode(":", $ora1); $ora_ril=$hour.":".$minute; $html .= ""._ORE." ".$ora_ril; $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 .= "
"._SEZIONI." $num_scr "._SU." $num_sez"; ## if ($ud==$num_ril and ($perc_u or $perc_d)) $html .= "
$html .= "
"; if ((isset($perc_u[$data1.$ora1]) or isset($perc_d[$data1.$ora1])) and ($perc_u[$data1.$ora1]+$perc_d[$data1.$ora1])>0) $html .= "
"._UOMINI.""._DONNE.""._COMPLESSIVI."
"; else $html .= ""._COMPLESSIVI.""; if (isset($tot[$data1.$ora1])){ ## if ($ora_rif=="$data1.$ora1") if (($perc_u[$data1.$ora1] or $perc_d[$data1.$ora1])){ $ar['perc'][$data1.$ora1]="
".$perc_u[$data1.$ora1]."% ".$perc_d[$data1.$ora1]."% ".$perc_c[$data1.$ora1]."%
"; $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(preg_match('/[1-9]/',$tot[$data1.$ora1]))>0) { #foreach($ar[['num_sez'] as $i) ########## $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)=$resvoti->fetch(PDO::FETCH_NUM)) { $ar[$i][$data1.$ora1]="non rilevata"; } } } } $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; while (list($data,$ora,$numsez,$uomini,$donne,$complessivi) = $resvoti->fetch(PDO::FETCH_NUM)) { if(($uomini+$donne)>0) $ar[$numsez][$data.$ora]="
$uomini $donne $complessivi
"; else $ar[$numsez][$data.$ora]=$complessivi; } $html .= ""; foreach ($ar as $i => $arr) { if(intval($i) % 2) $html .= ""; else $html .= ""; foreach ($arr as $valore) { $html .= "$valore"; } $html .= ""; } $html .= ""; if($genere==0){ //se e' referendum #'Pagina precedente' e 'Pagina Successiva' if ($xls!='1' && $pdf!='1' && $csv!='1'){ $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 luciano apolito e roberto gigli - www.eleonline.it
"; $style .= "
"; } ?>