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 ($genere==0) $tab="ref";elseif($genere=='4' || $votog) $tab="lista";
|
---|
16 | else $tab="gruppo";
|
---|
17 |
|
---|
18 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
19 | else $circos='';
|
---|
20 |
|
---|
21 | #$res = mysql_query("select * from ".$prefix."_ele_voti_".$tab." where id_cons='$id_cons' group by id_sez ",$dbi);
|
---|
22 | # $numero=mysql_num_rows($res);
|
---|
23 | # $res = mysql_query("select * from ".$prefix."_ele_sezioni where id_cons='$id_cons'",$dbi);
|
---|
24 | $sql="select t3.id_sez 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 ";
|
---|
25 | $res = $dbi->prepare("$sql");
|
---|
26 | $res->execute();
|
---|
27 |
|
---|
28 | $numero=$res->rowCount();
|
---|
29 | $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' $circos";
|
---|
30 | $res = $dbi->prepare("$sql");
|
---|
31 | $res->execute();
|
---|
32 |
|
---|
33 | $sezioni=$res->rowCount();
|
---|
34 |
|
---|
35 | if ($numero!=0){
|
---|
36 |
|
---|
37 |
|
---|
38 | echo "<h5><b>"._DETTAGLIO." "._VOTIE."</b> - </h5>";
|
---|
39 | echo "<div style=\"text-align:center;\"><i> "._SEZSCRU." $numero "._SU." $sezioni </i></div>";
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 |
|
---|
44 | $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' $circos";
|
---|
45 | $res1 = $dbi->prepare("$sql");
|
---|
46 | $res1->execute();
|
---|
47 |
|
---|
48 | list($tot_aventi) = $res1->fetch(PDO::FETCH_NUM);
|
---|
49 | if ($genere!=0) {
|
---|
50 |
|
---|
51 | $sql="SELECT sum(t1.validi+t1.nulli+t1.bianchi+t1.contestati) as tot,
|
---|
52 | sum(t1.validi),sum(t1.nulli),sum(t1.bianchi),sum(t1.contestati), '0'
|
---|
53 | 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 having tot>0";
|
---|
54 | $res1 = $dbi->prepare("$sql");
|
---|
55 | $res1->execute();
|
---|
56 |
|
---|
57 | }else{
|
---|
58 | $sql="SELECT sum(validi+nulli+bianchi+contestati) as tot,
|
---|
59 | sum(validi),sum(nulli),sum(bianchi),sum(contestati), id_gruppo
|
---|
60 | from ".$prefix."_ele_voti_ref where id_cons=$id_cons group by id_gruppo having tot>0";
|
---|
61 | $res1 = $dbi->prepare("$sql");
|
---|
62 | $res1->execute();
|
---|
63 |
|
---|
64 | }
|
---|
65 |
|
---|
66 | while (list($tot_votanti,$validi,$nulli,$bianchi,$contestati,$id) = $res1->fetch(PDO::FETCH_NUM)){
|
---|
67 | $tot_votanti=$validi+$bianchi+$nulli+$contestati;
|
---|
68 | $perc_validi=number_format($validi*100/$tot_votanti,2);
|
---|
69 | $perc_nulli=number_format($nulli*100/$tot_votanti,2);
|
---|
70 | $perc_bianchi=number_format($bianchi*100/$tot_votanti,2);
|
---|
71 | $perc_conte=number_format($contestati*100/$tot_votanti,2);
|
---|
72 | $perc_votanti=number_format($tot_votanti*100/$tot_aventi,2);
|
---|
73 | $non_votanti=($tot_aventi - $tot_votanti);
|
---|
74 | $perc_non=100-$perc_votanti;
|
---|
75 |
|
---|
76 | if ($genere==0) {
|
---|
77 | $sql="SELECT num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id";
|
---|
78 | $res = $dbi->prepare("$sql");
|
---|
79 | $res->execute();
|
---|
80 |
|
---|
81 | list($num_gruppo,$descr_gruppo) = $res->fetch(PDO::FETCH_NUM);
|
---|
82 | }
|
---|
83 |
|
---|
84 |
|
---|
85 |
|
---|
86 | echo "<table style=\"width=100%;border-collapse: collapse;background-color:gray\" class=\"modulo\">";
|
---|
87 | if ($genere==0) {echo "<br/>Referendum n. <b>[$num_gruppo]</b><br/>";}
|
---|
88 | echo "
|
---|
89 | <tr bgcolor=\"#ffffff\"><td style=\"padding: 1px;\"><b>"._AVENTI."</b></td><td>$tot_aventi</td><td><span class=\"red\">100%</span></td></tr>
|
---|
90 |
|
---|
91 | <tr bgcolor=\"#ffffff\"><td style=\"padding: 1px;\"><b>"._VOTANTI."</b></td><td>$tot_votanti</td><td><span class=\"red\">$perc_votanti%</span></td></tr>
|
---|
92 |
|
---|
93 | <tr bgcolor=\"#ffffff\"><td style=\"padding: 1px;\">"._VALIDI."</td><td>$validi</td><td><span class=\"red\">$perc_validi%</span></td></tr>
|
---|
94 |
|
---|
95 | <tr bgcolor=\"#ffffff\"><td style=\"padding: 1px;\">"._NULLI."</td><td>$nulli</td><td><span class=\"red\">$perc_nulli%</span></td></tr>
|
---|
96 |
|
---|
97 | <tr bgcolor=\"#ffffff\"><td style=\"padding: 1px;\">"._BIANCHI."</td><td>$bianchi</td><td><span class=\"red\">$perc_bianchi%</span></td></tr>
|
---|
98 |
|
---|
99 | <tr bgcolor=\"#ffffff\"><td style=\"padding: 1px;\">"._CONTESTATI."</td><td>$contestati</td><td><span class=\"red\">$perc_conte%</span></td></tr>
|
---|
100 |
|
---|
101 | </table>";
|
---|
102 |
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 |
|
---|
107 |
|
---|
108 |
|
---|
109 |
|
---|
110 |
|
---|
111 |
|
---|
112 | ?>
|
---|