1 | <?php
|
---|
2 |
|
---|
3 | /************************************************************************/
|
---|
4 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
5 | /* by Luciano Apolito & Roberto Gigli */
|
---|
6 | /* http://www.eleonline.it */
|
---|
7 | /* info@eleonline.it luciano@aniene.net rgigli@libero.it */
|
---|
8 | /************************************************************************/
|
---|
9 |
|
---|
10 | if (!defined('MODULE_FILE')) {
|
---|
11 | die ("You can't access this file directly...");
|
---|
12 | }
|
---|
13 |
|
---|
14 |
|
---|
15 | $sql="SELECT t1.descrizione, t1.tipo_cons,t2.genere, t2.voto_g, t2.voto_l, t2.voto_c, t2.circo FROM ".$prefix."_ele_consultazione as t1,".$prefix."_ele_tipo as t2 where t1.tipo_cons=t2.tipo_cons and t1.id_cons_gen='$id_cons_gen' ";
|
---|
16 | $res = $dbi->prepare("$sql");
|
---|
17 | $res->execute();
|
---|
18 | list($descr_cons,$tipo_cons,$genere,$votog,$votol,$votoc,$circo) = $res->fetch(PDO::FETCH_NUM);
|
---|
19 | $sql="SELECT t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'";
|
---|
20 | $res = $dbi->prepare("$sql");
|
---|
21 | $res->execute();
|
---|
22 | list($id_cons) = $res->fetch(PDO::FETCH_NUM);
|
---|
23 |
|
---|
24 | /*********************************/
|
---|
25 | /* Grafica votanti */
|
---|
26 | /**********************************/
|
---|
27 |
|
---|
28 | function votanti_mobile(){
|
---|
29 | global $op, $prefix, $dbi, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$tipo_cons,$id_comune,$id_cons_gen,$id_circ,$csv,$w,$l,$siteistat,$flash,$tour,$tema;
|
---|
30 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ?
|
---|
31 | $_GET : $_POST;
|
---|
32 | if ($siteistat==$id_comune) $logo="$siteistat"; else $logo=''; // logo per il comune
|
---|
33 | $logo=verificasimbolo(); // carica_logo da funzioni.php
|
---|
34 | $tab="gruppo"; $tabr="gruppo";
|
---|
35 | if ($genere==0) $tabr="ref";elseif($genere=='4' || $votog) {$tab="lista"; $tabr="lista";}
|
---|
36 | # else $tab="gruppo";
|
---|
37 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
38 | else $circos='';
|
---|
39 |
|
---|
40 |
|
---|
41 | $sql="select t1.id_sez from ".$prefix."_ele_voti_".$tabr." as t1 left join ".$prefix."_ele_$tab as t2 on t1.id_$tab=t2.id_$tab where t1.id_cons='$id_cons' $circos group by t1.id_sez ";
|
---|
42 | $res = $dbi->prepare("$sql");
|
---|
43 | $res->execute();
|
---|
44 | if($res)
|
---|
45 | $numero=$res->rowCount();
|
---|
46 | else
|
---|
47 | $numero=1;
|
---|
48 | $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";
|
---|
49 | $res = $dbi->prepare("$sql");
|
---|
50 | $res->execute();
|
---|
51 | $sezioni=$res->rowCount();
|
---|
52 | if ($numero!=0){
|
---|
53 |
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 | $sql="SELECT sum(maschi+femmine) 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";
|
---|
58 | $res1 = $dbi->prepare("$sql");
|
---|
59 | $res1->execute();
|
---|
60 | list($tot_aventi) = $res1->fetch(PDO::FETCH_NUM);
|
---|
61 |
|
---|
62 | if ($genere!=0) {
|
---|
63 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
64 | echo "<center><h2>";
|
---|
65 | echo "<b>Grafica "._DETTAGLIO." "._VOTIE."</b>";
|
---|
66 | //echo "<i> "._SEZSCRU." $numero "._SU." $sezioni </i>";
|
---|
67 | echo "</h2></center></li>";
|
---|
68 |
|
---|
69 | $sql="SELECT sum(validi+nulli+bianchi+contestati) as tot,
|
---|
70 | sum(validi),sum(nulli),sum(bianchi),sum(contestati), '0'
|
---|
71 | 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 having tot>0";
|
---|
72 | $res1 = $dbi->prepare("$sql");
|
---|
73 | $res1->execute();
|
---|
74 | }else{
|
---|
75 |
|
---|
76 | if($tema=='tour'){
|
---|
77 | $sql="SELECT count(0)
|
---|
78 | from ".$prefix."_ele_gruppo where id_cons=$id_cons";
|
---|
79 | $res1 = $dbi->prepare("$sql");
|
---|
80 | $res1->execute();
|
---|
81 |
|
---|
82 | list($max_ruotag) = $res1->fetch(PDO::FETCH_NUM);
|
---|
83 | if (isset($_SESSION['ruotag'])) { $ruotag=$_SESSION['ruotag'];}
|
---|
84 | else {$ruotag=1;$_SESSION['ruotag']=1;}
|
---|
85 | if ($ruotag>=$max_ruotag) {$ruotag=1;}
|
---|
86 | else {$ruotag++;}
|
---|
87 | $_SESSION['ruotag']=$ruotag;
|
---|
88 | $sql="SELECT count(0) from ".$prefix."_ele_voti_ref AS t1 LEFT JOIN ".$prefix."_ele_gruppo AS t2 ON t1.id_gruppo = t2.id_gruppo WHERE t1.id_cons ='$id_cons' AND t2.num_gruppo ='$ruotag'";
|
---|
89 | $res1 = $dbi->prepare("$sql");
|
---|
90 | $res1->execute();
|
---|
91 | list($numero)=$res1->fetch(PDO::FETCH_NUM);
|
---|
92 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
93 | echo "<center><h2>";
|
---|
94 | echo "<b>Grafica "._DETTAGLIO." "._VOTIE."</b> ";
|
---|
95 | //echo "<i> "._SEZSCRU." $numero "._SU." $sezioni </i>";
|
---|
96 | echo "</h2></center></li>";
|
---|
97 |
|
---|
98 | $sql="SELECT sum( t1.validi + t1.nulli + t1.bianchi + t1.contestati ) AS tot, sum( t1.validi ) , sum( t1.nulli ) , sum( t1.bianchi ) , sum( t1.contestati ) , t1.id_gruppo
|
---|
99 | FROM ".$prefix."_ele_voti_ref AS t1 LEFT JOIN ".$prefix."_ele_gruppo AS t2 ON t1.id_gruppo = t2.id_gruppo
|
---|
100 | WHERE t1.id_cons ='$id_cons' AND t2.num_gruppo ='$ruotag' GROUP BY t1.id_gruppo HAVING tot >0";
|
---|
101 | $res1 = $dbi->prepare("$sql");
|
---|
102 | $res1->execute();
|
---|
103 | } else
|
---|
104 | $sql="SELECT sum(validi+nulli+bianchi+contestati) as tot,
|
---|
105 | sum(validi),sum(nulli),sum(bianchi),sum(contestati), id_gruppo
|
---|
106 | from ".$prefix."_ele_voti_ref where id_cons=$id_cons group by id_gruppo having tot>0";
|
---|
107 | $res1 = $dbi->prepare("$sql");
|
---|
108 | $res1->execute();
|
---|
109 | }
|
---|
110 | while (list($tot_votanti,$validi,$nulli,$bianchi,$contestati,$id) = $res1->fetch(PDO::FETCH_NUM)){
|
---|
111 | $arperc=array();
|
---|
112 | $arval=array($validi,$nulli,$bianchi,$contestati);
|
---|
113 | $arperc=arrayperc($arval,$tot_votanti);
|
---|
114 | $tot_votanti=$validi+$bianchi+$nulli+$contestati;
|
---|
115 | $perc_validi=number_format($arperc[0],2);
|
---|
116 | $perc_nulli=number_format($arperc[1],2);
|
---|
117 | $perc_bianchi=number_format($arperc[2],2);
|
---|
118 | $perc_conte=number_format($arperc[3],2);
|
---|
119 | $perc_votanti=number_format($tot_votanti*100/$tot_aventi,2);
|
---|
120 | $non_votanti=($tot_aventi - $tot_votanti);
|
---|
121 | $perc_non=100-$perc_votanti;
|
---|
122 |
|
---|
123 | if ($genere==0) {
|
---|
124 | $sql="SELECT num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id";
|
---|
125 | $res = $dbi->prepare("$sql");
|
---|
126 | $res->execute();
|
---|
127 | list($num_gruppo,$descr_gruppo) = $res->fetch(PDO::FETCH_NUM);
|
---|
128 | }
|
---|
129 |
|
---|
130 |
|
---|
131 |
|
---|
132 | $a1=_VALIDI;$b1=_NULLI;$c1=_BIANCHI;$d1=_CONTESTATI;$titolo=""._PERCE." "._VOTIE."";
|
---|
133 | $e1=_VOTANTI;$f1=""._NON." "._VOTANTI."";$titolo2=""._PERCE." "._AFFLUENZE."";
|
---|
134 |
|
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|
138 |
|
---|
139 | echo "<div style=\"text-align:center\">
|
---|
140 | <h1>"._PERCE." "._VOTANTI."</h1>";
|
---|
141 | if ($genere==0) echo "<h2> "._GRUPPO." $num_gruppo</h2>";
|
---|
142 |
|
---|
143 |
|
---|
144 |
|
---|
145 | echo "<br /><img alt=\"Grafico\" width=\"300\" src=\"modules/Elezioni/grafici/votanti_graf.php?titolo=$titolo2&e=$perc_votanti&f=$perc_non&e1=$e1&f1=$f1&logo=$logo\" /><br /><br /></div>";
|
---|
146 |
|
---|
147 | echo "<div style=\"text-align:center\">";
|
---|
148 | echo "<h1>"._PERCE." "._VOTIE."</h1>";
|
---|
149 | if ($genere==0) echo "<h2> "._GRUPPO." $num_gruppo<h2> ";
|
---|
150 |
|
---|
151 |
|
---|
152 | echo "<br /><img alt=\"Grafico\" width=\"300\" src=\"modules/Elezioni/grafici/voti_graf.php?cop=&titolo=$titolo&a=$perc_validi&b=$perc_nulli&c=$perc_bianchi&d=$perc_conte&a1=$a1&b1=$b1&c1=$c1&d1=$d1&logo=$logo\" /><br /><br /></div>";
|
---|
153 |
|
---|
154 |
|
---|
155 | }
|
---|
156 | }
|
---|
157 |
|
---|
158 | }
|
---|
159 |
|
---|
160 |
|
---|
161 |
|
---|
162 |
|
---|
163 |
|
---|
164 |
|
---|
165 | /***********************************
|
---|
166 | /* Grafica Gruppo
|
---|
167 | /**********************************/
|
---|
168 |
|
---|
169 | function graf_gruppo_mob(){
|
---|
170 | global $dbi,$admin, $bgcolor1, $bgcolor5, $prefix, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$id_cons_gen,$id_comune,$id_circ,$tipo_cons,$w,$l,$op,$siteistat,$flash,$visgralista,$graficogruppo,$rss;
|
---|
171 | # parte grafica
|
---|
172 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ?
|
---|
173 | $_GET : $_POST;
|
---|
174 | if (isset($param['grafica'])) $grafica=intval($param['grafica']); else $grafica='';
|
---|
175 |
|
---|
176 |
|
---|
177 | if ($siteistat==$id_comune) $logo=$siteistat; else $logo=''; // logo per il comune
|
---|
178 |
|
---|
179 | if (!$id_circ and $circo){
|
---|
180 | $sql="SELECT id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons order by num_circ limit 0,1";
|
---|
181 | $res_sez = $dbi->prepare("$sql");
|
---|
182 | $res_sez->execute();
|
---|
183 | list($id_circ)=$res_sez->fetch(PDO::FETCH_NUM);
|
---|
184 | }
|
---|
185 | $circond='';$circondt1='';
|
---|
186 | if ($genere!=0){$tab="ele_voti_gruppo";}else{$tab="ele_voti_ref";}
|
---|
187 | if ($genere==4 or $visgralista){$tab="ele_voti_lista";}
|
---|
188 | if ($votog){$tab="ele_voti_lista";}
|
---|
189 | $sql="select id_sez from ".$prefix."_$tab where id_cons='$id_cons' group by id_sez ";
|
---|
190 | $res = $dbi->prepare("$sql");
|
---|
191 | $res->execute();
|
---|
192 | if ($circo){
|
---|
193 | $sql="select t1.* from ".$prefix."_ele_voti_gruppo as t1, ".$prefix."_ele_gruppo as t2 where t1.id_gruppo=t2.id_gruppo and t1.id_cons='$id_cons' and t2.id_circ=$id_circ group by t1.id_sez ";
|
---|
194 | $res = $dbi->prepare("$sql");
|
---|
195 | $res->execute();
|
---|
196 |
|
---|
197 | $sql="select sum(t1.voti) from ".$prefix."_ele_voti_gruppo as t1, ".$prefix."_ele_gruppo as t2 where t1.id_gruppo=t2.id_gruppo and t1.id_cons='$id_cons' and t2.id_circ=$id_circ";
|
---|
198 | $circond="and id_circ=$id_circ";$circondt1="and t1.id_circ=$id_circ";
|
---|
199 | $restotv = $dbi->prepare("$sql");
|
---|
200 | $restotv->execute();
|
---|
201 | }
|
---|
202 | if ($res) $numero=$res->rowCount();else $numero=0;
|
---|
203 | $sql="select t2.* from ".$prefix."_ele_sezioni as t2, ".$prefix."_ele_sede as t1 where t2.id_cons='$id_cons' and t1.id_sede=t2.id_sede $circondt1";
|
---|
204 | $res = $dbi->prepare("$sql");
|
---|
205 | $res->execute();
|
---|
206 | if ($res) $sezioni=$res->rowCount();else $sezioni=0;
|
---|
207 |
|
---|
208 |
|
---|
209 | if ($numero>0){
|
---|
210 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
211 | echo "<center><b>"._PREFERENZE." "._GRUPPO."</b>";
|
---|
212 | //echo "<br/><i> "._SEZSCRU." $numero "._SU." $sezioni </i><br/>";
|
---|
213 | echo "</center></li>";
|
---|
214 |
|
---|
215 |
|
---|
216 | if ($genere!=0){
|
---|
217 | // tot voti
|
---|
218 | if (!$circo)
|
---|
219 | $sql="select sum(voti) from ".$prefix."_$tab where id_cons=$id_cons ";
|
---|
220 | if ($votog)
|
---|
221 | $sql="select sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons ";
|
---|
222 | $restotv = $dbi->prepare("$sql");
|
---|
223 | $restotv->execute();
|
---|
224 | list($tot) = $restotv->fetch(PDO::FETCH_NUM);
|
---|
225 |
|
---|
226 | $i=0;
|
---|
227 | // lista o gruppo
|
---|
228 | if ($genere!=4 and !$visgralista){
|
---|
229 |
|
---|
230 | if ($votog){
|
---|
231 |
|
---|
232 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
233 | from ".$prefix."_ele_gruppo as t1,
|
---|
234 | ".$prefix."_ele_voti_lista as t2,
|
---|
235 | ".$prefix."_ele_lista as t3
|
---|
236 | where t1.id_cons='$id_cons'
|
---|
237 | and t2.id_lista=t3.id_lista
|
---|
238 | and t1.id_gruppo=t3.id_gruppo
|
---|
239 | group by t1.id_gruppo
|
---|
240 | order by somma desc";
|
---|
241 | $cosa='id_gruppo';
|
---|
242 |
|
---|
243 | }else{
|
---|
244 |
|
---|
245 |
|
---|
246 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
247 | from ".$prefix."_ele_gruppo as t1
|
---|
248 | left join ".$prefix."_$tab as t2 on (t1.id_gruppo=t2.id_gruppo)
|
---|
249 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons $circondt1
|
---|
250 | group by t1.id_gruppo, t1.num_gruppo, t1.descrizione
|
---|
251 | order by somma desc";
|
---|
252 | $cosa='id_gruppo';
|
---|
253 | }
|
---|
254 | $res = $dbi->prepare("$sql");
|
---|
255 | $res->execute();
|
---|
256 |
|
---|
257 |
|
---|
258 | }else{
|
---|
259 | $sql="select t1.id_lista, t1.num_lista, t1.descrizione, sum(t2.voti) as somma
|
---|
260 | from ".$prefix."_ele_lista as t1
|
---|
261 | left join ".$prefix."_$tab as t2 on (t1.id_lista=t2.id_lista)
|
---|
262 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons
|
---|
263 | group by t2.id_lista
|
---|
264 | order by somma desc";
|
---|
265 | $res = $dbi->prepare("$sql");
|
---|
266 | $res->execute();
|
---|
267 | $cosa='id_lista';
|
---|
268 | }
|
---|
269 |
|
---|
270 |
|
---|
271 | // inizio tabella dati
|
---|
272 | // variabili stampa flash
|
---|
273 | $e=0;
|
---|
274 | $gruppos[$e]="";
|
---|
275 | $pre[$e]="";
|
---|
276 | $e=1;
|
---|
277 | // fine
|
---|
278 | $gruppinum=$res->rowCount();
|
---|
279 | $altrivoti=0;
|
---|
280 | ####calcolo percentuale
|
---|
281 | $arvoti=array();
|
---|
282 | $arperc=array();
|
---|
283 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
284 | $arvoti[$id]=$voti;
|
---|
285 | }
|
---|
286 | $arperc=arrayperc($arvoti,$tot);
|
---|
287 | //$db->sql_data_seek($res,0);
|
---|
288 | $res = $dbi->prepare("$sql");
|
---|
289 | $res->execute();
|
---|
290 | # mysql_data_seek($res,0);
|
---|
291 | ####
|
---|
292 | $altriperc=0;
|
---|
293 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
294 |
|
---|
295 |
|
---|
296 | // verica chi ha preso meno del 3%
|
---|
297 | $menotre=(number_format($voti*100/$tot,2));
|
---|
298 |
|
---|
299 | if($menotre>3){
|
---|
300 |
|
---|
301 |
|
---|
302 |
|
---|
303 |
|
---|
304 | // funz per il taglio corretto della frase 13 feb 2007
|
---|
305 | //$descrizione=taglio(4,$descrizione);
|
---|
306 |
|
---|
307 | $gruppo[$i]=(substr($descrizione,0,21));
|
---|
308 | $gruppos[$e]=(substr($descrizione,0,21)); //flash
|
---|
309 |
|
---|
310 |
|
---|
311 |
|
---|
312 | if (strlen($descrizione)>21) $gruppo[$i].="...";
|
---|
313 | if (strlen($descrizione)>21) $gruppos[$e].="...";
|
---|
314 | $pro[$i]=number_format($arperc[$id],2);
|
---|
315 | $pre[$e]=number_format($arperc[$id],2); //flash
|
---|
316 |
|
---|
317 |
|
---|
318 | }else{
|
---|
319 | //somma i voti sotto il 3%
|
---|
320 | $altrivoti = $altrivoti + $voti;
|
---|
321 | $altriperc += $arperc[$id];
|
---|
322 | }
|
---|
323 |
|
---|
324 |
|
---|
325 |
|
---|
326 |
|
---|
327 |
|
---|
328 |
|
---|
329 | $votiv=number_format($voti,0,',','.');
|
---|
330 | // formattazione numeri perc
|
---|
331 | $prov=number_format($arperc[$id],2);
|
---|
332 |
|
---|
333 | // sviluppo tabella dati
|
---|
334 | $bgcolor1= ($bgcolor1=="#cacaca") ? "#ffffff":"#cacaca";
|
---|
335 |
|
---|
336 | if($grafica!="1"){
|
---|
337 | echo "<table style=\" text-align:left;border:1px solid Black;width:100%;\"><tr>\n<td width=\"55\"><a href=\"#dati\">
|
---|
338 | <img src=\"modules.php?name=Elezioni&file=foto&$cosa=$id\" width=\"50\" align=\"left\" alt=\"\" /></a></td>\n
|
---|
339 | <td><span style=\"font-size:10px;\">$descrizione</span><br/>
|
---|
340 |
|
---|
341 | "._VOTI." <span style=\"font-size:20px;\"><b>$votiv</b> <i>($prov%)</i></span></td>\n
|
---|
342 | </tr></table>\n";
|
---|
343 | }
|
---|
344 | $i++;
|
---|
345 | }
|
---|
346 | // aggiunge altri minori al 3%
|
---|
347 | // esiste
|
---|
348 | // corretto 15 aprile 2006
|
---|
349 | if ($altrivoti>0){
|
---|
350 |
|
---|
351 | $gruppo[]=_ALTRI;
|
---|
352 | $gruppos[]=_ALTRI;
|
---|
353 | $pro[]=$altriperc; #number_format($altrivoti*100/$tot,3);
|
---|
354 | $pre[]=$altriperc; #number_format($altrivoti*100/$tot,3);
|
---|
355 | }
|
---|
356 |
|
---|
357 |
|
---|
358 | if ($i<=10) $i=10;
|
---|
359 | $titolo=""._PERCE." "._VOTIE."";
|
---|
360 | $dati1=serialize($pro);
|
---|
361 | //$dati1=urlencode($dati1);
|
---|
362 | //$gruppo=utf8_encode($gruppo);
|
---|
363 | $dati2=serialize($gruppo);
|
---|
364 | $dati2=urlencode($dati2);
|
---|
365 |
|
---|
366 | $titolo=urlencode($titolo);
|
---|
367 | if (isset($copy)) $copy=urlencode($copy); else $copy='';
|
---|
368 | $descr_cons=urlencode($descr_cons);
|
---|
369 | if ($genere==4){$w=700;$l=300;}else{$w=500;$l=180;}
|
---|
370 |
|
---|
371 |
|
---|
372 | if($grafica=="1")
|
---|
373 | echo "<br/><center><img width=\"300\" src='modules/Elezioni/grafici/barre.php?dati1=$dati1&dati2=$dati2&i=$i&cop=$copy&titolo=$titolo&descr=$descr_cons&l=$l&w=$w&logo=$logo' alt=\"Grafico\" /><br/></center>";
|
---|
374 |
|
---|
375 |
|
---|
376 |
|
---|
377 |
|
---|
378 |
|
---|
379 | }else{
|
---|
380 | // tot voti
|
---|
381 | $sql="
|
---|
382 | select sum(validi),id_gruppo from ".$prefix."_$tab where id_cons=$id_cons group by id_gruppo";
|
---|
383 | $res = $dbi->prepare("$sql");
|
---|
384 | $res->execute();
|
---|
385 | while (list($tot,$id_gruppo) = $res->fetch(PDO::FETCH_NUM)){
|
---|
386 |
|
---|
387 | $s=0;
|
---|
388 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.si), sum(t2.no)
|
---|
389 | from ".$prefix."_ele_gruppo as t1
|
---|
390 | left join ".$prefix."_$tab as t2 on (t1.id_gruppo=t2.id_gruppo)
|
---|
391 | where t1.id_cons='$id_cons' and t1.id_gruppo='$id_gruppo'
|
---|
392 | group by t1.id_gruppo
|
---|
393 | ";
|
---|
394 | $res1 = $dbi->prepare("$sql");
|
---|
395 | $res1->execute();
|
---|
396 |
|
---|
397 |
|
---|
398 | while (list($id_gruppo,$num_gruppo,$descrizione,$si,$no) = $res1->fetch(PDO::FETCH_NUM)){
|
---|
399 | if($tot){
|
---|
400 | $percsi=number_format($si*100/$tot,3);
|
---|
401 | $percno=number_format($no*100/$tot,3);
|
---|
402 | $percsi=number_format($percsi,2);
|
---|
403 | $percno=number_format($percno,2);
|
---|
404 | }else{
|
---|
405 | $percsi="0.00"; $percno="0.00";
|
---|
406 | }
|
---|
407 |
|
---|
408 | $gruppo=array("si","no");
|
---|
409 | $gruppos=array("","si","no");// flash
|
---|
410 | $pro=array($percsi,$percno);
|
---|
411 | $pre=array("",$percsi,$percno);//flash
|
---|
412 | // echo "<br/><b><center>$descrizione</center><br/><br/>";
|
---|
413 | // sviluppo tabella dati
|
---|
414 | echo "<li><table style=\"text-align:left;border : 1px solid Black;width:100%;\">"; // inizio tabella dati
|
---|
415 | echo "<tr><td >$num_gruppo - $descrizione</b></td></tr></table>
|
---|
416 | <table style=\"text-align:left;border : 1px solid Black;width:100%;\" bgcolor=\"#ffffff\" width=\"100%\">
|
---|
417 | <tr>
|
---|
418 |
|
---|
419 | <td width=\"33%\">"._SI."</td>
|
---|
420 | <td width=\"33%\"><b>$si voti</b></td>
|
---|
421 | <td width=\"33%\"><b><span style=\"color:#ff0000\">$percsi %</span></b></td><table>
|
---|
422 | <table style=\"text-align:left;border : 1px solid Black;width:100%;\">
|
---|
423 | <tr>
|
---|
424 | <td width=\"33%\">"._NO."</td>
|
---|
425 | <td width=\"33%\"><b>$no voti</b></td>
|
---|
426 | <td width=\"33%\"><b><span style=\"color:#ff0000\">$percno %</span></b></td><tr>
|
---|
427 | </table></li>";
|
---|
428 |
|
---|
429 | $i=8; // parametro lunghezza tavola
|
---|
430 | $l=30; // larghezza label
|
---|
431 | $titolo="Numero ".$num_gruppo."";
|
---|
432 | $dati1=serialize($pro);
|
---|
433 | //$dati1=urlencode($dati1); //IE
|
---|
434 | $dati2=serialize($gruppo);
|
---|
435 | $dati2=urlencode($dati2);
|
---|
436 | $titolo=urlencode($titolo);
|
---|
437 | if (isset($copy)) $copy=urlencode($copy); else $copy='';
|
---|
438 | $descr=urlencode($descr_cons);
|
---|
439 |
|
---|
440 |
|
---|
441 |
|
---|
442 |
|
---|
443 |
|
---|
444 |
|
---|
445 |
|
---|
446 |
|
---|
447 | $s++;
|
---|
448 | }
|
---|
449 |
|
---|
450 |
|
---|
451 | }
|
---|
452 |
|
---|
453 |
|
---|
454 |
|
---|
455 | }
|
---|
456 |
|
---|
457 | }
|
---|
458 |
|
---|
459 |
|
---|
460 | }
|
---|
461 |
|
---|
462 | /***********************************
|
---|
463 | /* Grafica liste
|
---|
464 | /**********************************/
|
---|
465 |
|
---|
466 | function graf_liste_mob(){
|
---|
467 |
|
---|
468 | global $id_cons,$id_cons_gen,$prefix,$dbi,$min,$offset,$op,$tipo_cons,$prev,$next,$votog,$votol,$circo,$genere,$id_comune,$colortheme;
|
---|
469 |
|
---|
470 | $offset=10000;
|
---|
471 | if (!isset($min)) $min=0;
|
---|
472 |
|
---|
473 | // numero sezioni scrutinate sul gruppo
|
---|
474 | if ($circo) $circos = "and id_circ=$id_circ" ; else $circos='';
|
---|
475 | if ($genere==0) $tab="ref"; else $tab="gruppo";
|
---|
476 | $sql="select id_sez from ".$prefix."_ele_voti_".$tab." where id_cons='$id_cons' $circos group by id_sez ";
|
---|
477 | $res = $dbi->prepare("$sql");
|
---|
478 | $res->execute();
|
---|
479 | $numero=$res->rowCount();
|
---|
480 | $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' $circos ";
|
---|
481 | $res = $dbi->prepare("$sql");
|
---|
482 | $res->execute();
|
---|
483 | $sezioni=$res->rowCount();
|
---|
484 | //$res = mysql_query("select chiusa from ".$prefix."_ele_cons_comuni where id_cons='$id_cons' $circos ",$dbi);
|
---|
485 | //$chiusa=mysql_num_rows($res);
|
---|
486 | //if ($numero!=0 and $chiusa==0)
|
---|
487 |
|
---|
488 | if ($numero>0){
|
---|
489 |
|
---|
490 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
491 | echo "<center><b>Voti per Lista</b>";
|
---|
492 | echo "<br/><i> "._SEZSCRU." $numero "._SU." $sezioni </i><br/>";
|
---|
493 | echo "</center></li>";
|
---|
494 | }
|
---|
495 |
|
---|
496 |
|
---|
497 | // tot liste
|
---|
498 | $sql="SELECT * FROM ".$prefix."_ele_lista where id_cons='$id_cons' ";
|
---|
499 | $res = $dbi->prepare("$sql");
|
---|
500 | $res->execute();
|
---|
501 | $max = $res->rowCount();
|
---|
502 |
|
---|
503 | // tot voti liste
|
---|
504 | $sql="select sum(voti) from ".$prefix."_ele_voti_lista where id_cons='$id_cons'";
|
---|
505 | $res_lista_tutti = $dbi->prepare("$sql");
|
---|
506 | $res_lista_tutti->execute();
|
---|
507 | list($voti_lista_tutti) = $res_lista_tutti->fetch(PDO::FETCH_NUM);
|
---|
508 |
|
---|
509 | $sql="select id_cons ,id_lista ,id_gruppo, num_lista, descrizione from ".$prefix."_ele_lista where id_cons='$id_cons' ORDER BY num_lista LIMIT $min,$offset";
|
---|
510 | $result = $dbi->prepare("$sql");
|
---|
511 | $result->execute();
|
---|
512 | while(list($id_cons2,$id_lista,$id_gruppo, $num_lista, $descr_lista) = $result->fetch(PDO::FETCH_NUM)) {
|
---|
513 | if ($num_lista!=0) {
|
---|
514 | // voti lista
|
---|
515 | $sql="select sum(voti) from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_lista='$id_lista'";
|
---|
516 | $res_lista = $dbi->prepare("$sql");
|
---|
517 | $res_lista->execute();
|
---|
518 | list($voti_lista) = $res_lista->fetch(PDO::FETCH_NUM);
|
---|
519 | if ($voti_lista_tutti!=0)
|
---|
520 | $perc_lista=number_format(($voti_lista*100)/$voti_lista_tutti,2);
|
---|
521 | else $perc_lista='';
|
---|
522 | // gruppo
|
---|
523 | $sql="select descrizione from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
|
---|
524 | $res_gruppo = $dbi->prepare("$sql");
|
---|
525 | $res_gruppo->execute();
|
---|
526 | list($descr_gruppo) = $res_gruppo->fetch(PDO::FETCH_NUM);
|
---|
527 |
|
---|
528 |
|
---|
529 | /*echo "<table><tr class=\"bggray\">"
|
---|
530 | ."<td class=\"td-5\"><b>"._NUM."</b></td>"
|
---|
531 | ."<td ><b>"._DESCR."</b></td>"
|
---|
532 | ."<td class=\"td-5\"><b>"._SIMBOLO."</b></td>"
|
---|
533 | ."<td class=\"td-5\"><b>"._GRUPPO."</b></td></tr>";
|
---|
534 | */
|
---|
535 |
|
---|
536 |
|
---|
537 | echo "<li><table style=\"text-align:left;border : 1px solid Black;width:100%\"><tr><td width=\"15\">$num_lista
|
---|
538 | </td>
|
---|
539 | <td width=\"60\">
|
---|
540 | <img width=\"50\" src=\"modules.php?name=Elezioni&file=foto&id_lista=$id_lista\" alt=\"$descr_lista\" /></td>
|
---|
541 |
|
---|
542 |
|
---|
543 | <td width=\"320\"><span style=\"font-size:12px;\">$descr_lista</span><br />Voti:
|
---|
544 | <b>$voti_lista </b><span style=\"color:#ff0000;font-size:12px;\"> ($perc_lista %)</span>";
|
---|
545 | echo "</td>
|
---|
546 |
|
---|
547 | <td width=\"180\">
|
---|
548 | <img class=\"stemma\" width=\"50\" src=\"modules.php?name=Elezioni&file=foto&id_gruppo=$id_gruppo\" alt=\"$descr_gruppo\" />
|
---|
549 | <br /><span style=\"font-size:10px;\">$descr_gruppo</span></td>
|
---|
550 | </tr></table></li>";
|
---|
551 | }
|
---|
552 | }
|
---|
553 | }
|
---|
554 |
|
---|
555 |
|
---|
556 |
|
---|
557 |
|
---|
558 |
|
---|
559 | /***********************************
|
---|
560 | /* Grafica Candidato
|
---|
561 | /**********************************/
|
---|
562 |
|
---|
563 | function graf_candidato_mob(){
|
---|
564 | global $dbi,$bgcolor1, $bgcolor5,$bgcolor5, $prefix, $offset, $min,$descr_cons, $id_cons,$tipo_cons,$copy,$id_comune,$id_istat,$genere,$votog,$votol,$votoc,$circo,$siteistat;
|
---|
565 | if ($siteistat==$id_comune) $logo='1'; else $logo=''; // logo per il comune
|
---|
566 | $bgcolor1="";
|
---|
567 |
|
---|
568 | $tab="ele_voti_candidati";
|
---|
569 |
|
---|
570 | $sql="select id_sez from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' group by id_sez ";
|
---|
571 | $res = $dbi->prepare("$sql");
|
---|
572 | $res->execute();
|
---|
573 | $numero=$res->rowCount();
|
---|
574 | $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons'";
|
---|
575 | $res = $dbi->prepare("$sql");
|
---|
576 | $res->execute();
|
---|
577 | $sezioni=$res->rowCount();
|
---|
578 |
|
---|
579 |
|
---|
580 | if ($numero>0){
|
---|
581 |
|
---|
582 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
583 | echo "<center><b>Elenco candidati in ordine di voti</b>";
|
---|
584 | echo "<br/><i> "._SEZSCRU." $numero "._SU." $sezioni </i><br/>";
|
---|
585 | echo "</center></li>";
|
---|
586 |
|
---|
587 |
|
---|
588 | // tot voti
|
---|
589 | $sql="
|
---|
590 | select sum(voti) from ".$prefix."_ele_voti_candidati where id_cons=$id_cons ";
|
---|
591 | $res = $dbi->prepare("$sql");
|
---|
592 | $res->execute();
|
---|
593 | list($tot) = $res->fetch(PDO::FETCH_NUM);
|
---|
594 |
|
---|
595 | // gruppi o liste per simbolo
|
---|
596 |
|
---|
597 | if ($genere==4){
|
---|
598 | $scelta="_ele_lista as t3 on (t1.id_lista=t3.id_lista)";
|
---|
599 | }else{
|
---|
600 | $scelta="_ele_lista as t3 on (t1.id_lista=t3.id_lista)";
|
---|
601 | }
|
---|
602 | $i=0;
|
---|
603 | $sql="select t1.id_lista, t1.id_cand, t1.nome , t1.cognome, sum(t2.voti) as somma
|
---|
604 | from ".$prefix."_ele_candidati as t1
|
---|
605 | left join ".$prefix."_ele_voti_candidati as t2 on (t1.id_cand=t2.id_cand)
|
---|
606 | left join ".$prefix.$scelta."
|
---|
607 | where t1.id_cons='$id_cons'
|
---|
608 | group by t1.id_lista, t1.id_cand, t1.nome, t1.cognome
|
---|
609 | order by somma desc";
|
---|
610 | $res = $dbi->prepare("$sql");
|
---|
611 | $res->execute();
|
---|
612 | $n_candi=$res->rowCount();
|
---|
613 |
|
---|
614 | while (list($id_lista,$id_cand,$nome,$cognome,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
615 | $candidato[$i]=$cognome;
|
---|
616 | $pro[$i]=number_format($voti*100/$tot,2);
|
---|
617 | // sviluppo tabella dati
|
---|
618 | $e=$i+1;
|
---|
619 | echo "<li><table style=\"text-align:left;border : 1px solid Black;width:100%;\">"; // inizio tabella dati
|
---|
620 | echo "<tr><td>".$e."°</td><td><b><img alt=\"$nome $cognome\" src=\"modules.php?name=Elezioni&file=foto&id_lista=$id_lista\" align=\"middle\" width=\"30\"></b></td>
|
---|
621 | <td width=\"70%\" bgcolor=\"$bgcolor1\"><b>$nome $cognome</b><br/>
|
---|
622 | "._VOTI.": <b>$voti </b>
|
---|
623 | ( <span style=\"color:#ff0000;\">$pro[$i]%</span> )</td></tr>";
|
---|
624 | echo "</table></li>"; // fine tabella dati
|
---|
625 | /* tolto il conteggio
|
---|
626 | if ($e=='5000' || $e==$n_candi){
|
---|
627 |
|
---|
628 |
|
---|
629 |
|
---|
630 |
|
---|
631 |
|
---|
632 | //include("footer.php");
|
---|
633 | exit;
|
---|
634 | }
|
---|
635 |
|
---|
636 | */
|
---|
637 |
|
---|
638 | $i++;
|
---|
639 |
|
---|
640 |
|
---|
641 |
|
---|
642 |
|
---|
643 | }
|
---|
644 |
|
---|
645 | }
|
---|
646 |
|
---|
647 | }
|
---|
648 |
|
---|
649 |
|
---|
650 | ######################################################
|
---|
651 | function numerodisezioni() {
|
---|
652 | /*Funzione numero sezioni scrutinate
|
---|
653 | /*****************************************************
|
---|
654 | Ritorna i dati in un array con quest'ordine:
|
---|
655 | numero di sezioni totali , numero di sezioni scrutinate
|
---|
656 | *******************************************************/
|
---|
657 |
|
---|
658 |
|
---|
659 |
|
---|
660 | global $dbi,$db, $prefix, $circo, $genere,$id_cons_gen,$id_cons,$id_circ,$tipo_cons,$votog,$id_comune;
|
---|
661 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
662 | else $circos='';
|
---|
663 |
|
---|
664 | //if ($genere==0) $tab="ref";elseif($genere=='4' || $votog) $tab="lista";
|
---|
665 | if($genere=='4' || $votog) $tab="lista";
|
---|
666 | else $tab="gruppo";
|
---|
667 | if ($genere==0) $tab="ref";
|
---|
668 |
|
---|
669 |
|
---|
670 | $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";
|
---|
671 | $res2 = $dbi->prepare("$sql");
|
---|
672 | $res2->execute();
|
---|
673 | $result_sezioni[1]=$res2->rowCount();
|
---|
674 |
|
---|
675 |
|
---|
676 |
|
---|
677 | // numero sezioni
|
---|
678 | $sql="select t3.id_sez from ".$prefix."_ele_voti_".$tab." 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' $circos group by t3.id_sez ";
|
---|
679 | $sez_num = $dbi->prepare("$sql");
|
---|
680 | $sez_num->execute();
|
---|
681 | $result_sezioni[0]=$sez_num->rowCount();
|
---|
682 |
|
---|
683 | // $sez_scrut = $db->sql_query("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");
|
---|
684 | //$result_sezioni[1]=$db->sql_numrows($sez_scrut);
|
---|
685 |
|
---|
686 |
|
---|
687 | $sql="select chiusa from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
|
---|
688 | $res = $dbi->prepare("$sql");
|
---|
689 | $res->execute();
|
---|
690 | //$chiusa=$db->sql_numrows($res);
|
---|
691 | list($chiusa) = $res->fetch(PDO::FETCH_NUM);
|
---|
692 | //echo "-----------> $chiusa - $id_comune";
|
---|
693 |
|
---|
694 | if($chiusa!=0)$result_sezioni[0]=0;
|
---|
695 | return $result_sezioni;
|
---|
696 |
|
---|
697 |
|
---|
698 |
|
---|
699 |
|
---|
700 |
|
---|
701 | }
|
---|
702 | ####################################################
|
---|
703 | # Come
|
---|
704 | ####################################################
|
---|
705 |
|
---|
706 | function come_mob($info) {
|
---|
707 | global $prefix, $dbi, $offset, $min,$id_cons,$tipo_cons,$descr_cons,$id_comune;
|
---|
708 |
|
---|
709 | $tab='';
|
---|
710 | if ($info=="come"){ $tab="_ele_come";$vista="Come si vota";}
|
---|
711 | elseif ($info=="numeri"){ $tab="_ele_numeri";$vista="Numeri Utili";}
|
---|
712 | elseif ($info=="servizi"){ $tab="_ele_servizi";$vista="Servizi Elettorali";}
|
---|
713 | elseif ($info=="link"){ $tab="_ele_link";$vista="Link Utili";}
|
---|
714 | else{ $tab="_ele_come";$vista="Come si vota";}
|
---|
715 |
|
---|
716 |
|
---|
717 | global $user, $admin, $cookie, $textcolor2;
|
---|
718 | $sql="select mid, title, preamble, content,editimage from ".$prefix."$tab where id_cons='$id_cons' order by mid ";
|
---|
719 | $result = $dbi->prepare("$sql");
|
---|
720 | $result->execute();
|
---|
721 |
|
---|
722 | echo "<li data-role=\"list-divider\" >";
|
---|
723 | echo "<center><b>$vista</b>";
|
---|
724 | echo "</center></li>";
|
---|
725 |
|
---|
726 |
|
---|
727 |
|
---|
728 | if ($result->rowCount() == 0) {
|
---|
729 | return;
|
---|
730 | } else {
|
---|
731 | while (list($mid, $title, $preamble,$content, $editimage) = $result->fetch(PDO::FETCH_NUM)) {
|
---|
732 | if ($title != "" && $content != "") {
|
---|
733 |
|
---|
734 | if ($info=="link"){
|
---|
735 |
|
---|
736 | echo "<li>
|
---|
737 | <b><a href=\"$preamble\">$title</a></b>
|
---|
738 | $content
|
---|
739 | </li>";
|
---|
740 |
|
---|
741 | }else{
|
---|
742 | echo "<li><div><b>$title</b><br /></div>";
|
---|
743 |
|
---|
744 |
|
---|
745 | echo "<div class=\"message\">$preamble<br /><br /></div>";
|
---|
746 |
|
---|
747 | echo "<div class=\"message\">$content</div></li>";
|
---|
748 | }
|
---|
749 |
|
---|
750 |
|
---|
751 |
|
---|
752 | }
|
---|
753 | }
|
---|
754 | }
|
---|
755 |
|
---|
756 | }
|
---|
757 |
|
---|
758 |
|
---|
759 |
|
---|
760 | /****************
|
---|
761 | Funzione dati Generali
|
---|
762 | visuallizza la stringa dei dati generali
|
---|
763 | ****************/
|
---|
764 |
|
---|
765 |
|
---|
766 | function dati_mob($print) {
|
---|
767 | global $db,$prefix, $dbi, $votog, $votol, $votoc, $circo, $id_cons,$tipo_cons,$descr_cons,$id_cons_gen,$id_comune,$genere,$id_circ;
|
---|
768 | $print=intval($print);
|
---|
769 |
|
---|
770 | $sql="select * from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ";
|
---|
771 | $res = $dbi->prepare("$sql");
|
---|
772 | $res->execute();
|
---|
773 | $sql="select * from ".$prefix."_ele_sede where id_cons='$id_cons' ";
|
---|
774 | $ressede = $dbi->prepare("$sql");
|
---|
775 | $ressede->execute();
|
---|
776 | $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' ";
|
---|
777 | $res3 = $dbi->prepare("$sql");
|
---|
778 | $res3->execute();
|
---|
779 | $circo = $res->rowCount();
|
---|
780 | $sedi = $ressede->rowCount();
|
---|
781 | $sez = $res3->rowCount();
|
---|
782 |
|
---|
783 | //Variabili linguaggio
|
---|
784 | $DATIG=_DATIG;$AVENTI=_AVENTI;$MASCHI=_MASCHI;$FEMMINE=_FEMMINE;$SEZIONI=_SEZIONI; $GRUPPI=_GRUPPI;$CANDIDATI=_CANDIDATI;$LISTE=_LISTE;
|
---|
785 | if ($circo>1)$SEDE=_CIRCS; else $SEDE=_SEDI;
|
---|
786 |
|
---|
787 | $candi=0;
|
---|
788 |
|
---|
789 | // se non referendum
|
---|
790 | if ($genere!=0 and !$votoc){
|
---|
791 | $sql="select id_cons from ".$prefix."_ele_candidati where id_cons='$id_cons' ";
|
---|
792 | $res1 = $dbi->prepare("$sql");
|
---|
793 | $res1->execute();
|
---|
794 | $candi = $res1->rowCount();
|
---|
795 | }
|
---|
796 |
|
---|
797 | // se non europee (non liste e candidati)
|
---|
798 | if ($genere!=4){
|
---|
799 | $sql="select id_cons from ".$prefix."_ele_gruppo where id_cons='$id_cons' ";
|
---|
800 | }else{
|
---|
801 | $sql="select id_cons from ".$prefix."_ele_lista where id_cons='$id_cons' ";
|
---|
802 | }
|
---|
803 | $res2 = $dbi->prepare("$sql");
|
---|
804 | $res2->execute();
|
---|
805 |
|
---|
806 | $gruppo = $res2->rowCount();
|
---|
807 |
|
---|
808 | // camera e senato con raggruppamenti
|
---|
809 | //if($votog){
|
---|
810 | $sql="select * from ".$prefix."_ele_lista where id_cons='$id_cons' ";
|
---|
811 | $res3 = $dbi->prepare("$sql");
|
---|
812 | $res3->execute();
|
---|
813 | $liste = $res3->rowCount();
|
---|
814 | //}
|
---|
815 |
|
---|
816 | if($circo==1) $circo=$sedi;
|
---|
817 | $sql="select sum(maschi),sum(femmine), sum(maschi+femmine) from ".$prefix."_ele_sezioni where id_cons=$id_cons";
|
---|
818 | $res4 = $dbi->prepare("$sql");
|
---|
819 | $res4->execute();
|
---|
820 | if($res4) list($maschi,$femmine,$tot) = $res4->fetch(PDO::FETCH_NUM);
|
---|
821 |
|
---|
822 |
|
---|
823 |
|
---|
824 | $ris = array($tot,$maschi,$femmine,$circo,$sez,$gruppo,$candi,$liste);
|
---|
825 | return $ris;
|
---|
826 |
|
---|
827 |
|
---|
828 | }
|
---|
829 |
|
---|
830 | ####################################
|
---|
831 | ## funzione che richiama i dati generali
|
---|
832 | ## function dati_mob e li stampa
|
---|
833 |
|
---|
834 | function dati_mob_fun(){
|
---|
835 | $dati=dati_mob(0);
|
---|
836 | global $genere;
|
---|
837 | if($genere==0)$gruppo="Quesiti";else$gruppo="Gruppi";
|
---|
838 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
839 | echo "<b> <center>Dati Generali della consultazione </center></b></li>";
|
---|
840 | echo "<br/><div style=\"margin:0 auto;width:300px;\"><ul>";
|
---|
841 | echo "<li>Aventi Diritto: $dati[0]</li>";
|
---|
842 | echo "<li> Maschi: $dati[1]</li>";
|
---|
843 | echo "<li>Femmine: $dati[2]</li>";
|
---|
844 | if($dati[3]!=0) echo "<li>Num. Circoscrizioni: $dati[3]</li>";
|
---|
845 | echo "<li>Num: Sezioni: $dati[4]</li>";
|
---|
846 | if($dati[5]!=0)echo "<li>Num: $gruppo: $dati[5]</li>";
|
---|
847 | if($dati[6]!=0)echo "<li>Num. Candidati: $dati[6]</li>";
|
---|
848 | if($dati[7]!=0)echo "<li>Num. Liste: $dati[7]</li>";
|
---|
849 | echo "</ul></div>";
|
---|
850 | }
|
---|
851 |
|
---|
852 |
|
---|
853 |
|
---|
854 |
|
---|
855 | function circo_mob() {
|
---|
856 |
|
---|
857 | /******************************************************/
|
---|
858 | /*Funzione di visualizzazione sede */
|
---|
859 | /*****************************************************/
|
---|
860 | global $admin, $prefix, $dbi, $offset, $min,$id_cons,$file,$id_cons_gen,$id_comune ,$prev,$next;
|
---|
861 | $sql="SELECT * FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ";
|
---|
862 | $res = $dbi->prepare("$sql");
|
---|
863 | $res->execute();
|
---|
864 | $max = $res->rowCount();
|
---|
865 |
|
---|
866 | //OpenTable();
|
---|
867 |
|
---|
868 | dati();
|
---|
869 |
|
---|
870 |
|
---|
871 | $offset=10;
|
---|
872 | if (!isset($min)) $min=0;
|
---|
873 | $go="circo";
|
---|
874 |
|
---|
875 | $sql="select * from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ORDER BY num_circ
|
---|
876 | LIMIT $min,$offset";
|
---|
877 | $result = $dbi->prepare("$sql");
|
---|
878 | $result->execute();
|
---|
879 | $numcirc=$result->rowCount();
|
---|
880 | if ($numcirc>1){
|
---|
881 | echo "<div><b>"._CIRCS."</b></div><br /><br />
|
---|
882 | <table class=\"table-80\"><tr class=\"bggray\">"
|
---|
883 | ."<td ><b>"._NUM."</b></td>"
|
---|
884 | ."<td ><b>"._CIRCO."</b></td>"
|
---|
885 | ."<td ><b>"._INDIRIZZO."</b></td>"
|
---|
886 | ."<td><b>"._TEL."</b></td></tr>";
|
---|
887 | }else{
|
---|
888 | echo "<div><b></b></div><br /><br />
|
---|
889 | <table class=\"table-80\"><tr class=\"bggray\">"
|
---|
890 | ."<td ><b>"._INDIRIZZO."</b></td>"
|
---|
891 | ."<td><b>"._TEL."</b></td></tr>";
|
---|
892 | }
|
---|
893 |
|
---|
894 | while(list($id_cons2,$id_circ,$num_circ,$descr_circ) = $result->fetch(PDO::FETCH_NUM)) {
|
---|
895 | #if($numcirc==1) {$descr_circ=''; $num_circ='';}
|
---|
896 | if (!($num_circ===0)) {
|
---|
897 |
|
---|
898 | echo "<tr class=\"bggray3\">";
|
---|
899 | if ($numcirc>1) {
|
---|
900 | echo "<td><b>$num_circ</b>"
|
---|
901 | ."</td><td><b>";
|
---|
902 | echo "<a href=\"modules.php?name=Elezioni&op=sezione&id_cons_gen=$id_cons_gen&id_comune=$id_comune&id_circ=$id_circ&descr_circ=$descr_circ\">$descr_circ</a></b></td>";
|
---|
903 | }
|
---|
904 |
|
---|
905 | // dati sede
|
---|
906 | $sql="select id_sede,indirizzo,telefono1,telefono2, mappa, filemappa from ".$prefix."_ele_sede where id_cons='$id_cons' and id_circ='$id_circ'";
|
---|
907 | $result1 = $dbi->prepare("$sql");
|
---|
908 | $result1->execute();
|
---|
909 | $righe=$result1->rowCount();$i=0;
|
---|
910 | while(list($id_sede,$indir,$tel1,$tel2,$mappa,$filemappa)=$result1->fetch(PDO::FETCH_NUM)){
|
---|
911 |
|
---|
912 | $i++;
|
---|
913 | echo "<td><b><a href=\"modules.php?name=Elezioni&file=iphone&op=sezione&id_cons_gen=$id_cons_gen&id_comune=$id_comune&id_sede=$id_sede&indirizzo=$indir\">$indir</a></b>"
|
---|
914 | ."</td><td><b>$tel1 </b></td><td><b> $tel2</b></td></tr>";
|
---|
915 |
|
---|
916 | if ($i<$righe) echo"<tr class=\"bggray3\">";
|
---|
917 | if ($numcirc>1) echo "<td></td><td></td>";
|
---|
918 |
|
---|
919 | }
|
---|
920 | }
|
---|
921 | }
|
---|
922 | echo "</table>";
|
---|
923 |
|
---|
924 | //page($id_cons_gen,$go,$max,$min,$prev,$next,$offset,$file);
|
---|
925 |
|
---|
926 | //CloseTable();
|
---|
927 | }
|
---|
928 |
|
---|
929 | /******************************************************/
|
---|
930 | /*Funzione di visualizzazione globale sezioni */
|
---|
931 | /*****************************************************/
|
---|
932 |
|
---|
933 | function sezione_mob() {
|
---|
934 | global $admin, $prefix, $dbi, $offset, $min,$votog,$circo, $id_cons_gen,$id_circ,$descr_circ,$id_cons,$file,$prev,$next,$id_comune,$googlemaps;
|
---|
935 |
|
---|
936 | if(!isset($_GET['id_circ'])) unset($id_circ);
|
---|
937 | //dati();
|
---|
938 | $totali_t=0;$maschi_t=0;$femmine_t=0;
|
---|
939 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
940 | //mappa
|
---|
941 | if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede='0';
|
---|
942 | if (isset($param['indirizzo'])) $indirizzo=$param['indirizzo']; else $indirizzo='';
|
---|
943 | if ($id_sede!='0' && $googlemaps!='1'){
|
---|
944 |
|
---|
945 | echo "$indirizzo<br /><div><img src=\"modules.php?name=Elezioni&file=foto&id_sede=".$id_sede."\" alt=\"mappa\" /></div>";
|
---|
946 | }elseif($id_sede!='0' && $googlemaps=='1'){
|
---|
947 | echo "$indirizzo";
|
---|
948 | $mappa=googlemaps(); echo $mappa;
|
---|
949 | }
|
---|
950 |
|
---|
951 |
|
---|
952 | //CloseTable();
|
---|
953 | }
|
---|
954 |
|
---|
955 |
|
---|
956 | function genere(){
|
---|
957 | global $prefix,$db,$id_cons_gen;
|
---|
958 | $sql="SELECT descrizione,genere FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen' ";
|
---|
959 | $res = $dbi->prepare("$sql");
|
---|
960 | $res->execute();
|
---|
961 | list($descr_cons,$genere) = $res->fetch(PDO::FETCH_NUM);
|
---|
962 | //$descr_cons =stripslashes($descr_com);
|
---|
963 |
|
---|
964 |
|
---|
965 |
|
---|
966 | echo $genere;
|
---|
967 | }
|
---|
968 |
|
---|
969 |
|
---|
970 | ########################################################
|
---|
971 | # Affluenze
|
---|
972 | function affluenze_mob() {
|
---|
973 | global $bgcolor1, $bgcolor2, $prefix, $dbi, $offset,$genere,$votog,$votol,$votoc,$circo, $min,$id_cons,$tipo_cons,$id_cons_gen,$csv,$id_comune,$id_circ, $tema;
|
---|
974 | // icone
|
---|
975 | if ($circo) $circos="and t2.id_circ='$id_circ'";
|
---|
976 | else $circos="";
|
---|
977 | if (!$csv)
|
---|
978 |
|
---|
979 |
|
---|
980 | // numero sezioni scrutinate
|
---|
981 | //if ($circo)$circos="and id_circ='$id_circ'";
|
---|
982 | if (!isset($data1)) $data1='';
|
---|
983 | if (!isset($ora_ril)) $ora_ril='';
|
---|
984 | $sql="SELECT count(data) 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 t1.id_cons='$id_cons' and data='$data1' and orario='$ora_ril' $circos group by t3.id_gruppo";
|
---|
985 | $res1 = $dbi->prepare("$sql");
|
---|
986 | $res1->execute();
|
---|
987 | # mysql_query("select * from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' $circos group by id_sez ",$dbi);
|
---|
988 | $numero=$res1->rowCount();
|
---|
989 | $sql="SELECT t1.* FROM ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede $circos order by num_sez";
|
---|
990 | $res2 = $dbi->prepare("$sql");
|
---|
991 | $res2->execute();
|
---|
992 | #mysql_query("select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' $circos",$dbi);
|
---|
993 | $sezioni=$res2->rowCount();
|
---|
994 |
|
---|
995 |
|
---|
996 |
|
---|
997 |
|
---|
998 |
|
---|
999 | // barre
|
---|
1000 | $l_size = getimagesize("modules/Elezioni/images/barre/leftbar.gif");
|
---|
1001 | $m_size = getimagesize("modules/Elezioni/images/barre/mainbar.gif");
|
---|
1002 | $r_size = getimagesize("modules/Elezioni/images/barre/rightbar.gif");
|
---|
1003 | $l_size2 = getimagesize("modules/Elezioni/images/barre/leftbar2.gif");
|
---|
1004 | $m_size2 = getimagesize("modules/Elezioni/images/barre/mainbar2.gif");
|
---|
1005 | $r_size2 = getimagesize("modules/Elezioni/images/barre/rightbar2.gif");
|
---|
1006 | // totali
|
---|
1007 |
|
---|
1008 | if($tema=='tour') $andcond="select orario,data from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' order by data desc,orario desc limit 0,1";
|
---|
1009 | else $andcond="select orario,data from ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data,orario";
|
---|
1010 |
|
---|
1011 | $sql="$andcond";
|
---|
1012 | $res = $dbi->prepare("$sql");
|
---|
1013 | $res->execute();
|
---|
1014 | while(list($orario,$data) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
1015 | list ($ore,$minuti,$secondi)=explode(':',$orario);
|
---|
1016 | list ($anno,$mese,$giorno)=explode('-',$data);
|
---|
1017 | $tot_v_m=0;$tot_v_d=0;$tot_t=0;
|
---|
1018 |
|
---|
1019 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
1020 | echo "<center>"._VOTANTI." "._ALLE." "._ORE." $ore,$minuti "._DEL." $giorno/$mese/$anno</center></li>";
|
---|
1021 |
|
---|
1022 | $sql="SELECT count(data) 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 t1.id_cons='$id_cons' and data='$data' and orario='$orario' $circos group by t3.id_gruppo";
|
---|
1023 | $res1 = $dbi->prepare("$sql");
|
---|
1024 | $res1->execute();
|
---|
1025 | list($numero)=$res1->fetch(PDO::FETCH_NUM);
|
---|
1026 |
|
---|
1027 |
|
---|
1028 | $sql="select sum(t3.voti_complessivi), t4.num_gruppo , t4.id_gruppo 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 left join ".$prefix."_ele_gruppo as t4 on (t3.id_gruppo=t4.id_gruppo) where t3.id_cons='$id_cons' and t3.orario='$orario' and t3.data='$data' $circos group by t4.num_gruppo, t4.id_gruppo order by t4.num_gruppo ";
|
---|
1029 | $res1 = $dbi->prepare("$sql");
|
---|
1030 | $res1->execute();
|
---|
1031 |
|
---|
1032 |
|
---|
1033 |
|
---|
1034 |
|
---|
1035 | while(list($voti_t, $num_gruppo,$id_gruppo) = $res1->fetch(PDO::FETCH_NUM)) {
|
---|
1036 | /* $query="select sum(voti_complessivi) from ".$prefix."_ele_voti_parziale where orario='$orario' and data='$data' and id_cons='$id_cons'";
|
---|
1037 |
|
---|
1038 | if ($genere==0){$query.=" and id_gruppo=$id_gruppo";}
|
---|
1039 |
|
---|
1040 | $res_aff = $dbi->prepare("$query");
|
---|
1041 | $res_aff->execute();
|
---|
1042 | $voti_numero=$res_aff->rowCount();*/
|
---|
1043 | $query="SELECT sum(maschi+femmine) FROM ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede $circos";
|
---|
1044 |
|
---|
1045 |
|
---|
1046 | $res1234 = $dbi->prepare("$query");
|
---|
1047 | $res1234->execute();
|
---|
1048 | list($tot)=$res1234->fetch(PDO::FETCH_NUM);
|
---|
1049 |
|
---|
1050 | $perc=number_format($voti_t*100/$tot,2);
|
---|
1051 |
|
---|
1052 | echo "<li><table style=\"text-align:left;border : 1px solid Black;width:100%\"><tr>";
|
---|
1053 | if ($genere==0){echo "<td>Refer. N.</td>";}
|
---|
1054 | echo "<td><b>"._VOTANTI."</b></td><td><b>Percent.</b></td>";
|
---|
1055 | echo "<td><b>"._SEZIONI."</b></td>";
|
---|
1056 | echo "</tr>";
|
---|
1057 | echo "<tr>";
|
---|
1058 | if ($genere==0){echo "<td><h2>$num_gruppo</h2></td>";}
|
---|
1059 | echo "<td>$voti_t</td><td>$perc %</td><td>$numero</td>
|
---|
1060 | </tr></table>";
|
---|
1061 |
|
---|
1062 |
|
---|
1063 | // barre
|
---|
1064 |
|
---|
1065 | echo "<table style=\"width:100%\"><tr><td><table><tr><td> "._VOTANTI." : </td><td>
|
---|
1066 | <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=\"\" /> $perc% <br /></td></tr>\n";
|
---|
1067 |
|
---|
1068 | $tot_gen=$tot;
|
---|
1069 |
|
---|
1070 |
|
---|
1071 | 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>";
|
---|
1072 | echo "</td></tr></table></li><br/>";
|
---|
1073 |
|
---|
1074 | }
|
---|
1075 |
|
---|
1076 | }
|
---|
1077 |
|
---|
1078 |
|
---|
1079 | }
|
---|
1080 |
|
---|
1081 | ## risultati semplici
|
---|
1082 | function graf_risultati(){
|
---|
1083 | global $descr_cons,$circo,$genere;
|
---|
1084 |
|
---|
1085 | if($genere!='0' && !$circo){ // referendum e circoscrizionali
|
---|
1086 | list ($gruppo,$pro)=grupporss();
|
---|
1087 | if ($gruppo!=''){
|
---|
1088 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
1089 | echo "<center><h2>";
|
---|
1090 | echo "<b>Risultati</b> ";
|
---|
1091 | //echo "<i> "._SEZSCRU." $numero "._SU." $sezioni </i>";
|
---|
1092 | echo "</h2></center></li>";
|
---|
1093 | }
|
---|
1094 |
|
---|
1095 | //$content .="<div style=\"text-align:left;\"><strong>$descr_cons</strong></div><br/>";
|
---|
1096 | echo "<li><table bgcolor=\"gray\" width=\"100%\" cellspacing=\"1\">";
|
---|
1097 | for($x=0;$x<count($gruppo);$x++){
|
---|
1098 | $nume=$x+1;
|
---|
1099 | echo "<tr bgcolor=\"#ffffff\"><td>$nume - ".$gruppo[$x]." </td><td align=\"right\"><b><span style=\"color:#ff0000;\">".$pro[$x] ."%</span></b></td></tr>\n";
|
---|
1100 | }
|
---|
1101 | echo "</table></center>";
|
---|
1102 |
|
---|
1103 | }
|
---|
1104 |
|
---|
1105 | }
|
---|
1106 |
|
---|
1107 | ###############################
|
---|
1108 | # grafico affluenza unica
|
---|
1109 |
|
---|
1110 | function affluenza_unica(){
|
---|
1111 | global $dbi,$circo,$prefix,$id_cons,$genere,$id_circ,$id_comune,$id_cons_gen;
|
---|
1112 |
|
---|
1113 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
1114 | else $circos='';
|
---|
1115 | $circos='';
|
---|
1116 | // numero sezioni scrutinate
|
---|
1117 |
|
---|
1118 | $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'";
|
---|
1119 | $res2 = $dbi->prepare("$sql");
|
---|
1120 | $res2->execute();
|
---|
1121 | $sezioni=$res2->rowCount();
|
---|
1122 |
|
---|
1123 | $sql="select orario,data from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' order by data desc,orario desc limit 1";
|
---|
1124 | $res = $dbi->prepare("$sql");
|
---|
1125 | $res->execute();
|
---|
1126 | if($res){
|
---|
1127 |
|
---|
1128 | while(list($orario,$data) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
1129 | list ($ore,$minuti,$secondi)=explode(':',$orario);
|
---|
1130 | list ($anno,$mese,$giorno)=explode('-',$data);
|
---|
1131 | $tot_v_m=0;$tot_v_d=0;$tot_t=0;
|
---|
1132 |
|
---|
1133 |
|
---|
1134 | $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' group by t3.id_sez ";
|
---|
1135 | $res1 = $dbi->prepare("$sql");
|
---|
1136 | $res1->execute();
|
---|
1137 | $numero=$res1->rowCount();
|
---|
1138 |
|
---|
1139 | echo "<div style=\"text-align:center;\">Ultime Affluenze<br/>";
|
---|
1140 | echo "<b>"._ORE." $ore,$minuti "._DEL." $giorno/$mese/$anno</b></div>";
|
---|
1141 |
|
---|
1142 |
|
---|
1143 |
|
---|
1144 |
|
---|
1145 | $sql="select sum(t3.voti_complessivi), t4.num_gruppo , t4.id_gruppo 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 left join ".$prefix."_ele_gruppo as t4 on (t3.id_gruppo=t4.id_gruppo) where t3.id_cons='$id_cons' and t3.orario='$orario' and t3.data='$data' $circos group by t4.num_gruppo, t4.id_gruppo order by t4.num_gruppo ";
|
---|
1146 | $res1 = $dbi->prepare("$sql");
|
---|
1147 | $res1->execute();
|
---|
1148 |
|
---|
1149 |
|
---|
1150 |
|
---|
1151 | while(list($voti_t, $num_gruppo,$id_gruppo) = $res1->fetch(PDO::FETCH_NUM)) {
|
---|
1152 |
|
---|
1153 | $query="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";
|
---|
1154 | if ($genere==0){$query.=" and t3.id_gruppo=$id_gruppo";}
|
---|
1155 |
|
---|
1156 | $res_aff = $dbi->prepare("$query");
|
---|
1157 | $res_aff->execute();
|
---|
1158 | $voti_numero=$res_aff->rowCount();
|
---|
1159 |
|
---|
1160 | # $query="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' ";
|
---|
1161 |
|
---|
1162 | $query="SELECT sum(maschi+femmine) FROM ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede ";
|
---|
1163 |
|
---|
1164 | //if ($genere==0){$query.=" and t3.id_gruppo=$id_gruppo";}
|
---|
1165 | $tot='';
|
---|
1166 | $res1234 = $dbi->prepare("$query");
|
---|
1167 | $res1234->execute();
|
---|
1168 | list($tot)=$res1234->fetch(PDO::FETCH_NUM);
|
---|
1169 | if (isset($tot)){$perc=number_format($voti_t*100/$tot,2);}
|
---|
1170 | else{$tot=0;$perc="0.00";}
|
---|
1171 | if($voti_t<=$tot){
|
---|
1172 |
|
---|
1173 | $resto=100-$perc;
|
---|
1174 | if ($genere==0){echo "<div style=\"text-align:center\"><b>Referendum n. $num_gruppo</b></div>";}
|
---|
1175 |
|
---|
1176 | echo "<div style=\"margin:0 auto;width:300px;\"><img src=\"http://chart.apis.google.com/chart?
|
---|
1177 | chs=300x200
|
---|
1178 | &chd=t:$perc
|
---|
1179 | &cht=gom
|
---|
1180 | &chl=$perc%
|
---|
1181 | &chco=ff0000,ffff00 \"
|
---|
1182 | alt=\"Sample chart\" />
|
---|
1183 |
|
---|
1184 | </div>";
|
---|
1185 |
|
---|
1186 | }
|
---|
1187 |
|
---|
1188 | }
|
---|
1189 |
|
---|
1190 | }
|
---|
1191 | }
|
---|
1192 |
|
---|
1193 | }
|
---|
1194 |
|
---|
1195 |
|
---|
1196 | ###############################
|
---|
1197 | # votanti in tabella
|
---|
1198 |
|
---|
1199 | function votanti_tabella(){
|
---|
1200 |
|
---|
1201 | global $op, $prefix, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$tipo_cons,$id_comune,$id_cons_gen,$id_circ,$csv,$w,$l,$siteistat,$flash,$tour,$dbi;
|
---|
1202 |
|
---|
1203 |
|
---|
1204 |
|
---|
1205 |
|
---|
1206 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
1207 | else $circos='';
|
---|
1208 | $circos='';
|
---|
1209 | //if ($genere==0) $tab="ref";elseif($genere=='4' || $votog) $tab="lista";
|
---|
1210 | if($genere=='4' || $votog) $tab="lista";
|
---|
1211 | else $tab="gruppo";
|
---|
1212 | if ($genere==0) $tab="ref";
|
---|
1213 |
|
---|
1214 | $sql="select t3.id_sez from ".$prefix."_ele_voti_".$tab." 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' $circos group by t3.id_sez ";
|
---|
1215 | $res = $dbi->prepare("$sql");
|
---|
1216 | $res->execute();
|
---|
1217 | $numero=$res->rowCount();
|
---|
1218 | $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";
|
---|
1219 | $res = $dbi->prepare("$sql");
|
---|
1220 | $res->execute();
|
---|
1221 | $sezioni=$res->rowCount();
|
---|
1222 |
|
---|
1223 | if ($numero!=0){
|
---|
1224 |
|
---|
1225 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
1226 | echo "<center><b>"._DETTAGLIO." "._VOTIE."</b></center></li>";
|
---|
1227 | echo "<div style=\"text-align:center;\"><i> "._SEZSCRU." $numero "._SU." $sezioni </i></div>";
|
---|
1228 |
|
---|
1229 |
|
---|
1230 |
|
---|
1231 |
|
---|
1232 | if ($genere!=0) {
|
---|
1233 |
|
---|
1234 | $sql="select sum(t1.maschi+t1.femmine) 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' and validi>0 $circos";
|
---|
1235 | $res = $dbi->prepare("$sql");
|
---|
1236 | $res->execute();
|
---|
1237 | list($tot_aventi) = $res->fetch(PDO::FETCH_NUM);
|
---|
1238 |
|
---|
1239 | $sql="select sum(t1.validi+t1.nulli+t1.bianchi+t1.contestati) as tot,
|
---|
1240 | sum(t1.validi),sum(t1.nulli),sum(t1.bianchi),sum(t1.contestati), '0', '0', '0'
|
---|
1241 | 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' and validi>0 $circos";
|
---|
1242 | $res = $dbi->prepare("$sql");
|
---|
1243 | $res->execute();
|
---|
1244 |
|
---|
1245 | }else{
|
---|
1246 | $sql="SELECT sum(maschi+femmine) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'";
|
---|
1247 | $res = $dbi->prepare("$sql");
|
---|
1248 | $res->execute();
|
---|
1249 | list($tot_aventi) = $res->fetch(PDO::FETCH_NUM);
|
---|
1250 | $sql="SELECT sum(validi+nulli+bianchi+contestati) as tot,
|
---|
1251 | sum(validi),sum(nulli),sum(bianchi),sum(contestati), id_gruppo, sum(si), sum(no)
|
---|
1252 | from ".$prefix."_ele_voti_ref where id_cons=$id_cons group by id_gruppo having tot>'0'";
|
---|
1253 | $res = $dbi->prepare("$sql");
|
---|
1254 | $res->execute();
|
---|
1255 | }
|
---|
1256 |
|
---|
1257 | while (list($tot_votanti,$validi,$nulli,$bianchi,$contestati,$id,$si,$no) = $res->fetch(PDO::FETCH_NUM)){
|
---|
1258 | $tot_votanti=$validi+$bianchi+$nulli+$contestati;
|
---|
1259 | $arvoti=array($validi,$nulli,$bianchi,$contestati);
|
---|
1260 | $arperc=arrayperc($arvoti,$tot_votanti);
|
---|
1261 | if($tot_votanti){
|
---|
1262 | if($genere==0 and $validi) {$perc_si=number_format($si*100/$validi,2);$perc_no=number_format(100 - $si*100/$validi,2);}
|
---|
1263 | else {$perc_si="0.00"; $perc_no="0.00";}
|
---|
1264 | $perc_validi=number_format($arperc[0],2);#number_format($validi*100/$tot_votanti,2);
|
---|
1265 | $perc_nulli=number_format($arperc[1],2);
|
---|
1266 | $perc_bianchi=number_format($arperc[2],2);
|
---|
1267 | $perc_conte=number_format($arperc[3],2);
|
---|
1268 | }else {$perc_validi="0.00";$perc_nulli="0.00";$perc_bianchi="0.00";$perc_conte="0.00";}
|
---|
1269 | if($tot_aventi)
|
---|
1270 | $perc_votanti=number_format($tot_votanti*100/$tot_aventi,2);
|
---|
1271 | else $perc_votanti="0.00";
|
---|
1272 | $non_votanti=($tot_aventi - $tot_votanti);
|
---|
1273 | $perc_non=100-$perc_votanti;
|
---|
1274 |
|
---|
1275 | if ($genere==0) {
|
---|
1276 | $sql="SELECT num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id";
|
---|
1277 | $resg = $dbi->prepare("$sql");
|
---|
1278 | $resg->execute();
|
---|
1279 | list($num_gruppo,$descr_gruppo) = $resg->fetch(PDO::FETCH_NUM);
|
---|
1280 | }
|
---|
1281 |
|
---|
1282 |
|
---|
1283 |
|
---|
1284 |
|
---|
1285 | echo "<li><table bgcolor=\"gray\" width=\"100%\" cellspacing=\"1\">";
|
---|
1286 | if ($genere==0) {echo "<br/>Referendum n. <b>[$num_gruppo]</b><br/>";}
|
---|
1287 | echo "
|
---|
1288 | <tr bgcolor=\"#ffffff\"><td ><b>"._AVENTI."</b></td><td align=\"right\">$tot_aventi</td><td align=\"right\"><span class=\"red\">100.00%</span></td></tr>
|
---|
1289 |
|
---|
1290 | <tr bgcolor=\"#ffffff\"><td><b>"._VOTANTI."</b></td><td align=\"right\">$tot_votanti</td><td align=\"right\"><span class=\"red\">$perc_votanti%</span></td></tr>";
|
---|
1291 | if ($genere==0){
|
---|
1292 | echo "<tr bgcolor=\"#ffffff\"><td>"._SI."</td><td align=\"right\">$si</td><td align=\"right\"><span class=\"red\">$perc_si%</span></td></tr>
|
---|
1293 |
|
---|
1294 | <tr bgcolor=\"#ffffff\"><td>"._NO."</td><td align=\"right\">$no</td><td align=\"right\"><span class=\"red\">$perc_no%</span></td></tr>";
|
---|
1295 | }
|
---|
1296 | echo "<tr bgcolor=\"#ffffff\"><td>"._VALIDI."</td><td align=\"right\">$validi</td><td align=\"right\"><span class=\"red\">$perc_validi%</span></td></tr>
|
---|
1297 |
|
---|
1298 | <tr bgcolor=\"#ffffff\"><td>"._NULLI."</td><td align=\"right\">$nulli</td><td align=\"right\"><span class=\"red\">$perc_nulli%</span></td></tr>
|
---|
1299 |
|
---|
1300 | <tr bgcolor=\"#ffffff\"><td>"._BIANCHI."</td><td align=\"right\">$bianchi</td><td align=\"right\"><span class=\"red\">$perc_bianchi%</span></td></tr>
|
---|
1301 |
|
---|
1302 | <tr bgcolor=\"#ffffff\"><td>"._CONTESTATI."</td><td align=\"right\">$contestati</td><td align=\"right\"><span class=\"red\">$perc_conte%</span></td></tr>
|
---|
1303 |
|
---|
1304 | </table></li>";
|
---|
1305 |
|
---|
1306 | }
|
---|
1307 | }
|
---|
1308 | }
|
---|
1309 |
|
---|
1310 |
|
---|
1311 |
|
---|
1312 | ######## fine
|
---|
1313 |
|
---|
1314 |
|
---|
1315 |
|
---|
1316 |
|
---|
1317 |
|
---|
1318 |
|
---|
1319 | ####################################
|
---|
1320 | # grafico sezioni
|
---|
1321 |
|
---|
1322 | function graf_sezioni(){
|
---|
1323 | global $prefix, $dbi,$id_cons_gen;
|
---|
1324 | $sql = "select chiusa from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen'";
|
---|
1325 | $res = $dbi->prepare("$sql");
|
---|
1326 | $res->execute();
|
---|
1327 | list($chiusa) = $res->fetch(PDO::FETCH_NUM);
|
---|
1328 |
|
---|
1329 | //if($chiusa!='1') numeri_sezione(); # se la consultazione non Ú chiusa
|
---|
1330 |
|
---|
1331 |
|
---|
1332 |
|
---|
1333 | //numeri_sezione(); //lancia la funzione
|
---|
1334 |
|
---|
1335 | function numeri_sezione() {
|
---|
1336 | global $prefix, $dbi, $circo, $genere,$id_cons_gen,$id_cons,$id_circ,$tipo_cons,$votog,$id_comune;
|
---|
1337 |
|
---|
1338 |
|
---|
1339 | if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
|
---|
1340 | else $circos='';
|
---|
1341 |
|
---|
1342 | if ($genere==0) $tab="ref";elseif($genere=='4' || $votog) $tab="lista";
|
---|
1343 | else $tab="gruppo";
|
---|
1344 |
|
---|
1345 |
|
---|
1346 |
|
---|
1347 | # numero sezioni
|
---|
1348 | $sql="select t1.id_sez,t1.num_sez 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 order by t1.num_sez";
|
---|
1349 | $res = $dbi->prepare("$sql");
|
---|
1350 | $res->execute();
|
---|
1351 | $max = $res->rowCount();
|
---|
1352 | if(!isset($html)) $html='';
|
---|
1353 | $html = "\n<table style=\"margin:0px auto;border:0px; width:90%\"><tr>";
|
---|
1354 |
|
---|
1355 | $i=0;$id_circ_old=0;$e=0;
|
---|
1356 | while(list($sez_id, $sez_num) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
1357 | $i++;
|
---|
1358 |
|
---|
1359 | $sql="select * from ".$prefix."_ele_voti_".$tab." where id_sez='$sez_id'";
|
---|
1360 | $res2 = $dbi->prepare("$sql");
|
---|
1361 | $res2->execute();
|
---|
1362 | $numero=$res2->rowCount();
|
---|
1363 | if ($numero!=0){$e++;$bgsez="#FFFF00";}else{$bgsez="";}
|
---|
1364 |
|
---|
1365 |
|
---|
1366 | if ($genere==0) $pos="gruppo_sezione";elseif($genere=='4' || $votog) $pos="lista_sezione";
|
---|
1367 | else $pos="gruppo_sezione";
|
---|
1368 |
|
---|
1369 | //$html .="<td style=\"margin:0px auto; text-align:center; width:5%;\" bgcolor=\"$bgsez\"><a href=\"modules.php?id_cons_gen=$id_cons_gen&name=Elezioni&id_comune=$id_comune&perc=true&file=index&op=$pos&minsez=$sez_num&offsetsez=$sez_num\"><b>$sez_num</b></a></td>";
|
---|
1370 | $html .="<td style=\"margin:0px auto; text-align:center; width:5%;\" bgcolor=\"$bgsez\"><b>$sez_num</b></td>";
|
---|
1371 |
|
---|
1372 | if (($i%8) ==0) $html .="</tr>\n<tr>";
|
---|
1373 | }
|
---|
1374 |
|
---|
1375 | $html .="</tr></table>\n";
|
---|
1376 | // stampa
|
---|
1377 | if($e!='0'){
|
---|
1378 | echo "<li data-role=\"list-divider\" data-icon=\"arrow-up\" >";
|
---|
1379 | echo "<center>";
|
---|
1380 | echo "<b>"._SEZSCRU."</b> ";
|
---|
1381 | echo "</center></li><br/></center>";
|
---|
1382 | echo "<center><img alt=\"Grafico\" src=\"modules/Elezioni/grafici/ledex2.php?sez=$e&max=$max\" /></center>";
|
---|
1383 |
|
---|
1384 | echo $html; }
|
---|
1385 | }
|
---|
1386 | numeri_sezione(); //lancia la funzione
|
---|
1387 | }
|
---|
1388 |
|
---|
1389 | ?>
|
---|
1390 |
|
---|
1391 |
|
---|