source: trunk/client/modules/Elezioni/blocchi/00_affluenze.php@ 354

Last change on this file since 354 was 279, checked in by roby, 5 years ago
File size: 7.1 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
9global $circo,$prefix,$dbi,$id_cons,$genere,$id_circ;
10
11if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
12else $circos='';
13// numero sezioni scrutinate
14// $res2 = mysql_query("select * from ".$prefix."_ele_sezioni where id_cons='$id_cons'",$dbi);
15 $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";
16 $res2 = $dbi->prepare("$sql");
17 $res2->execute();
18
19 $sezioni=$res2->rowCount();
20
21//echo "select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' $circos";
22
23
24
25// barre
26 $l_size = getimagesize("modules/Elezioni/images/barre/leftbar.gif");
27 $m_size = getimagesize("modules/Elezioni/images/barre/mainbar.gif");
28 $r_size = getimagesize("modules/Elezioni/images/barre/rightbar.gif");
29 $l_size2 = getimagesize("modules/Elezioni/images/barre/leftbar2.gif");
30 $m_size2 = getimagesize("modules/Elezioni/images/barre/mainbar2.gif");
31 $r_size2 = getimagesize("modules/Elezioni/images/barre/rightbar2.gif");
32
33# $res = mysql_query("select orario,data from ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data desc,orario DESC limit 1", $dbi);
34#x Luciano: quella sopra diventa quella sotto. in rilaff ci sono tutte le date e orari di affluenza mentre in vot_parziale solo quelli inseriri
35# inoltre va messo il desc anche alla data altrimenti il risultato ha la data piu' bassa e l'ora piu' alta
36 $sql="select orario,data from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' order by data desc,orario desc limit 1";
37 $res = $dbi->prepare("$sql");
38 $res->execute();
39
40 if($res){
41
42 while(list($orario,$data) = $res->fetch(PDO::FETCH_NUM)) {
43 list ($ore,$minuti,$secondi)=explode(':',$orario);
44 list ($anno,$mese,$giorno)=explode('-',$data);
45 $tot_v_m=0;$tot_v_d=0;$tot_t=0;
46
47 $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 ";
48 $res1 = $dbi->prepare("$sql");
49 $res1->execute();
50
51
52 $numero=$res1->rowCount();
53
54 echo "<br /><div><h5>Ultime Affluenze</h5></div>";
55 echo "<div style=\"text-align:center;color:#ff0000\"><b>"._ORE." $ore,$minuti "._DEL." $giorno/$mese/$anno</b></div>";
56
57
58
59
60
61#modifica del 26giugno 09 per gestione circoscrizionali
62if($genere==0)
63 $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 " ;
64
65
66else
67 $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";
68$res1 = $dbi->prepare("$sql");
69$res1->execute();
70
71#fine modifica
72
73
74
75
76 while(list($voti_t, $num_gruppo,$id_gruppo) = $res1->fetch(PDO::FETCH_NUM)) {
77// $res1 = mysql_query(,$dbi);
78// $query="select sum(voti_complessivi) from ".$prefix."_ele_voti_parziale where orario='$orario' and data='$data' and id_cons='$id_cons'";
79$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";
80 if ($genere==0){$sql.=" and t3.id_gruppo=$id_gruppo";}
81 $res_aff = $dbi->prepare("$sql");
82 $res_aff->execute();
83
84 $voti_numero=$res_aff->rowCount();
85 // $query="select sum(maschi+femmine) from ".$prefix."_ele_voti_parziale as t1 , ".$prefix."_ele_sezioni as t2 where t1.id_cons=$id_cons and t1.id_sez=t2.id_sez and orario='$orario' and data='$data'";
86 $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";
87
88 if ($genere==0){$sql.=" and id_gruppo=$id_gruppo";}
89 $res1234 = $dbi->prepare("$sql");
90 $res1234->execute();
91
92 list($tot)=$res1234->fetch(PDO::FETCH_NUM);
93 if ($tot)
94 $perc=number_format($voti_t*100/$tot,2);
95 else {$tot=0;$perc="0.00";}
96 echo "<table class=\"td-80\"><tr class=\"bggray\">";
97 if ($genere==0){echo "<td>N.</td>";}
98 echo "<td><b>"._VOTANTI."</b></td><td><b>"._PERCE."</b></td>";
99 echo "<td><b>"._SEZIONI."</b></td>";
100 echo "</tr>";
101 echo "<tr class=\"bggray2\">";
102 if ($genere==0){echo "<td>$num_gruppo</td>";}
103// echo "<td>$voti_t</td><td>$perc %</td><td>$numero</td>
104 echo "<td>$voti_t</td><td>$perc %</td><td>$numero</td>
105 </tr></table>";
106
107
108 // barre
109
110 echo "<table><tr><td><table><tr><td>&nbsp;</td><td>
111<img src=\"modules/Elezioni/images/barre/leftbar2.gif\" height=\"$l_size2[1]\" width=\"$l_size2[0]\" alt=\"\" /><img src=\"modules/Elezioni/images/barre/mainbar2.gif\" alt=\"\" height=\"$m_size2[1]\" width=\"". ($perc * 1)."\" /><img src=\"modules/Elezioni/images/barre/rightbar2.gif\" height=\"$r_size2[1]\" width=\"$r_size2[0]\" alt=\"\" /><span class=\"red\"> $perc</span> % <br /></td></tr>\n";
112
113 $tot_gen=$tot;
114
115
116 echo "<tr><td></td><td><img src=\"modules/Elezioni/images/barre/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" alt=\"\" /><img src=\"modules/Elezioni/images/barre/mainbar.gif\" alt=\"\" height=\"$m_size[1]\" width=\"".(100 * 1)."\" /><img src=\"modules/Elezioni/images/barre/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" alt=\"\" /> 100 % </td></tr></table>";
117 echo "</td></tr></table>";
118
119 }
120
121 }
122}
123?>
Note: See TracBrowser for help on using the repository browser.