[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 | 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;
|
---|
[354] | 18 | $query='';
|
---|
[2] | 19 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
| 20 | else $circos='';
|
---|
| 21 | // numero sezioni scrutinate
|
---|
| 22 |
|
---|
[394] | 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";
|
---|
[265] | 24 | $res2 = $dbi->prepare("$sql");
|
---|
| 25 | $res2->execute();
|
---|
[394] | 26 | $numsez=$res2->rowCount();
|
---|
| 27 | $sezioni=$res2->fetch(PDO::FETCH_NUM);
|
---|
[2] | 28 |
|
---|
[265] | 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 |
|
---|
[2] | 33 | if($res){
|
---|
| 34 |
|
---|
[265] | 35 | while(list($orario,$data) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
[2] | 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;
|
---|
[394] | 39 | $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 ";
|
---|
| 40 | $res1 = $dbi->prepare("$sql");
|
---|
| 41 | $res1->execute();
|
---|
| 42 | $numero=$res1->rowCount();
|
---|
| 43 | echo "<h5>Ultime Affluenze</h5>";
|
---|
| 44 | if($numero==$numsez)
|
---|
| 45 | echo "<div style=\"text-align:center;color:#ff0000\">"._PERC."<br><b>"._ORE." $ore,$minuti "._DEL." $giorno/$mese/$anno</b></div>";
|
---|
| 46 | else
|
---|
| 47 | echo "<div style=\"text-align:center;color:#ff0000\">"._PERC_TEND."<br><b>"._ORE." $ore,$minuti "._DEL." $giorno/$mese/$anno</b></div>";
|
---|
[2] | 48 |
|
---|
| 49 | # $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);
|
---|
| 50 | #modifica del 26giugno 09 per gestione circoscrizionali
|
---|
[394] | 51 | if($genere==0)
|
---|
| 52 | {
|
---|
| 53 | $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 " ;
|
---|
| 54 | $res1 = $dbi->prepare("$sql");
|
---|
| 55 | $res1->execute();
|
---|
[265] | 56 |
|
---|
[394] | 57 | }else{
|
---|
| 58 | $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";
|
---|
| 59 | $res1 = $dbi->prepare("$sql");
|
---|
| 60 | $res1->execute();
|
---|
| 61 | }
|
---|
[2] | 62 | #fine modifica
|
---|
[394] | 63 |
|
---|
| 64 | while(list($voti_t, $num_gruppo,$id_gruppo) = $res1->fetch(PDO::FETCH_NUM)) {
|
---|
[2] | 65 |
|
---|
[394] | 66 | $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";
|
---|
| 67 | if ($genere==0){$query.=" and t3.id_gruppo=$id_gruppo";}
|
---|
| 68 | $res_aff = $dbi->prepare("$sql");
|
---|
| 69 | $res_aff->execute();
|
---|
[265] | 70 |
|
---|
[394] | 71 | $voti_numero=$res_aff->rowCount();
|
---|
| 72 |
|
---|
| 73 | $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";
|
---|
| 74 |
|
---|
| 75 | if ($genere==0){$query.=" and id_gruppo=$id_gruppo";}
|
---|
| 76 | $res1234 = $dbi->prepare("$sql");
|
---|
| 77 | $res1234->execute();
|
---|
[265] | 78 |
|
---|
[394] | 79 | list($tot)=$res1234->fetch(PDO::FETCH_NUM);
|
---|
| 80 | if ($tot) $perc=number_format($voti_t*100/$tot,2);
|
---|
| 81 | else {$tot=0;$perc="0.00";}
|
---|
| 82 |
|
---|
| 83 | $resto=100-$perc;
|
---|
| 84 | if ($genere==0){echo "<div style=\"text-align:center\">referendum n. $num_gruppo</div";}
|
---|
[412] | 85 | echo '<center>
|
---|
| 86 | <div id="piechart" style="width:100%; min-height:200px;"></div><br/>
|
---|
| 87 | <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>
|
---|
| 88 | </center>
|
---|
| 89 | <script>google.charts.load("current", {"packages":["corechart"]});
|
---|
| 90 | google.charts.setOnLoadCallback(drawChart);
|
---|
| 91 |
|
---|
| 92 | function drawChart() {
|
---|
| 93 | var data = google.visualization.arrayToDataTable([
|
---|
| 94 | ["Task", "Affluenze"],
|
---|
| 95 | ["", '.$resto.'],
|
---|
| 96 | ["'.$perc.'%", '.$perc.']
|
---|
| 97 | ]);
|
---|
| 98 | var options = {
|
---|
| 99 | title: "",
|
---|
| 100 | is3D:true,
|
---|
| 101 | legend: "none",
|
---|
| 102 | pieSliceText: "label",
|
---|
| 103 | pieSliceTextStyle: {
|
---|
| 104 | color: "#000",
|
---|
| 105 | bold:true,
|
---|
| 106 | fontSize:12
|
---|
| 107 | },
|
---|
| 108 | slices: {
|
---|
| 109 | 0: { color: "#ff0000", textStyle:{color:"#fff"}},
|
---|
| 110 | 1: { color: "#ffff00" }
|
---|
| 111 | }
|
---|
| 112 | };
|
---|
| 113 | var chart = new google.visualization.PieChart(document.getElementById("piechart"));
|
---|
[2] | 114 |
|
---|
[412] | 115 | chart.draw(data, options);
|
---|
| 116 | }</script>';
|
---|
[394] | 117 | }
|
---|
[2] | 118 |
|
---|
[394] | 119 | }
|
---|
| 120 | }
|
---|
[2] | 121 | ?>
|
---|