source: trunk/client/modules/Elezioni/blocchi/pie_affluenze.php@ 421

Last change on this file since 421 was 421, checked in by roby, 4 weeks ago
  • CLIENT

-- Modifica alla funzione rss per gestire consultazioni con spoglio non ancora iniziato
-- Aggiunto grafico a torta per le voci del menu Grafici, utile in particolare per il tema tour

File size: 5.8 KB
Line 
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
11if (!defined('MODULE_FILE')) {
12 die ("You can't access this file dirrectly...");
13}
14
15
16
17global $circo,$prefix,$dbi,$id_cons,$genere,$id_circ,$id_comune,$id_cons_gen;
18$query='';
19if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
20else $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 $numsez=$res2->rowCount();
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 $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>";
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
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();
56
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 }
62#fine modifica
63
64 while(list($voti_t, $num_gruppo,$id_gruppo) = $res1->fetch(PDO::FETCH_NUM)) {
65
66 $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";
67 if ($genere==0){$sql.=" and t3.id_gruppo=$id_gruppo";}
68 $res_aff = $dbi->prepare("$sql");
69 $res_aff->execute();
70
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 if ($genere==0){$sql.=" and t3.id_gruppo=$id_gruppo";}
75 $res1234 = $dbi->prepare("$sql");
76 $res1234->execute();
77
78 list($tot)=$res1234->fetch(PDO::FETCH_NUM);
79 if ($tot) $perc=number_format($voti_t*100/$tot,2);
80 else {$tot=0;$perc="0.00";}
81
82 $resto=100-$perc;
83 if ($genere==0){echo "<div style=\"text-align:center\">referendum n. $num_gruppo</div";}
84 echo '<center><div style="text-align:center;color:#ff0000"><b>'.$perc.' %</b><br/>Sezioni '.$voti_numero.' su '.$numsez.'</div>
85 <div id="piechart'.$num_gruppo.'" style="width:100%; min-height:200px;"></div>
86 <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>
87 </center><hr>
88 <script>google.charts.load("current", {"packages":["corechart"]});
89 google.charts.setOnLoadCallback(drawChart);
90
91 function drawChart() {
92 var data = google.visualization.arrayToDataTable([
93 ["Task", "Affluenze"],
94 ["", '.$resto.'],
95 ["'.$perc.'%", '.$perc.']
96 ]);
97 var options = {
98 title: "",
99 is3D:true,
100 legend: "none",
101 pieSliceText: "label",
102 pieSliceTextStyle: {
103 color: "#000",
104 bold:true,
105 fontSize:12
106 },
107 slices: {
108 0: { color: "#ff0000", textStyle:{color:"#fff"}},
109 1: { color: "#ffff00" }
110 }
111 };
112 var chart = new google.visualization.PieChart(document.getElementById("piechart'.$num_gruppo.'"));
113
114 chart.draw(data, options);
115 }</script>';
116 }
117
118 }
119 }
120?>
Note: See TracBrowser for help on using the repository browser.