[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 |
|
---|
[279] | 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 |
|
---|
[265] | 67 | $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";
|
---|
[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 |
|
---|
[265] | 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";
|
---|
[2] | 75 |
|
---|
[399] | 76 | if ($genere==0){$sql.=" and id_gruppo='$id_gruppo'";}
|
---|
[265] | 77 | $res1234 = $dbi->prepare("$sql");
|
---|
| 78 | $res1234->execute();
|
---|
| 79 |
|
---|
| 80 | list($tot)=$res1234->fetch(PDO::FETCH_NUM);
|
---|
[2] | 81 | if ($tot)
|
---|
| 82 | $perc=number_format($voti_t*100/$tot,2);
|
---|
| 83 | else {$tot=0;$perc="0.00";}
|
---|
[80] | 84 | if($voti_t<=$tot){
|
---|
[2] | 85 |
|
---|
| 86 | $resto=100-$perc;
|
---|
[137] | 87 | if ($genere==0){echo "<div style=\"text-align:center;margin-left: 10px;\"><hr/>referendum n. $num_gruppo</div>";}
|
---|
[412] | 88 | echo "<div>sezioni n. $numero su $sezioni</div>";
|
---|
| 89 | echo "<div style=\"text-align:center;\">";
|
---|
| 90 | ##########################<script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>
|
---|
| 91 | echo "
|
---|
| 92 | <script type=\"text/javascript\">
|
---|
| 93 | google.charts.load('current', {'packages':['gauge']});
|
---|
| 94 | google.charts.setOnLoadCallback(drawGauge);
|
---|
| 95 |
|
---|
| 96 | var gaugeOptions = {min: 0, max: 100, yellowFrom: 100, yellowTo: 100,
|
---|
| 97 | redFrom: 100, redTo: 100, minorTicks: 5};
|
---|
| 98 | var gauge;
|
---|
| 99 |
|
---|
| 100 | function drawGauge() {
|
---|
| 101 | gaugeData = new google.visualization.DataTable();
|
---|
| 102 | gaugeData.addColumn('number', 'Votanti');
|
---|
| 103 | gaugeData.addRows(1);
|
---|
| 104 | gaugeData.setCell(0, 0, $perc);
|
---|
| 105 |
|
---|
| 106 | gauge = new google.visualization.Gauge(document.getElementById('gauge_div'));
|
---|
| 107 | gauge.draw(gaugeData, gaugeOptions);
|
---|
| 108 | }
|
---|
| 109 | </script>";
|
---|
| 110 | echo "<div id=\"gauge_div\" style=\"width:130px; height: 130px; ;margin-left: 30px\"></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] | 111 | </div>";
|
---|
[2] | 112 |
|
---|
[80] | 113 | }
|
---|
[2] | 114 |
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | }
|
---|
| 118 | }
|
---|
| 119 | ?>
|
---|