[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 | /* widget pie google affluenze
|
---|
| 9 | by luc 25 giugno 2009 */
|
---|
| 10 |
|
---|
| 11 | global $circo,$prefix,$dbi,$id_cons,$genere,$id_circ,$id_comune,$id_cons_gen;
|
---|
| 12 |
|
---|
| 13 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 14 | else $circos='';
|
---|
| 15 | // numero sezioni scrutinate
|
---|
| 16 |
|
---|
[265] | 17 | $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";
|
---|
| 18 | $res2 = $dbi->prepare("$sql");
|
---|
| 19 | $res2->execute();
|
---|
[2] | 20 |
|
---|
[265] | 21 | $sezioni=$res2->fetch(PDO::FETCH_NUM);
|
---|
[2] | 22 |
|
---|
[273] | 23 | $sql="select orario,data from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' order by data desc,orario desc limit 1";
|
---|
[265] | 24 | $res = $dbi->prepare("$sql");
|
---|
| 25 | $res->execute();
|
---|
[273] | 26 | if($res->rowCount()){
|
---|
[265] | 27 |
|
---|
| 28 | while(list($orario,$data) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
[2] | 29 | list ($ore,$minuti,$secondi)=explode(':',$orario);
|
---|
| 30 | list ($anno,$mese,$giorno)=explode('-',$data);
|
---|
| 31 | $tot_v_m=0;$tot_v_d=0;$tot_t=0;
|
---|
| 32 |
|
---|
| 33 |
|
---|
[279] | 34 | $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 ";
|
---|
[276] | 35 | $res1 = $dbi->prepare("$sql");
|
---|
| 36 | $res1->execute();
|
---|
[265] | 37 |
|
---|
| 38 | $numero=$res1->rowCount();
|
---|
[2] | 39 |
|
---|
| 40 | echo "<h5>Ultime Affluenze</h5>";
|
---|
[116] | 41 | echo "<div style=\"text-align:center;color:#ff0000\">"._PERC_TEND."<br><b>"._ORE." $ore,$minuti "._DEL." $giorno/$mese/$anno</b></div>";
|
---|
[2] | 42 |
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 |
|
---|
| 46 | # $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);
|
---|
| 47 | #modifica del 26giugno 09 per gestione circoscrizionali
|
---|
[265] | 48 | if($genere==0)
|
---|
| 49 | $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 ";
|
---|
[2] | 50 | else
|
---|
[265] | 51 | $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";
|
---|
[273] | 52 | $res1 = $dbi->prepare("$sql");
|
---|
| 53 | $res1->execute();
|
---|
[265] | 54 |
|
---|
[2] | 55 | #fine modifica
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 |
|
---|
[265] | 60 | while(list($voti_t, $num_gruppo,$id_gruppo) = $res1->fetch(PDO::FETCH_NUM)) {
|
---|
[2] | 61 |
|
---|
[265] | 62 | $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";
|
---|
| 63 | if ($genere==0){$sql.=" and t3.id_gruppo=$id_gruppo";}
|
---|
| 64 | $res_aff = $dbi->prepare("$sql");
|
---|
| 65 | $res_aff->execute();
|
---|
| 66 | $voti_numero=$res_aff->rowCount();
|
---|
[2] | 67 |
|
---|
[265] | 68 | $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";
|
---|
[2] | 69 |
|
---|
[265] | 70 | if ($genere==0){$sql.=" and id_gruppo=$id_gruppo";}
|
---|
| 71 | $res1234 = $dbi->prepare("$sql");
|
---|
| 72 | $res1234->execute();
|
---|
| 73 | list($tot)=$res1234->fetch(PDO::FETCH_NUM);
|
---|
[2] | 74 | if ($tot)
|
---|
| 75 | $perc=number_format($voti_t*100/$tot,2);
|
---|
| 76 | else {$tot=0;$perc="0.00";}
|
---|
| 77 |
|
---|
| 78 | $resto=100-$perc;
|
---|
| 79 | if ($genere==0){echo "<div style=\"text-align:center\">referendum n. $num_gruppo</div";}
|
---|
| 80 |
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 |
|
---|
| 84 | echo "<center><img src=\"http://chart.apis.google.com/chart?
|
---|
| 85 | chs=160x160
|
---|
| 86 | &cht=bvs
|
---|
| 87 | &chd=t:0,$perc,0
|
---|
| 88 | &chxt=y
|
---|
| 89 | &chco=
|
---|
| 90 | &chl=|$perc% |\"
|
---|
| 91 |
|
---|
| 92 | alt=\"Sample chart\" />
|
---|
| 93 |
|
---|
| 94 | <br/><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>
|
---|
| 95 | </center>";
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | }
|
---|
| 101 | }
|
---|
| 102 | ?>
|
---|