[2] | 1 | <?php
|
---|
| 2 | /************************************************************************/
|
---|
| 3 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
| 4 | /* by Roberto Gigli & Luciano Apolito */
|
---|
| 5 | /* http://www.eleonline.it */
|
---|
| 6 | /* info@eleonline.it luciano@aniene.net rgigli@libero.it */
|
---|
| 7 | /************************************************************************/
|
---|
| 8 |
|
---|
| 9 | if (!defined('MODULE_FILE')) {
|
---|
| 10 | die ("You can't access this file dirrectly...");
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | global $op, $prefix, $dbi, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$tipo_cons,$id_comune,$id_cons_gen,$id_circ,$csv,$w,$l,$siteistat,$flash,$tour;
|
---|
| 14 |
|
---|
| 15 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 16 | else $circos='';
|
---|
| 17 |
|
---|
| 18 | if($genere=='4' || $votog) $tab="lista";
|
---|
| 19 | else $tab="gruppo";
|
---|
| 20 | if ($genere==0) $tab="ref";
|
---|
| 21 |
|
---|
| 22 |
|
---|
[138] | 23 | if ($genere!=0) { // referendum
|
---|
[2] | 24 |
|
---|
[265] | 25 | $sql="select sum(t1.maschi+t1.femmine) 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' and validi>0 $circos";
|
---|
| 26 | $res = $dbi->prepare("$sql");
|
---|
| 27 | $res->execute();
|
---|
[2] | 28 |
|
---|
[265] | 29 | list($tot_aventi) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 30 |
|
---|
[389] | 31 | $sql="select sum(t1.validi+t1.nulli+t1.bianchi+t1.contestati+t1.voti_nulli) as tot,
|
---|
| 32 | sum(t1.validi),sum(t1.nulli+t1.voti_nulli),sum(t1.bianchi),sum(t1.contestati), '0', '0', '0'
|
---|
[265] | 33 | 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' and validi>0 $circos";
|
---|
| 34 | $res = $dbi->prepare("$sql");
|
---|
| 35 | $res->execute();
|
---|
[2] | 36 |
|
---|
[265] | 37 |
|
---|
[2] | 38 | }else{
|
---|
[138] | 39 |
|
---|
| 40 |
|
---|
| 41 |
|
---|
[265] | 42 | $sql="SELECT sum(maschi+femmine) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'";
|
---|
| 43 | $res = $dbi->prepare("$sql");
|
---|
| 44 | $res->execute();
|
---|
| 45 |
|
---|
| 46 | list($tot_aventi) = $res->fetch(PDO::FETCH_NUM);
|
---|
[273] | 47 | $sql="SELECT sum(validi+nulli+bianchi+contestati) as tot,
|
---|
[2] | 48 | sum(validi),sum(nulli),sum(bianchi),sum(contestati), id_gruppo, sum(si), sum(no)
|
---|
[265] | 49 | from ".$prefix."_ele_voti_ref where id_cons=$id_cons group by id_gruppo having tot>'0'";
|
---|
| 50 | $res = $dbi->prepare("$sql");
|
---|
| 51 | $res->execute();
|
---|
| 52 |
|
---|
[2] | 53 | }
|
---|
| 54 |
|
---|
[138] | 55 | $i=0;
|
---|
| 56 |
|
---|
[265] | 57 | while (list($tot_votanti,$validi,$nulli,$bianchi,$contestati,$id,$si,$no) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[138] | 58 |
|
---|
[177] | 59 | # calcolo sezioni
|
---|
[265] | 60 | if($genere==0) $sql="select count(0) from ".$prefix."_ele_voti_".$tab." where id_cons='$id_cons' and id_gruppo='$id'";
|
---|
[340] | 61 | else
|
---|
| 62 | if (!$circos) $sql="select count(0) from ".$prefix."_ele_sezioni as t2 where t2.id_cons='$id_cons' and t2.validi+t2.nulli+t2.bianchi+t2.contestati>0 ";
|
---|
| 63 | else $sql="select count(0) from ".$prefix."_ele_sezioni as t2 left join ".$prefix."_ele_sede as t1 on t1.id_sede=t2.id_sede where t1.id_sede in (select id_sede from ".$prefix."_ele_sede where id_circ='$id_circ') and t2.validi+t2.nulli+t2.bianchi+t2.contestati>0 ";
|
---|
[265] | 64 |
|
---|
[273] | 65 | $res_sez = $dbi->prepare("$sql");
|
---|
| 66 | $res_sez->execute();
|
---|
[265] | 67 |
|
---|
[273] | 68 | if($res_sez->rowCount())
|
---|
[265] | 69 | list($numero)=$res_sez->fetch(PDO::FETCH_NUM);
|
---|
[168] | 70 | else
|
---|
| 71 | $numero=0;
|
---|
[279] | 72 | #$sql="select t3.* from ".$prefix."_ele_voti_".$tab." 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.id_sez ";
|
---|
| 73 | # $res_sez = $dbi->prepare("$sql");
|
---|
| 74 | # $res_sez->execute();
|
---|
[138] | 75 |
|
---|
[279] | 76 | $sql="select t1.id_sez 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' $circos";
|
---|
[265] | 77 | $res_sez = $dbi->prepare("$sql");
|
---|
| 78 | $res_sez->execute();
|
---|
| 79 |
|
---|
| 80 | $sezioni=$res_sez->rowCount();
|
---|
| 81 |
|
---|
[2] | 82 | $tot_votanti=$validi+$bianchi+$nulli+$contestati;
|
---|
[73] | 83 | $arvoti=array($validi,$nulli,$bianchi,$contestati);
|
---|
| 84 | $arperc=arrayperc($arvoti,$tot_votanti);
|
---|
[2] | 85 | if($tot_votanti){
|
---|
| 86 | if($genere==0 and $validi) {$perc_si=number_format($si*100/$validi,2);$perc_no=number_format(100 - $si*100/$validi,2);}
|
---|
| 87 | else {$perc_si="0.00"; $perc_no="0.00";}
|
---|
[73] | 88 | $perc_validi=number_format($arperc[0],2);#number_format($validi*100/$tot_votanti,2);
|
---|
| 89 | $perc_nulli=number_format($arperc[1],2);
|
---|
| 90 | $perc_bianchi=number_format($arperc[2],2);
|
---|
| 91 | $perc_conte=number_format($arperc[3],2);
|
---|
[2] | 92 | }else {$perc_validi="0.00";$perc_nulli="0.00";$perc_bianchi="0.00";$perc_conte="0.00";}
|
---|
| 93 | if($tot_aventi)
|
---|
| 94 | $perc_votanti=number_format($tot_votanti*100/$tot_aventi,2);
|
---|
| 95 | else $perc_votanti="0.00";
|
---|
| 96 | $non_votanti=($tot_aventi - $tot_votanti);
|
---|
| 97 | $perc_non=100-$perc_votanti;
|
---|
| 98 |
|
---|
| 99 | if ($genere==0) {
|
---|
[265] | 100 | $sql="SELECT num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id";
|
---|
| 101 | $resg = $dbi->prepare("$sql");
|
---|
| 102 | $resg->execute();
|
---|
| 103 |
|
---|
| 104 | list($num_gruppo,$descr_gruppo) = $resg->fetch(PDO::FETCH_NUM);
|
---|
[2] | 105 | }
|
---|
| 106 |
|
---|
[138] | 107 | $i++;
|
---|
| 108 | if($i==1)echo "<h5><b>"._DETTAGLIO." "._VOTIE."</b></h5>";
|
---|
| 109 | if($i==1)echo "<div style=\"text-align:center;\">[ <i>Percentuali Relative</i> ]</div>";
|
---|
[2] | 110 |
|
---|
[138] | 111 | if ($genere==0) {echo "<br><div style=\"text-align:center;\">Referendum n. <b>[$num_gruppo]</b></div>";}
|
---|
| 112 | echo "<div style=\"text-align:center;\"><i> "._SEZSCRU." $numero "._SU." $sezioni </i></div>";
|
---|
[2] | 113 | echo "<table bgcolor=\"gray\" width=\"100%\" cellspacing=\"1\">";
|
---|
| 114 | echo "
|
---|
[73] | 115 | <tr bgcolor=\"#ffffff\"><td ><b>"._AVENTI."</b></td><td align=\"right\">$tot_aventi</td><td align=\"right\"><span class=\"red\">100.00%</span></td></tr>
|
---|
[2] | 116 |
|
---|
[73] | 117 | <tr bgcolor=\"#ffffff\"><td><b>"._VOTANTI."</b></td><td align=\"right\">$tot_votanti</td><td align=\"right\"><span class=\"red\">$perc_votanti%</span></td></tr>";
|
---|
[2] | 118 | if ($genere==0){
|
---|
[73] | 119 | echo "<tr bgcolor=\"#ffffff\"><td>"._SI."</td><td align=\"right\">$si</td><td align=\"right\"><span class=\"red\">$perc_si%</span></td></tr>
|
---|
[2] | 120 |
|
---|
[73] | 121 | <tr bgcolor=\"#ffffff\"><td>"._NO."</td><td align=\"right\">$no</td><td align=\"right\"><span class=\"red\">$perc_no%</span></td></tr>";
|
---|
[2] | 122 | }
|
---|
[73] | 123 | echo "<tr bgcolor=\"#ffffff\"><td>"._VALIDI."</td><td align=\"right\">$validi</td><td align=\"right\"><span class=\"red\">$perc_validi%</span></td></tr>
|
---|
[2] | 124 |
|
---|
[73] | 125 | <tr bgcolor=\"#ffffff\"><td>"._NULLI."</td><td align=\"right\">$nulli</td><td align=\"right\"><span class=\"red\">$perc_nulli%</span></td></tr>
|
---|
[2] | 126 |
|
---|
[73] | 127 | <tr bgcolor=\"#ffffff\"><td>"._BIANCHI."</td><td align=\"right\">$bianchi</td><td align=\"right\"><span class=\"red\">$perc_bianchi%</span></td></tr>
|
---|
[2] | 128 |
|
---|
[73] | 129 | <tr bgcolor=\"#ffffff\"><td>"._CONTESTATI."</td><td align=\"right\">$contestati</td><td align=\"right\"><span class=\"red\">$perc_conte%</span></td></tr>
|
---|
[2] | 130 |
|
---|
| 131 | </table>";
|
---|
| 132 |
|
---|
[138] | 133 |
|
---|
[2] | 134 | }
|
---|
| 135 |
|
---|
| 136 | ?>
|
---|