[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->rowCount();
|
---|
| 22 |
|
---|
| 23 | $sql="select orario,data from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' order by data desc,orario desc limit 1";
|
---|
| 24 | $res = $dbi->prepare("$sql");
|
---|
| 25 | $res->execute();
|
---|
| 26 |
|
---|
[2] | 27 | if($res){
|
---|
| 28 |
|
---|
[265] | 29 | while(list($orario,$data) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
[2] | 30 | list ($ore,$minuti,$secondi)=explode(':',$orario);
|
---|
| 31 | list ($anno,$mese,$giorno)=explode('-',$data);
|
---|
| 32 | $tot_v_m=0;$tot_v_d=0;$tot_t=0;
|
---|
| 33 |
|
---|
| 34 |
|
---|
[420] | 35 | $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 ";
|
---|
[278] | 36 | $res1 = $dbi->prepare("$sql");
|
---|
| 37 | $res1->execute();
|
---|
[265] | 38 |
|
---|
| 39 | $numero=$res1->rowCount();
|
---|
[2] | 40 |
|
---|
| 41 | echo "<h5>Ultime Affluenze</h5>";
|
---|
[394] | 42 | if($numero=$sezioni)
|
---|
| 43 | echo "<div style=\"text-align:center;color:#ff0000\">"._PERC."<br><b>"._ORE." $ore,$minuti "._DEL." $giorno/$mese/$anno</b></div>";
|
---|
| 44 | else
|
---|
[116] | 45 | echo "<div style=\"text-align:center;color:#ff0000\">"._PERC_TEND."<br><b>"._ORE." $ore,$minuti "._DEL." $giorno/$mese/$anno</b></div>";
|
---|
[2] | 46 |
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 |
|
---|
| 50 | # $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);
|
---|
| 51 | #modifica del 26giugno 09 per gestione circoscrizionali
|
---|
[265] | 52 | if($genere==0)
|
---|
| 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 " ;
|
---|
[2] | 54 | else
|
---|
[265] | 55 | $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";
|
---|
[279] | 56 | $res1 = $dbi->prepare("$sql");
|
---|
| 57 | $res1->execute();
|
---|
[265] | 58 |
|
---|
[2] | 59 | #fine modifica
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 |
|
---|
[265] | 65 | while(list($voti_t, $num_gruppo,$id_gruppo) = $res1->fetch(PDO::FETCH_NUM)) {
|
---|
[2] | 66 |
|
---|
[420] | 67 | $sql="select 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";
|
---|
[399] | 68 | if ($genere==0){$sql.=" and t3.id_gruppo='$id_gruppo'";}
|
---|
[265] | 69 | $res_aff = $dbi->prepare("$sql");
|
---|
| 70 | $res_aff->execute();
|
---|
| 71 |
|
---|
| 72 | $voti_numero=$res_aff->rowCount();
|
---|
[2] | 73 |
|
---|
[420] | 74 | $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";
|
---|
[399] | 75 | if ($genere==0){$sql.=" and id_gruppo='$id_gruppo'";}
|
---|
[265] | 76 | $res1234 = $dbi->prepare("$sql");
|
---|
| 77 | $res1234->execute();
|
---|
[420] | 78 | list($tot)=$res1234->fetch(PDO::FETCH_NUM);
|
---|
| 79 | if ($tot)
|
---|
[2] | 80 | $perc=number_format($voti_t*100/$tot,2);
|
---|
| 81 | else {$tot=0;$perc="0.00";}
|
---|
[420] | 82 | if($voti_t<=$tot){
|
---|
[2] | 83 | $resto=100-$perc;
|
---|
[137] | 84 | if ($genere==0){echo "<div style=\"text-align:center;margin-left: 10px;\"><hr/>referendum n. $num_gruppo</div>";}
|
---|
[420] | 85 | echo "<div style=\"text-align:center;\">sezioni n. $voti_numero su $sezioni</div><br/>";
|
---|
[412] | 86 | echo "<div style=\"text-align:center;\">";
|
---|
| 87 | ##########################<script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>
|
---|
| 88 | echo "
|
---|
| 89 | <script type=\"text/javascript\">
|
---|
| 90 | google.charts.load('current', {'packages':['gauge']});
|
---|
| 91 | google.charts.setOnLoadCallback(drawGauge);
|
---|
| 92 |
|
---|
[420] | 93 | var gaugeOptions = {min: 0, max: 100, greenFrom: 0, greenTo: $perc,
|
---|
| 94 | yellowFrom: $perc, yellowTo: 100, minorTicks: 5};
|
---|
[412] | 95 | var gauge;
|
---|
| 96 |
|
---|
| 97 | function drawGauge() {
|
---|
| 98 | gaugeData = new google.visualization.DataTable();
|
---|
| 99 | gaugeData.addColumn('number', 'Votanti');
|
---|
| 100 | gaugeData.addRows(1);
|
---|
| 101 | gaugeData.setCell(0, 0, $perc);
|
---|
| 102 |
|
---|
[420] | 103 | gauge = new google.visualization.Gauge(document.getElementById('gauge_div$num_gruppo'));
|
---|
[412] | 104 | gauge.draw(gaugeData, gaugeOptions);
|
---|
| 105 | }
|
---|
| 106 | </script>";
|
---|
[420] | 107 | echo "<div id=\"gauge_div$num_gruppo\" style=\"width:130px; height: 130px;margin-left: auto;margin-right:auto;\"></div> <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>
|
---|
[136] | 108 | </div>";
|
---|
[2] | 109 |
|
---|
[80] | 110 | }
|
---|
[2] | 111 |
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | }
|
---|
| 115 | }
|
---|
| 116 | ?>
|
---|