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 | /* widget pie google affluenze
|
---|
9 | by luc 25 giugno 2009 */
|
---|
10 |
|
---|
11 | if (!defined('MODULE_FILE')) {
|
---|
12 | die ("You can't access this file dirrectly...");
|
---|
13 | }
|
---|
14 |
|
---|
15 |
|
---|
16 |
|
---|
17 | global $circo,$prefix,$dbi,$id_cons,$genere,$id_circ,$id_comune,$id_cons_gen;
|
---|
18 |
|
---|
19 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
20 | else $circos='';
|
---|
21 | // numero sezioni scrutinate
|
---|
22 |
|
---|
23 | $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";
|
---|
24 | $res2 = $dbi->prepare("$sql");
|
---|
25 | $res2->execute();
|
---|
26 |
|
---|
27 | $sezioni=$res2->fetch(PDO::FETCH_NUM);
|
---|
28 |
|
---|
29 | $sql="select orario,data from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' order by data desc,orario desc limit 1";
|
---|
30 | $res = $dbi->prepare("$sql");
|
---|
31 | $res->execute();
|
---|
32 |
|
---|
33 | if($res){
|
---|
34 |
|
---|
35 | while(list($orario,$data) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
36 | list ($ore,$minuti,$secondi)=explode(':',$orario);
|
---|
37 | list ($anno,$mese,$giorno)=explode('-',$data);
|
---|
38 | $tot_v_m=0;$tot_v_d=0;$tot_t=0;
|
---|
39 |
|
---|
40 |
|
---|
41 | $sql="select t3.id_sez 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' and t3.data='$data' and t3.orario='$orario' $circos group by t3.id_sez ";
|
---|
42 | $res1 = $dbi->prepare("$sql");
|
---|
43 | $res1->execute();
|
---|
44 |
|
---|
45 | $numero=$res1->rowCount();
|
---|
46 |
|
---|
47 | echo "<h5>Ultime Affluenze</h5>";
|
---|
48 | echo "<div style=\"text-align:center;color:#ff0000\">"._PERC_TEND."<br><b>"._ORE." $ore,$minuti "._DEL." $giorno/$mese/$anno</b></div>";
|
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 | # $res1 = mysql_query("select sum(t1.voti_complessivi), t2.num_gruppo , t2.id_gruppo from ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2 on (t1.id_gruppo=t2.id_gruppo) where t1.id_cons='$id_cons' and t1.orario='$orario' and t1.data='$data' group by t2.num_gruppo,t2.id_gruppo order by t2.num_gruppo " , $dbi);
|
---|
54 | #modifica del 26giugno 09 per gestione circoscrizionali
|
---|
55 | if($genere==0) { $sql="select sum(t1.voti_complessivi), t2.num_gruppo , t2.id_gruppo from ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2 on (t1.id_gruppo=t2.id_gruppo) where t1.id_cons='$id_cons' and t1.orario='$orario' and t1.data='$data' group by t2.num_gruppo,t2.id_gruppo order by t2.num_gruppo " ;
|
---|
56 | $res1 = $dbi->prepare("$sql");
|
---|
57 | $res1->execute();
|
---|
58 |
|
---|
59 | }else{
|
---|
60 | $sql="select sum(t3.voti_complessivi),0,0 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' and t3.data='$data' and t3.orario='$orario' $circos";
|
---|
61 | $res1 = $dbi->prepare("$sql");
|
---|
62 | $res1->execute();
|
---|
63 | }
|
---|
64 | #fine modifica
|
---|
65 |
|
---|
66 |
|
---|
67 |
|
---|
68 |
|
---|
69 |
|
---|
70 | while(list($voti_t, $num_gruppo,$id_gruppo) = $res1->fetch(PDO::FETCH_NUM)) {
|
---|
71 |
|
---|
72 | $sql="select sum(t3.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' and t3.data='$data' and t3.orario='$orario' $circos";
|
---|
73 | if ($genere==0){$query.=" and t3.id_gruppo=$id_gruppo";}
|
---|
74 | $res_aff = $dbi->prepare("$sql");
|
---|
75 | $res_aff->execute();
|
---|
76 |
|
---|
77 | $voti_numero=$res_aff->rowCount();
|
---|
78 |
|
---|
79 | $sql="select sum(t1.maschi+t1.femmine) 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' and t3.data='$data' and t3.orario='$orario' $circos";
|
---|
80 |
|
---|
81 | if ($genere==0){$query.=" and id_gruppo=$id_gruppo";}
|
---|
82 | $res1234 = $dbi->prepare("$sql");
|
---|
83 | $res1234->execute();
|
---|
84 |
|
---|
85 | list($tot)=$res1234->fetch(PDO::FETCH_NUM);
|
---|
86 | if ($tot)
|
---|
87 | $perc=number_format($voti_t*100/$tot,2);
|
---|
88 | else {$tot=0;$perc="0.00";}
|
---|
89 |
|
---|
90 | $resto=100-$perc;
|
---|
91 | if ($genere==0){echo "<div style=\"text-align:center\">referendum n. $num_gruppo</div";}
|
---|
92 |
|
---|
93 | echo "<center><img src=\"http://chart.apis.google.com/chart?
|
---|
94 | chs=200x70
|
---|
95 | &chd=t:$resto,$perc
|
---|
96 | &cht=p3
|
---|
97 | &chl=|$perc%
|
---|
98 | &chco=ff0000,ffff00 \"
|
---|
99 | alt=\"Sample chart\" />
|
---|
100 | <a href=\"modules.php?id_cons_gen=$id_cons_gen&name=Elezioni&id_comune=$id_comune&file=index&op=affluenze_graf\">Tutte le affluenze</a>
|
---|
101 | </center>";
|
---|
102 |
|
---|
103 |
|
---|
104 |
|
---|
105 | }
|
---|
106 |
|
---|
107 | }
|
---|
108 | }
|
---|
109 | ?>
|
---|