prepare("$sql"); $res->execute(); list($descr_comune) = $res->fetch(PDO::FETCH_NUM); $sql="SELECT t1.descrizione, t1.tipo_cons,t2.genere, t2.voto_g, t2.voto_l, t2.voto_c, t2.circo FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_tipo as t2 where t1.tipo_cons=t2.tipo_cons and t1.id_cons_gen='$id_cons_gen' "; $res = $dbi->prepare("$sql"); $res->execute(); list($descr_cons,$tipo_cons,$genere,$votog,$votol,$votoc,$circo) = $res->fetch(PDO::FETCH_NUM); $sql="SELECT t2.id_cons,t2.solo_gruppo,t2.disgiunto 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'" ; $res = $dbi->prepare("$sql"); $res->execute(); list($id_cons,$dettnulli,$disgiunto) = $res->fetch(PDO::FETCH_NUM); //////////////////////////////////////////////////////////// // Visualizza i dati per liste, gruppi e referendum, per sezione o circoscrizione //////////////////////////////////////////////////////////// function gruppo_circo(){ global $prefix, $dbi, $descr_cons, $id_cons, $id_cons_gen,$tipo_cons,$votog,$votol,$votoc,$circo, $genere,$id_gruppo,$id_lista,$bgcolor1,$bgcolor2,$id_comune,$descr_comune,$id_circ; global $id_comune,$id_cons_gen,$op,$minsez,$id_lista,$id_circ,$csv,$min,$orienta,$formato,$dettnulli,$disgiunto, $orvert,$offset,$offsetsez,$perc,$info,$files,$nomefile; $nomefile=""; #Denominazione pagine if($op=="gruppo_circo") $pagina=_GRUPPO." "._PER." "._CIRCO; if($op=="gruppo_sezione") $pagina=_GRUPPO." "._PER." "._SEZIONI; if($op=="lista_circo") $pagina=_LISTA." "._PER." "._CIRCO; if($op=="lista_sezione") $pagina=_LISTA." "._PER." "._SEZIONI; if($op=="candidato_circo") $pagina=_CONSI." "._PER." "._CIRCO; if($op=="candidato_sezione") $pagina=_CONSI." "._PER." "._SEZIONI; if($op=="consiglieri") $pagina=_CALCONS; if (strstr( $op,'circo')) { //$op=='gruppo_circo' or $op=='lista_circo') { $tab1="circ"; $tab2="t5.num_circ,t5.descrizione"; $tab3="t5.num_circ"; $tipo1=_DA." "._CIRCO; $tipo2=_CIRCOS; $tipo3=_CIRCO; }else{ $tab1="sez"; $tab2="t3.num_sez,''"; $tab3="t3.num_sez"; $tipo1=_DA." "._SEZIONE; $tipo2=_SEZIONI; $tipo3=_SEZIONE; } if (strstr( $op,"gruppo")){ $tab="gruppo"; }elseif (strstr( $op,'lista')) { $tab="lista"; }else{ $tab="candidati"; } if ($orvert) { $righe=''; $colonne='checked'; }else{ $righe='checked'; $colonne=''; } if ($orienta) { $land=''; $port='checked'; }else{ $land='checked'; $port=''; } if ($formato) { $A3=''; $A4='checked'; }else{ $A3='checked'; $A4=''; } if ($genere>0) { //se non e' un referendum $voticompl=0; if (!($offset)) $offset=25; if (!($min)) $min=1; if (!($offsetsez)) $offsetsez=22; if (!($minsez)) $minsez=1; if ($min>$offset) { $appo=$min; $min=$offset; $offset=$appo; } if ($minsez>$offsetsez) { $appo=$minsez; $minsez=$offsetsez; $offsetsez=$appo; } if (!$csv){ echo "
"; echo "
"; echo ""; } $condcirc=''; if ($circo){ //gestione circoscrizionali if(!$id_circ){ $sql="SELECT id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons and num_circ=1"; $res_cir = $dbi->prepare("$sql"); $res_cir->execute(); //se non si e' scelta una circoscr. prende la prima list($id_circ)=$res_cir->fetch(PDO::FETCH_NUM); } $sql="SELECT num_circ from ".$prefix."_ele_circoscrizione where id_circ=$id_circ"; $res_cir = $dbi->prepare("$sql"); $res_cir->execute(); //estrae il numero della circoscrizione list($num_circ)=$res_cir->fetch(PDO::FETCH_NUM); $condcirc="and id_circ=$id_circ"; //variabile aggiunta nelle select per le circ. $sql="SELECT count(t1.num_sez) from ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons=$id_cons and t1.id_sede=t2.id_sede and t2.id_circ=$id_circ"; $res_sez = $dbi->prepare("$sql"); $res_sez->execute(); //numero di sezioni nella circoscrizione $sql="SELECT min(t1.num_sez) from ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons=$id_cons and t1.id_sede=t2.id_sede and t2.id_circ=$id_circ"; $res_min = $dbi->prepare("$sql"); $res_min->execute(); //setta minsez sulla prima sezione della circoscrizione list($minsez)=$res_min->fetch(PDO::FETCH_NUM); } elseif (strstr( $op,'circo')){ $sql="SELECT count(num_circ),min(num_circ),max(num_circ) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons"; $res_sez = $dbi->prepare("$sql"); $res_sez->execute(); } else{ $sql="SELECT count(num_sez),min(num_sez),max(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons"; $res_sez = $dbi->prepare("$sql"); $res_sez->execute(); } if($res_sez->rowCount()) list($tot_sez,$numsezmin,$numsezmax)=$res_sez->fetch(PDO::FETCH_NUM); $sql="SELECT count(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons"; $res_sez = $dbi->prepare("$sql"); $res_sez->execute(); list($tuttelesez)=$res_sez->fetch(PDO::FETCH_NUM); $num_sez=$tot_sez;//mysql_data_seek($res_sez,0); if ($circo) $offsetsez=$numsezmax; //$num_sez+$minsez-1;//setta offsetsez sull'ultima sezione della circoscrizione $visvot=''; if (!$csv) echo "
$pagina
"; if (!$csv) echo "
"; if(strstr( $op,'candidato')){ // $numliste=mysql_num_rows($res_lis); $visvot="cand"; if (!$csv){ $sql="SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $condcirc order by num_lista"; $res_lis = $dbi->prepare("$sql"); $res_lis->execute(); //elenco delle liste per la scelta echo "

"._SCEGLI_LISTA.":

"; } $sql="SELECT count(t1.id_sez) from ".$prefix."_ele_voti_$tab as t1, ".$prefix."_ele_$tab as t2 where t2.id_lista=$id_lista and t1.id_cand=t2.id_cand group by t1.id_cand"; $res_scr = $dbi->prepare("$sql"); $res_scr->execute(); $sqlc="SELECT id_cand, concat(cognome,' ', nome), num_cand from ".$prefix."_ele_$tab where id_cons=$id_cons and id_lista=$id_lista order by num_cand"; $res_cand = $dbi->prepare("$sqlc"); $res_cand->execute(); if ($circo) $condcirc="and t5.id_circ=$id_circ"; $sqlvoti="select $tab2, t1.num_cand, concat(t1.cognome,' ', t1.nome) as nome, sum(t2.voti),'','','','','' from ".$prefix."_ele_candidati as t1, ".$prefix."_ele_voti_candidati as t2, " .$prefix."_ele_sezioni as t3, ".$prefix."_ele_sede as t4, ".$prefix."_ele_circoscrizione as t5 where t1.id_lista=$id_lista and t1.id_cons=$id_cons and t1.id_cand=t2.id_cand and t2.id_sez=t3.id_sez and t3.id_sede=t4.id_sede and t4.id_circ=t5.id_circ $condcirc group by t1.num_cand,$tab3, nome order by $tab3,t1.num_cand"; $res_voti = $dbi->prepare("$sqlvoti"); $res_voti->execute(); }else{ if (!$csv) echo ""; // camera e senato nel 2006 aggiunte le somme della coalizione // divise per circo e sez. in quanto nella tabella del gruppo // all'atto dell'immsione non viene fatta la somma // quindi leggere prima i voti di lista e poi agganciali al gruppo // la var $tab diviene lista, $tab15 diviene gruppo in caso di somma // dei voti di lista...oltre naturalmnte alle condizioni messe in variabile // 4 aprile 2006 by luc if ($votog && $tab=="gruppo"){ // camera e senato 2006 $t="t9"; $tab="lista"; $tab15="gruppo"; $add_1= ",".$prefix."_ele_gruppo as t9"; $and_1="and t1.id_gruppo=t9.id_gruppo"; }else{ $t="t1"; $tab15=$tab; $add_1=''; $and_1=''; } // fine della modifica $sql="SELECT count(id_sez) from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons' group by id_$tab15"; $res_scr = $dbi->prepare("$sql"); $res_scr->execute(); //numero sezioni scrutinate $sqlc="SELECT id_$tab15, descrizione, num_$tab15 from ".$prefix."_ele_$tab15 where id_cons='$id_cons' $condcirc order by num_$tab15"; $res_cand = $dbi->prepare("$sqlc"); $res_cand->execute(); if ($circo) $condcirc="and t5.id_circ=$id_circ"; if ($tab=="gruppo" or $genere==4) $votigl=" sum(t3.validi),sum(t3.nulli),sum(t3.bianchi),sum(t3.contestati),sum(t3.voti_nulli)"; else if ($votog) $votigl=" (t3.validi_lista),(t3.nulli),(t3.bianchi),(t3.contestati),(t3.voti_nulli)"; else $votigl=" sum(t3.validi_lista),sum(t3.nulli),sum(t3.bianchi),sum(t3.contestati_lista),sum(t3.voti_nulli_lista+t3.voti_nulli)"; $sqlvoti="select $tab2, $t.num_$tab15, $t.descrizione, sum(t2.voti), $votigl from ".$prefix."_ele_$tab as t1, ".$prefix."_ele_voti_$tab as t2, ".$prefix."_ele_sezioni as t3, ".$prefix."_ele_sede as t4, ".$prefix."_ele_circoscrizione as t5 $add_1 where t1.id_cons=$id_cons and t1.id_$tab=t2.id_$tab $and_1 and t2.id_sez=t3.id_sez and t3.id_sede=t4.id_sede and t4.id_circ=t5.id_circ $condcirc group by $t.num_$tab15,$tab3,$tab2, $t.descrizione order by $tab3,$t.num_$tab15"; $res_voti = $dbi->prepare("$sqlvoti"); $res_voti->execute(); } if ($res_scr) list($tot_scr)=$res_scr->fetch(PDO::FETCH_NUM);else $tot_scr=0; if ($res_cand) $num_cand=$res_cand->rowCount(); else $num_cand=0; if(!$circo){ if (!(0 < $minsez and $minsez<=$numsezmax)) $minsez=1; if (!(0<$offsetsez and $offsetsez<=$numsezmax)) $offsetsez=$numsezmax; } if (!(0 < $min and $min<=$num_cand)) $min=1; if (!(0<$offset and $offset<=$num_cand)) $offset=$num_cand; if (!$csv) { if(strstr( $op,'lista')){$scelta=_SCEGLI_LISTA;}else{$scelta=_SCEGLI_CANDI;} echo "

$scelta "._DA.":  "; echo "  "._A.": 

"; //echo "
"; if(!$circo){ echo "

"._SCEGLI." $tipo1 n. "; echo _A." n. (max. $numsezmax)"; } # pagine ############ if (strstr( $op,'circo')) $sql="SELECT count(num_circ) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons and num_circ>=$minsez and num_circ<=$offsetsez"; else $sql="SELECT count(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons and num_sez>=$minsez and num_sez<=$offsetsez"; $resnsez = $dbi->prepare("$sql"); $resnsez->execute(); list($diff)=$resnsez->fetch(PDO::FETCH_NUM); ######## # $diff=($offsetsez-$minsez); if ($minsez>1){ $minsez_p= ($minsez-$diff)>1 ? $minsez-$diff:1; $offsetsez_p=$offsetsez-$diff; echo "

<- $tipo2 Precedenti
"; }else{echo "";} if ($offsetsez<$numsezmax){ $minsez_s=$minsez+$diff; $offsetsez_s= ($offsetsez+$diff)>$num_sez ? $num_sez: $offsetsez+$diff; echo "
$tipo2 Successive ->
"; }else{echo "";} if(!$circo) echo "

"._MOSTRA." $tipo2 "._PERCOL.""._PERRIGHE." "; echo "
"; echo "

"; if (!strstr( $op,'candidato')) { echo ""._VIS_PERC.":
"; } echo ""; if($circo) echo ""; echo ""; echo ""; echo ""; echo ""; echo "

"; #### recupera dati stampa supporti diversi dati //echo ""._COMUNE." $descr_comune - "._RISULTATI.": $descr_cons
"; //echo "tot:$tot_scr"; //if ($tipo_cons!=4 && $tot_scr) echo " - Sezioni scrutinate: $tot_scr su $tuttelez"; # liste e gruppi da.... a if (!strstr( $op,'candidato')) { $sql="SELECT descrizione from ".$prefix."_ele_$tab15 where id_cons='$id_cons' and num_$tab15 ='$min'"; $res_cand2 = $dbi->prepare("$sql"); $res_cand2->execute(); list($descrizione)= $res_cand2->fetch(PDO::FETCH_NUM); $list1 ="da $descrizione "; $sql="SELECT descrizione from ".$prefix."_ele_$tab15 where id_cons='$id_cons' and num_$tab15 ='$offset'"; $res_cand3 = $dbi->prepare("$sql"); $res_cand3->execute(); list($descrizione)= $res_cand3->fetch(PDO::FETCH_NUM); $list1 .=" a $descrizione
"; }else{$list1='';} # nome della lista if (!isset($list2)) $list2=''; if (strstr( $op,'candidato')) { $sql="SELECT num_lista, descrizione from ".$prefix."_ele_lista where id_lista=$id_lista"; $res_lis2 = $dbi->prepare("$sql"); $res_lis2->execute(); list($num_lista2,$descr_lista2)= $res_lis2->fetch(PDO::FETCH_NUM); $nomefile=" Lista n. $num_lista2 - $descr_lista2 "; $list2 .=" Lista n. $num_lista2 - $descr_lista2
"; $sql="SELECT concat(cognome,' ', nome) from ".$prefix."_ele_$tab where id_cons=$id_cons and id_lista=$id_lista and num_cand=$min"; $res_cand4 = $dbi->prepare("$sql"); $res_cand4->execute(); list($descrizione)= $res_cand4->fetch(PDO::FETCH_NUM); $list3 ="da $descrizione "; $sql="SELECT concat(cognome,' ', nome) from ".$prefix."_ele_$tab where id_cons=$id_cons and id_lista=$id_lista and num_cand=$offset"; $res_cand5 = $dbi->prepare("$sql"); $res_cand5->execute(); list($descrizione)= $res_cand5->fetch(PDO::FETCH_NUM); $list3 .="a $descrizione
"; }else{ $list2 .='';$list3='';} if(!isset($tab15)) $tab15=''; $nomefile.="$descr_cons $tab15"; $_SESSION['nomefile']=strip_tags(str_replace(" ", "_", $nomefile)); $datipdf=""._COMUNE." $descr_comune - "._RISULTATI.": $descr_cons
$pagina

$list1 $list2 $list3 "; # verificare la stampa sulle circoscrizioni echo "
"; echo " "; # stampa pdf echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; # echo ""; echo ""; echo "
"._ESPORTA."
"; if($circo){ echo "\"Stampa\""; }else{ echo "\"Stampa\""; echo "\"Export"; echo "\"Export"; echo "
"; echo ""; echo "  L  P  
"; echo "  A3A4"; echo "
"; } echo "

"; } if (!$csv){ echo "
Sezioni scrutinate"; if ($tipo_cons!=4) echo ": $tot_scr su $tuttelesez     "; echo "
 "; } $y=1; $ar[0][0]=$tipo3; $ra[0][0]=$tipo3; $num_sez++; $voticompl=0; $ominsez=$minsez-1; $valar=array();$percar=array(); //////////////////////////////////////////////////////////////////// // sandro: carica i numeri di sezione dal DB - giugno 2009 // caso: sezioni in collegi diversi non consecutive if (strstr( $op,'circo')) $sql="select num_circ,id_circ from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' and num_circ>='$minsez' and num_circ<='$offsetsez' order by num_circ"; else{ if($circo) { $secirco=" and t2.id_circ=$id_circ";} else $secirco="and t1.num_sez >= $minsez and t1.num_sez <= $offsetsez"; $numsezioni = $offsetsez-$ominsez; $sql="SELECT t1.num_sez,t1.id_sez from ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons=$id_cons and t1.id_sede=t2.id_sede $secirco order by t1.num_sez"; } $res_numsez = $dbi->prepare("$sql"); $res_numsez->execute();# for ($z=1;$z<=($offsetsez-$ominsez);$z++) { while($res=$res_numsez->fetch(PDO::FETCH_NUM)) { $sevaltot=0; $senultot=0; $sebiatot=0; $secontot=0; $sevnutot=0; $z=$res[0]; ##############inserimento percentuale di scrutinio nella sezione $scruvalidi=0; $scrunulli=0; $grpercscru=0; $altri=0; $votiscru=0; if($op=="gruppo_sezione"){ $sqlr="select sum(validi),sum(solo_lista) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'"; $sqlv="select sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='".$res[1]."'"; $resperc = $dbi->prepare("$sqlr"); $resperc->execute(); $votiperc = $dbi->prepare("$sqlv"); $votiperc->execute(); } elseif($op=="lista_sezione"){ $sqlr="select sum(validi),sum(contestati_lista+solo_gruppo+voti_nulli_lista) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'"; $sqlv="select sum(voti) from ".$prefix."_ele_voti_lista where id_sez='".$res[1]."'"; $resperc = $dbi->prepare("$sqlr"); $resperc->execute(); $votiperc = $dbi->prepare("$sqlv"); $votiperc->execute(); } if (isset($resperc) and $resperc) list($scruvalidi,$scrunulli)=$resperc->fetch(PDO::FETCH_NUM); if (isset($votiperc) and $votiperc) list($votiscru)=$votiperc->fetch(PDO::FETCH_NUM); $sql="select sum(voti_complessivi) from ".$prefix."_ele_voti_parziale where id_sez='".$res[1]."' group by data,orario order by data desc, orario desc limit 0,1 "; $resperc = $dbi->prepare("$sql"); $resperc->execute(); if ($resperc) list($totschede)=$resperc->fetch(PDO::FETCH_NUM); if (isset($scruvalidi) and $scruvalidi>0 ) $grpercscru=$votiscru ? number_format(($votiscru+$scrunulli)*100/$scruvalidi,0) : 0; ################### ".$temp3[$key]." % $ar[$z][0]=$res[0]; if($grpercscru) {$ar[$z][0].="
$grpercscru%";if(!strstr($ar[0][0],'scrutinio')) $ar[0][0].="
% scrutinio"; } $pos[$z]=$res[0]; #$valar[$z]=array(); } if (!isset($pos)) $pos[0]=0; $minpos=min($pos); $maxpos=max($pos); //////////////////////////////////////////////////////////////////// if ($res_voti->rowCount()) while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){ # if($genere==4) $sevalidi=$voti; $z=array_search($num_circ, $pos); if (!isset($votitot[($z)])) { $votitot[($z)]=0; if($sevalidi) $sevaltot+=$sevalidi; if($senulli) $senultot+=$senulli; if($sebianchi) $sebiatot+=$sebianchi; if($secontestati) $secontot+=$secontestati; if($sevonulli) $sevnutot+=$sevonulli; } $votitot[($z)]+=$voti; if(!isset($valsez[$z])) $valsez[$z]=0; $valsez[$z]=$sevalidi; $voticompl+=$voti; } if ($voticompl) { $res_voti = $dbi->prepare("$sqlvoti"); $res_voti->execute(); } $piuvot=0; if ($visvot!='cand') $piuvot=5; for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[0][$y]=" "; if (strstr( $op,'circo')) $sql="select num_circ from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' and num_circ>='$minsez' and num_circ<='$offsetsez' order by num_circ"; else $sql="select num_sez from ".$prefix."_ele_sezioni where id_cons='$id_cons' and num_sez>='$minsez' and num_sez<='$offsetsez' order by num_sez"; $lis_sez = $dbi->prepare("$sql"); $lis_sez->execute(); $nsezsel=$lis_sez->rowCount(); while(list($z)=$lis_sez->fetch(PDO::FETCH_NUM)) { for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[$z][$y]=" ";} //inizializza le celle interne ################################################################### # for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[0][$y]=" "; # for ($z=1;$z<=($offsetsez-$ominsez);$z++) # for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[$z][$y]=" "; //inizializza le celle interne $onetime=""; if ($res_voti) { while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){ $z=array_search($num_circ, $pos); $valar[($z)][$num_cand]=$voti; } foreach ($valar as $key=>$val){ if(isset($votitot[($key)])) $percar[$key]=arrayperc($val,$votitot[($key)]); } # if($res_voti->rowCount()) { $res_voti = $dbi->prepare("$sqlvoti"); $res_voti->execute(); #} while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){ if($num_cand<$min or $num_cand>$offset) continue; if($genere==4) $sevalidi=$voti; if (!isset($temp[$num_cand])) $temp[$num_cand]=0; $temp[$num_cand]+=$voti; $z=array_search($num_circ, $pos); if (!$z) continue; if ($num_cand>=$min and $num_cand<=$offset){ if($num_circ>=$minpos and $num_circ <=$maxpos){ $ar[0][$num_cand]=$num_cand.") ".$nome; if ($desc_circ && $onetime!=$desc_circ) {$ar[($z)][0].=") ".$desc_circ; $onetime=$desc_circ;} $percento=$voti; if ($perc=='true' and $votitot[($z)]) { $percento=$voti."
".number_format($percar[$z][$num_cand],2)." %"; } $ar[($z)][$num_cand]=$percento; } } if (!strstr( $op,'candidato')){ if (!isset($tempar[$num_cand])) $tempar[$num_cand]=0; $tempar[$num_cand]+=$voti; } if ($visvot!='cand'){ $posvoti=($offset); $ar[0][$posvoti+1]='Voti Validi'; $ar[0][$posvoti+2]='Schede Nulle'; $ar[0][$posvoti+3]='Schede Bianche'; $ar[0][$posvoti+4]='Voti Contestati'; $ar[0][$posvoti+5]='Voti Nulli'; if (($maxpos)>=$num_circ and $minpos<=$num_circ){ //$posvoti++; $ar[($z)][$posvoti+1]="$valsez[$z]"; $ar[($z)][$posvoti+2]="$senulli"; $ar[($z)][$posvoti+3]="$sebianchi"; $ar[($z)][$posvoti+4]="$secontestati"; $ar[($z)][$posvoti+5]="$sevonulli"; } } } } if (($offsetsez+1)>=$num_sez){ $ar[(1+$numsezmax)][0]=""._TOT."
"._COMPLESSIVO."
"; if(isset($temp)) { if (!isset($tab15) or !$tab15) $tab15="candidati"; if($tab15=="gruppo" or $genere==4){ $votigl=" sum(validi),sum(nulli),sum(bianchi),sum(contestati),sum(voti_nulli)"; }elseif($votog){ $votigl=" sum(validi),sum(nulli),sum(bianchi),sum(contestati),sum(voti_nulli)"; }else{ if($dettnulli) $votigl=" sum(validi_lista),sum(nulli),sum(bianchi),sum(contestati_lista),sum(voti_nulli_lista+voti_nulli)"; else $votigl=" sum(validi_lista),sum(nulli),sum(bianchi),sum(contestati_lista),sum(voti_nulli)"; } if($circo) $sql="SELECT $votigl from ".$prefix."_ele_sezioni AS t1 LEFT JOIN soraldo_ele_sede AS t2 ON t1.id_sede = t2.id_sede WHERE t1.id_cons='$id_cons' and t2.id_circ=$id_circ"; else $sql="SELECT $votigl from ".$prefix."_ele_sezioni as t1 where t1.id_cons='$id_cons' and t1.id_sez=(select t2.id_sez from ".$prefix."_ele_voti_$tab15 as t2 where t2.id_sez=t1.id_sez group by t2.id_sez)"; $resv = $dbi->prepare("$sql"); $resv->execute(); list ($sevaltot,$senultot,$sebiatot,$secontot,$sevnutot)= $resv->fetch(PDO::FETCH_NUM); $voticompl=$sevaltot+$senultot+$sebiatot+$secontot+$sevnutot; $sql="SELECT voti from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons'"; $resvt = $dbi->prepare("$sql"); $resvt->execute(); if($resvt) list($votlt)=$resvt->fetch(PDO::FETCH_NUM); else $votlt=0; if($perc) $temp3=arrayperc($temp,$sevaltot); while (list($key,$voti)= each($temp)) { if ($perc=='true' and $voticompl) { $percento="$voti
".$temp3[$key]." %
"; } else $percento="$voti"; $ar[1+$numsezmax][$key]=$percento; } } if ($visvot!='cand') { $key=$offset+1; $tmp=array($sevaltot,$senultot,$sebiatot,$secontot,$sevnutot); if($perc) $temp3=arrayperc($tmp,$voticompl); while(list($k,$voti)= each($tmp)) { if ($perc=='true' and $voticompl) { $percento="$voti
".$temp3[$k]." %
"; } else $percento="$voti"; $ar[1+$numsezmax][++$key]=$percento; } } } if($orvert!=1) { $i=0; foreach ( $ar as $riga) { $y=0; foreach($riga as $cella) { $ra[$y++][$i]=$cella; } $i++; } crea_tabella($ra); }else{ crea_tabella($ar); } //e' un referendum }else{ $sql="SELECT id_gruppo, descrizione,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons order by num_gruppo"; $res_lis = $dbi->prepare("$sql"); $res_lis->execute(); if($res_lis) $numliste=$res_lis->rowCount(); else $numliste=0; if (!isset($offset)) $offset=10; if (!isset($min)) $min=1; if (!isset($offsetsez)) $offsetsez=25; //lo 0 viene sostituito dal totale di sezioni presenti if (!isset($minsez)) $minsez=1; if (!$csv){ echo "
$pagina
"; echo "
"; echo "
"; echo ""; echo ""; echo ""; echo ""._SCELTA." "._CONSULTAZIONE.": "; echo "
"._VIS_PERC.": "; echo "
"; } $sql="select num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id_gruppo"; $res_ref = $dbi->prepare("$sql"); $res_ref ->execute(); $sql="select $tab2, t1.num_gruppo, t1.descrizione , t1.simbolo, sum(t2.si), sum(t2.no),sum(t2.validi), sum(t2.nulli),sum(t2.bianchi), sum(t2.contestati) from ".$prefix."_ele_gruppo as t1 left join ".$prefix."_ele_voti_ref as t2 on (t1.id_gruppo=t2.id_gruppo) left join ".$prefix."_ele_sezioni as t3 on (t2.id_sez=t3.id_sez) left join ".$prefix."_ele_sede as t4 on (t3.id_sede=t4.id_sede) left join ".$prefix."_ele_circoscrizione as t5 on (t4.id_circ=t5.id_circ) where t1.id_cons='$id_cons' and t1.id_gruppo=$id_gruppo group by t2.id_gruppo,$tab3 order by $tab3, t1.num_gruppo "; $res = $dbi->prepare("$sql"); $res->execute(); if($res) $num_sez=$res->rowCount(); else $num_sez=0; if($res_ref) list($num_gruppo,$descr)= $res_ref->fetch(PDO::FETCH_NUM); else {$num_gruppo=0;$descr='';} if (!$csv){ # stampa $datipdf=""._COMUNE." $descr_comune - "._RISULTATI.": $descr_cons
$pagina

"; $datipdf .="
Referendum n. ".$num_gruppo."
".$descr.""; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
"._ESPORTA."
"; echo "\"Stampa\""; echo "\"Export"; //echo "\"Export"; echo "\"Export"; echo "
"; echo ""; echo "  L  P  
"; echo "  A3A4"; echo "
"; echo "
"; // numero sezioni scrutinate $sql="select t3.* from ".$prefix."_ele_voti_ref 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' group by t3.id_sez "; $res4 = $dbi->prepare("$sql"); $res4->execute(); $numero=$res4->rowCount(); $sql="select t1.* from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t1.id_cons='$id_cons' "; $res5 = $dbi->prepare("$sql"); $res5->execute(); $sezioni=$res5->rowCount(); if ($numero!=0) echo "
"._SEZSCRU." $numero "._SU." $sezioni
"; } $sql="select count(0) from ".$prefix."_ele_sezioni where id_cons='$id_cons'"; $res5 = $dbi->prepare("$sql"); $res5->execute(); list($num_sez) = $res5->fetch(PDO::FETCH_NUM); if (!$csv)echo "Referendum n. ".$num_gruppo."
".$descr.""; $y=1; $ar[0][0]=$tipo2; $ar[0][1]=_SI; $ar[0][2]=_NO; $ar[0][3]=_VALIDI; $ar[0][4]=_NULLI; $ar[0][5]=_BIANCHI; $ar[0][6]=_CONTESTATI; if($res_ref) while (list($num_gruppo,$desc_ref) = $res_ref->fetch(PDO::FETCH_NUM)){ $ar[0][$i++]= $num_gruppo.") ".$desc_ref; $ar[1][$y++]= "SI"; $ar[1][$y++]= "NO"; } $num_sez++; $tot_si=0; $tot_no=0; $tot_va=0; $tot_nu=0; $tot_bi=0; $tot_co=0; if($res) while (list($num_circ,$desc_circ,$num_gruppo,$desc_ref,$simbolo,$si,$no,$validi,$nulli,$bianchi, $contestati) = $res->fetch(PDO::FETCH_NUM)){ $i=1; $votanti=$validi+$nulli+$bianchi+$contestati; $tot_si+=$si; $tot_no+=$no; $tot_va+=$validi; $tot_nu+=$nulli; $tot_bi+=$bianchi; $tot_co+=$contestati; $ar[$num_circ][0]=$num_circ."
".$desc_circ; if($validi){ $ar[$num_circ][$i++]= $perc=='true' ? $si."
".number_format($si*100/$validi,2)."%":$si; $ar[$num_circ][$i++]= $perc=='true' ? $no."
".number_format($no*100/$validi,2)."%":$no; }else{ $ar[$num_circ][$i++]= $perc=='true' ? $si."
0.00%":$si; $ar[$num_circ][$i++]= $perc=='true' ? $no."
0.00%":$no; } if($votanti){ $ar[$num_circ][$i++]= $perc=='true' ? $validi."
".number_format($validi*100/$votanti,2)."%":$validi; $ar[$num_circ][$i++]= $perc=='true' ? $nulli."
".number_format($nulli*100/$votanti,2)."%":$nulli; $ar[$num_circ][$i++]= $perc=='true' ? $bianchi."
".number_format($bianchi*100/$votanti,2)."%":$bianchi; $ar[$num_circ][$i++]= $perc=='true' ? $contestati."
".number_format($contestati*100/$votanti,2)."%":$contestati; }else{ $ar[$num_circ][$i++]= $perc=='true' ? $validi."
0.00%":$validi; $ar[$num_circ][$i++]= $perc=='true' ? $nulli."
0.00%":$nulli; $ar[$num_circ][$i++]= $perc=='true' ? $bianchi."
0.00%":$bianchi; $ar[$num_circ][$i++]= $perc=='true' ? $contestati."
0.00%":$contestati; } } $i=1; $tot_vo=$tot_va+$tot_nu+$tot_bi+$tot_co; # if($tot_va==0) $tot_va=1; # if($tot_vo==0) $tot_vo=1; $ar[$num_sez][0]=_TOT."
"._COMPLESSIVO; if($tot_va){ $ar[$num_sez][$i++]= $perc=='true' ? $tot_si."
".number_format($tot_si*100/$tot_va,2)."%":$tot_si; $ar[$num_sez][$i++]= $perc=='true' ? $tot_no."
".number_format($tot_no*100/$tot_va,2)."%":$tot_no; }else{ $ar[$num_sez][$i++]= $perc=='true' ? $tot_si."
0.00%":$tot_si; $ar[$num_sez][$i++]= $perc=='true' ? $tot_no."
0.00%":$tot_no; } if($tot_vo){ $ar[$num_sez][$i++]= $perc=='true' ? $tot_va."
".number_format($tot_va*100/$tot_vo,2)."%":$tot_va; $ar[$num_sez][$i++]= $perc=='true' ? $tot_nu."
".number_format($tot_nu*100/$tot_vo,2)."%":$tot_nu; $ar[$num_sez][$i++]= $perc=='true' ? $tot_bi."
".number_format($tot_bi*100/$tot_vo,2)."%":$tot_bi; $ar[$num_sez][$i++]= $perc=='true' ? $tot_co."
".number_format($tot_co*100/$tot_vo,2)."%":$tot_co; }else{ $ar[$num_sez][$i++]= $perc=='true' ? $tot_va."
0.00%":$tot_va; $ar[$num_sez][$i++]= $perc=='true' ? $tot_nu."
0.00%":$tot_nu; $ar[$num_sez][$i++]= $perc=='true' ? $tot_bi."
0.00%":$tot_bi; $ar[$num_sez][$i++]= $perc=='true' ? $tot_co."
0.00%":$tot_co; } crea_tabella($ar); } if ($csv) echo "\n"; } ?>