source: trunk/client/modules/Elezioni/gruppo.php@ 347

Last change on this file since 347 was 347, checked in by roby, 4 years ago

Aggiornamento per compatibilità con php7.4

File size: 46.1 KB
Line 
1<?php
2/************************************************************************/
3/* Eleonline - Raccolta e diffusione dei dati elettorali */
4/* by Luciano Apolito & Roberto Gigli */
5/* http://www.eleonline.it */
6/* info@eleonline.it rgigli@libero.it */
7/************************************************************************/
8
9if (!defined('MODULE_FILE')) {
10 die ("You can't access this file directly...");
11}
12if ($xls=='1' or $pdf=='1') {
13include_once("modules/Elezioni/language/lang-$lang.php");
14include_once("modules/Elezioni/funzioni.php");
15}
16$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ?
17 $_GET : $_POST;
18
19if (isset($param['id_cons_gen'])) $id_cons_gen=intval($param['id_cons_gen']); else $id_cons_gen='';
20//if (isset($param['op'])) $op=$param['op']; else $op='';
21if (isset($param['minsez'])) $minsez=intval($param['minsez']); else $minsez='';
22if (isset($param['id_lista'])) $id_lista=intval($param['id_lista']); else $id_lista='';
23if (isset($param['id_circ'])) $id_circ=intval($param['id_circ']); else $id_circ='';
24if (isset($param['csv'])) $csv=intval($param['csv']); else $csv='';
25if (isset($param['min'])) $min=intval($param['min']); else $min= 0;
26if (isset($param['orvert'])) $orvert=intval($param['orvert']); else $orvert='';
27if (isset($param['offset'])) $offset=intval($param['offset']); else $offset='';
28if (isset($param['offsetsez'])) $offsetsez=intval($param['offsetsez']); else $offsetsez='';
29if (isset($param['perc'])) $perc=$param['perc']; else $perc='';
30if (isset($param['info'])) $info=addslashes($param['info']); else $info='';
31if (isset($param['files'])) $files=addslashes($param['files']); else $files='';
32if (isset($param['voti_lista'])) $voti_lista=intval($param['voti_lista']); else $voti_lista= 0;
33if (isset($param['perc_lista'])) $perc_lista=$param['perc_lista']; else $perc_lista= 0;
34if (isset($param['lettera'])) $lettera=addslashes($param['lettera']); else $lettera='';
35if (isset($param['id_gruppo'])) $id_gruppo=intval($param['id_gruppo']); else $id_gruppo='';
36#if (isset($param['tipo_cons'])) $tipo_cons=intval($param['tipo_cons']); else $tipo_cons='';
37if (isset($param['pdf'])) $pdf=intval($param['pdf']); else $pdf='';
38if (isset($param['orienta'])) $orienta=addslashes($param['orienta']); else $orienta='';
39if (isset($param['datipdf'])) $datipdf=addslashes($param['datipdf']); else $datipdf='';
40if (isset($param['formato'])) $formato=addslashes($param['formato']); else $formato='';
41# anti-xss nov. 2009
42$id_comune=htmlentities($id_comune);
43$id_comune=intval($id_comune);
44$perc=htmlentities($perc);
45$perc_lista=floatval($perc_lista);
46#$datipdf= htmlentities($datipdf);
47$op= htmlentities($op);
48$info= htmlentities($info);
49$files=htmlentities($files);
50$lettera=htmlentities($lettera);
51$orienta=htmlentities($orienta);
52$formato=htmlentities($formato);
53
54
55
56
57
58include("crea_pagina.php");
59
60$sql="SELECT descrizione from ".$prefix."_ele_comuni where id_comune='$id_comune'" ;
61$res = $dbi->prepare("$sql");
62$res->execute();
63
64list($descr_comune) = $res->fetch(PDO::FETCH_NUM);
65
66$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' ";
67$res = $dbi->prepare("$sql");
68$res->execute();
69
70list($descr_cons,$tipo_cons,$genere,$votog,$votol,$votoc,$circo) = $res->fetch(PDO::FETCH_NUM);
71$sql="SELECT t2.id_cons,t2.solo_gruppo,t2.disgiunto 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'" ;
72$res = $dbi->prepare("$sql");
73$res->execute();
74
75list($id_cons,$dettnulli,$disgiunto) = $res->fetch(PDO::FETCH_NUM);
76
77
78
79
80
81
82
83////////////////////////////////////////////////////////////
84// Visualizza i dati per liste, gruppi e referendum, per sezione o circoscrizione
85////////////////////////////////////////////////////////////
86
87function gruppo_circo(){
88 global $prefix, $dbi, $descr_cons, $id_cons, $id_cons_gen,$tipo_cons,$votog,$votol,$votoc,$circo, $genere,$id_gruppo,$id_lista,$bgcolor1,$bgcolor2,$id_comune,$descr_comune,$id_circ;
89 global $id_comune,$id_cons_gen,$op,$minsez,$id_lista,$id_circ,$csv,$min,$orienta,$formato,$dettnulli,$disgiunto,
90 $orvert,$offset,$offsetsez,$perc,$info,$files,$nomefile;
91 $nomefile="";
92 #Denominazione pagine
93 if($op=="gruppo_circo") $pagina=_GRUPPO." "._PER." "._CIRCO;
94 if($op=="gruppo_sezione") $pagina=_GRUPPO." "._PER." "._SEZIONI;
95 if($op=="lista_circo") $pagina=_LISTA." "._PER." "._CIRCO;
96 if($op=="lista_sezione") $pagina=_LISTA." "._PER." "._SEZIONI;
97 if($op=="candidato_circo") $pagina=_CONSI." "._PER." "._CIRCO;
98 if($op=="candidato_sezione") $pagina=_CONSI." "._PER." "._SEZIONI;
99 if($op=="consiglieri") $pagina=_CALCONS;
100 if (strstr( $op,'circo')) { //$op=='gruppo_circo' or $op=='lista_circo') {
101 $tab1="circ";
102 $tab2="t5.num_circ,t5.descrizione";
103 $tab3="t5.num_circ";
104 $tipo1=_DA." "._CIRCO;
105 $tipo2=_CIRCOS;
106 $tipo3=_CIRCO;
107 }else{
108 $tab1="sez";
109 $tab2="t3.num_sez,''";
110 $tab3="t3.num_sez";
111 $tipo1=_DA." "._SEZIONE;
112 $tipo2=_SEZIONI;
113 $tipo3=_SEZIONE;
114 }
115 if (strstr( $op,"gruppo")){
116 $tab="gruppo";
117 }elseif (strstr( $op,'lista')) {
118 $tab="lista";
119 }else{
120 $tab="candidati";
121 }
122 if ($orvert) {
123 $righe='';
124 $colonne='checked';
125 }else{
126 $righe='checked';
127 $colonne='';
128 }
129
130 if ($orienta) {
131 $land='';
132 $port='checked';
133 }else{
134 $land='checked';
135 $port='';
136 }
137
138 if ($formato) {
139 $A3='';
140 $A4='checked';
141 }else{
142 $A3='checked';
143 $A4='';
144 }
145
146
147
148 if ($genere>0) { //se non e' un referendum
149
150
151 $voticompl=0;
152 if (!($offset)) $offset=25;
153 if (!($min)) $min=1;
154 if (!($offsetsez)) $offsetsez=22;
155 if (!($minsez)) $minsez=1;
156 if ($min>$offset) {
157 $appo=$min;
158 $min=$offset;
159 $offset=$appo;
160 }
161 if ($minsez>$offsetsez) {
162 $appo=$minsez;
163 $minsez=$offsetsez;
164 $offsetsez=$appo;
165 }
166 if (!$csv){
167 echo "<form id=\"voti\" method=\"post\" action=\"modules.php\">";
168 echo "<div><input type=\"hidden\" name=\"pag\" value=\"modules.php?name=Elezioni&amp;op=$op&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;id_circ=$id_circ&amp;id_lista=\"></input>";
169 echo "<input type=\"hidden\" name=\"pagina\" value=\"modules.php?name=Elezioni&amp;op=$op&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;id_circ=\"></input>";
170 }
171 $condcirc='';
172 if ($circo){ //gestione circoscrizionali
173 if(!$id_circ){
174 $sql="SELECT id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons and num_circ=1";
175 $res_cir = $dbi->prepare("$sql");
176 $res_cir->execute();
177 //se non si e' scelta una circoscr. prende la prima
178 list($id_circ)=$res_cir->fetch(PDO::FETCH_NUM);
179 }
180 $sql="SELECT num_circ from ".$prefix."_ele_circoscrizione where id_circ=$id_circ";
181 $res_cir = $dbi->prepare("$sql");
182 $res_cir->execute();
183 //estrae il numero della circoscrizione
184 list($num_circ)=$res_cir->fetch(PDO::FETCH_NUM);
185 $condcirc="and id_circ=$id_circ"; //variabile aggiunta nelle select per le circ.
186 $sql="SELECT count(t1.num_sez),min(t1.num_sez),max(t1.num_sez) from ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons=$id_cons and t1.id_sede=t2.id_sede and t2.id_circ=$id_circ";
187 $res_sez = $dbi->prepare("$sql");
188 $res_sez->execute();
189 //numero di sezioni nella circoscrizione
190 $sql="SELECT min(t1.num_sez) from ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons=$id_cons and t1.id_sede=t2.id_sede and t2.id_circ=$id_circ";
191 $res_min = $dbi->prepare("$sql");
192 $res_min->execute();
193 //setta minsez sulla prima sezione della circoscrizione
194 list($minsez)=$res_min->fetch(PDO::FETCH_NUM);
195 }
196 elseif (strstr( $op,'circo')){
197 $sql="SELECT count(num_circ),min(num_circ),max(num_circ) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons";
198 $res_sez = $dbi->prepare("$sql");
199 $res_sez->execute();
200 }
201 else{
202 $sql="SELECT count(num_sez),min(num_sez),max(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons";
203 $res_sez = $dbi->prepare("$sql");
204 $res_sez->execute();
205 }
206 if($res_sez->rowCount()) list($tot_sez,$numsezmin,$numsezmax)=$res_sez->fetch(PDO::FETCH_NUM);
207 else {$tot_sez=0;$numsezmin=0;$numsezmax=0;}
208 $sql="SELECT count(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons";
209 $res_sez = $dbi->prepare("$sql");
210 $res_sez->execute();
211
212 list($tuttelesez)=$res_sez->fetch(PDO::FETCH_NUM);
213
214 $num_sez=$tot_sez;//mysql_data_seek($res_sez,0);
215 if ($circo) $offsetsez=$numsezmax; //$num_sez+$minsez-1;//setta offsetsez sull'ultima sezione della circoscrizione
216
217 $visvot='';
218
219 if (!$csv) echo "<div><h5>$pagina</h5></div>";
220 if (!$csv) echo "<div style=\" text-align:left; margin-left:20px;\">";
221
222 if(strstr( $op,'candidato')){
223// $numliste=mysql_num_rows($res_lis);
224 $visvot="cand";
225 if (!$csv){
226 $sql="SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $condcirc order by num_lista";
227 $res_lis = $dbi->prepare("$sql");
228 $res_lis->execute();
229
230 //elenco delle liste per la scelta
231 echo "<p>"._SCEGLI_LISTA.":
232 <select name=\"id_lista\" class=\"modulo\" onChange=\"top.location.href=this.form.pag.value+this.form.id_lista.options[this.form.id_lista.selectedIndex].value;return false\">";
233 while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) {
234 if (!$id_lista) $id_lista=$id_rif;
235 $sel = ($id_rif == $id_lista) ? "selected=\"selected\"" : "";
236 echo "<option value=\"$id_rif\" $sel>";
237 for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
238 echo $num_lis.") ".$descrizione."</option>";
239 }
240 echo "</select></p>";
241 }
242 $sql="SELECT count(t1.id_sez) from ".$prefix."_ele_voti_$tab as t1, ".$prefix."_ele_$tab as t2 where t2.id_lista=$id_lista and t1.id_cand=t2.id_cand group by t1.id_cand";
243 $res_scr = $dbi->prepare("$sql");
244 $res_scr->execute();
245
246 $sqlc="SELECT id_cand, concat(cognome,' ', nome), num_cand from ".$prefix."_ele_$tab where id_cons=$id_cons and id_lista=$id_lista order by num_cand";
247 $res_cand = $dbi->prepare("$sqlc");
248 $res_cand->execute();
249
250 if ($circo) $condcirc="and t5.id_circ=$id_circ";
251
252 $sqlvoti="select $tab2, t1.num_cand, concat(t1.cognome,' ', t1.nome) as nome, sum(t2.voti),'','','','',''
253 from ".$prefix."_ele_candidati as t1, ".$prefix."_ele_voti_candidati as t2, "
254 .$prefix."_ele_sezioni as t3, ".$prefix."_ele_sede as t4, ".$prefix."_ele_circoscrizione as t5
255 where t1.id_lista=$id_lista
256 and t1.id_cons=$id_cons
257 and t1.id_cand=t2.id_cand
258 and t2.id_sez=t3.id_sez
259 and t3.id_sede=t4.id_sede
260 and t4.id_circ=t5.id_circ $condcirc
261 group by t1.num_cand,$tab2, t1.cognome,t1.nome
262 order by $tab3,t1.num_cand";
263 $res_voti = $dbi->prepare("$sqlvoti");
264 $res_voti->execute();
265 }else{
266 if (!$csv)
267 echo "<input type=\"hidden\" name=\"id_lista\" value=\"\"></input>";
268
269 // camera e senato nel 2006 aggiunte le somme della coalizione
270 // divise per circo e sez. in quanto nella tabella del gruppo
271 // all'atto dell'immsione non viene fatta la somma
272 // quindi leggere prima i voti di lista e poi agganciali al gruppo
273 // la var $tab diviene lista, $tab15 diviene gruppo in caso di somma
274 // dei voti di lista...oltre naturalmnte alle condizioni messe in variabile
275 // 4 aprile 2006 by luc
276 if ($votog && $tab=="gruppo"){ // camera e senato 2006
277 $t="t9";
278 $tab="lista";
279 $tab15="gruppo";
280 $add_1= ",".$prefix."_ele_gruppo as t9";
281 $and_1="and t1.id_gruppo=t9.id_gruppo";
282 }else{
283 $t="t1";
284 $tab15=$tab;
285 $add_1='';
286 $and_1='';
287 }
288 // fine della modifica
289
290 $sql="SELECT count(id_sez) from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons' group by id_$tab15";
291 $res_scr = $dbi->prepare("$sql");
292 $res_scr->execute();
293 //numero sezioni scrutinate
294 $sqlc="SELECT id_$tab15, descrizione, num_$tab15 from ".$prefix."_ele_$tab15 where id_cons='$id_cons' $condcirc order by num_$tab15";
295 $res_cand = $dbi->prepare("$sqlc");
296 $res_cand->execute();
297
298 if ($circo) $condcirc="and t5.id_circ=$id_circ";
299 if ($tab=="gruppo" or $genere==4 or ($genere==5 and $votog))
300 $votigl=" sum(t3.validi),sum(t3.nulli),sum(t3.bianchi),sum(t3.contestati),sum(t3.voti_nulli)";
301 else
302 if ($votog) $votigl=" (t3.validi_lista),(t3.nulli),(t3.bianchi),(t3.contestati),(t3.voti_nulli)";
303 else $votigl=" sum(t3.validi_lista),sum(t3.nulli),sum(t3.bianchi),sum(t3.contestati_lista),sum(t3.voti_nulli_lista+t3.voti_nulli)";
304 $sqlvoti="select $tab2, $t.num_$tab15, $t.descrizione, sum(t2.voti), $votigl
305 from
306 ".$prefix."_ele_$tab as t1,
307 ".$prefix."_ele_voti_$tab as t2,
308 ".$prefix."_ele_sezioni as t3,
309 ".$prefix."_ele_sede as t4,
310 ".$prefix."_ele_circoscrizione as t5
311 $add_1
312
313 where t1.id_cons=$id_cons
314 and t1.id_$tab=t2.id_$tab
315 $and_1
316
317 and t2.id_sez=t3.id_sez
318 and t3.id_sede=t4.id_sede
319 and t4.id_circ=t5.id_circ $condcirc
320
321
322 group by $t.num_$tab15,$tab3,$tab2, $t.descrizione
323 order by $tab3,$t.num_$tab15";
324 $res_voti = $dbi->prepare("$sqlvoti");
325 $res_voti->execute();
326 }
327 if ($res_scr) list($tot_scr)=$res_scr->fetch(PDO::FETCH_NUM);else $tot_scr=0;
328 if ($res_cand) $num_cand=$res_cand->rowCount(); else $num_cand=0;
329 if(!$circo){
330 if (!(0 < $minsez and $minsez<=$numsezmax)) $minsez=1;
331 if (!(0<$offsetsez and $offsetsez<=$numsezmax)) $offsetsez=$numsezmax;
332 }
333 if (!(0 < $min and $min<=$num_cand)) $min=1;
334 if (!(0<$offset and $offset<=$num_cand)) $offset=$num_cand;
335 if (!$csv) {
336 if(strstr( $op,'lista')){$scelta=_SCEGLI_LISTA;}else{$scelta=_SCEGLI_CANDI;}
337 echo "<p>$scelta "._DA.":&nbsp; <select name=\"min\" class=\"modulo\">";
338 while(list($id_rif,$descrizione,$num_lis) = $res_cand->fetch(PDO::FETCH_NUM)) {
339 if (!$min) $min=$num_lis;
340 $sel = ($num_lis == $min) ? "selected=\"selected\"" : "";
341 echo "<option value=\"$num_lis\" $sel>";
342 for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
343 echo $num_lis.") ".$descrizione."</option>";
344 }
345 echo "</select>";
346 echo "&nbsp;&nbsp;"._A.":&nbsp; <select name=\"offset\" class=\"modulo\">";
347 $res_cand = $dbi->prepare("$sqlc");
348 $res_cand->execute();
349
350 while(list($id_rif,$descrizione,$num_lis) = $res_cand->fetch(PDO::FETCH_NUM)) {
351 if (!$offset) $offset=$num_lis;
352 $sel = ($num_lis == $offset) ? "selected=\"selected\"" : "";
353 echo "<option value=\"$num_lis\" $sel>";
354 for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
355 echo $num_lis.") ".$descrizione."</option>";
356
357 }
358 echo "</select></p>";
359 //echo "<div style=\"text-align:left; margin-left:20px;\">";
360 if(!$circo){
361 echo "<p>"._SCEGLI." $tipo1 n. <input name=\"minsez\" value=\"$minsez\" size=\"4\" ></input>";
362 echo _A." n. <input name=\"offsetsez\" value=\"$offsetsez\" size=\"4\" ></input> (max. $numsezmax)";
363 }
364 # pagine
365############
366 if(!$offsetsez) $offsetsez=0;
367 if (strstr( $op,'circo'))
368 $sql="SELECT count(num_circ) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons and num_circ>=$minsez and num_circ<=$offsetsez";
369
370
371 else
372 $sql="SELECT count(num_sez) from ".$prefix."_ele_sezioni where id_cons=$id_cons and num_sez>=$minsez and num_sez<=$offsetsez";
373 $resnsez = $dbi->prepare("$sql");
374 $resnsez->execute();
375 list($diff)=$resnsez->fetch(PDO::FETCH_NUM);
376 ########
377 # $diff=($offsetsez-$minsez);
378 if ($minsez>1 and !$circo){
379 $minsez_p= ($minsez-$diff)>1 ? $minsez-$diff:1;
380 $offsetsez_p=$offsetsez-$diff;
381 echo "<div style=\"float: right; width:200px;margin-left:10px;margin-right:400px;font-size:12px \"><a href=\"modules.php?name=Elezioni&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;op=$op&amp;min=$min&amp;offset=$offset&amp;minsez=$minsez_p&amp;offsetsez=$offsetsez_p&amp;perc=$perc&amp;id_lista=$id_lista\"> <- $tipo2 Precedenti</a></div>";
382 }else{echo "";}
383 if ($offsetsez<$numsezmax){
384 $minsez_s=$minsez+$diff;
385 $offsetsez_s= ($offsetsez+$diff)>$num_sez ? $num_sez: $offsetsez+$diff;
386 echo "<div style=\"float: left; width:200px; margin-left:10px;\"><a href=\"modules.php?name=Elezioni&amp;file=index&amp;op=$op&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;orvert=$orvert&amp;min=$min&amp;offset=$offset&amp;minsez=$minsez_s&amp;offsetsez=$offsetsez_s&amp;perc=$perc&amp;id_lista=$id_lista\"> $tipo2 Successive -></a></div>";
387 }else{echo "";}
388 if(!$circo)
389 echo "<div style=\"margin-left:10px;\"><br/>"._MOSTRA." $tipo2 "._PERCOL."<input type=\"radio\" name=\"orvert\" $righe value=\"0\"></input>"._PERRIGHE." <input
390 type=\"radio\" name=\"orvert\" $colonne value=\"1\"></input>";
391 echo "<input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input></div>";
392 echo "<p>";
393 if (!strstr( $op,'candidato')) {
394 echo ""._VIS_PERC.": <input type=\"checkbox\" name=\"perc\" value=\"true\"";
395 if($perc=='true') echo " checked=\"true\"";
396 echo "></input><br/>";
397 }
398 echo "";
399 if($circo)
400 echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"></input>";
401 echo "<input type=\"hidden\" name=\"op\" value=\"$op\"></input>";
402 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"></input>";
403 echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>";
404
405 echo "<input type=\"hidden\" name=\"pag2\" value=\"modules.php?name=Elezioni&amp;op=$op&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;csv=1&amp;orvert=$orvert&amp;min=$min&amp;offset=$offset&amp;minsez=$minsez&amp;offsetsez=$offsetsez&amp;perc=$perc&amp;id_lista=\"></input>";
406
407 echo " <input type=\"submit\" name=\"update\" value=\""._RICARICA."\"></input></p></div></form>";
408
409
410 #### recupera dati stampa supporti diversi dati
411 //echo "</tr><tr><td><b>"._COMUNE." $descr_comune</b> - "._RISULTATI.": $descr_cons <br/>";
412 //echo "tot:$tot_scr";
413 //if ($tipo_cons!=4 && $tot_scr) echo " - Sezioni scrutinate: $tot_scr su $tuttelez";
414
415 # liste e gruppi da.... a
416 if (!strstr( $op,'candidato')) {
417 $sql="SELECT descrizione from ".$prefix."_ele_$tab15 where id_cons='$id_cons' and num_$tab15 ='$min'";
418 $res_cand2 = $dbi->prepare("$sql");
419 $res_cand2->execute();
420
421 list($descrizione)= $res_cand2->fetch(PDO::FETCH_NUM);
422 $list1 ="da $descrizione ";
423
424
425
426 $sql="SELECT descrizione from ".$prefix."_ele_$tab15 where id_cons='$id_cons' and num_$tab15 ='$offset'";
427 $res_cand3 = $dbi->prepare("$sql");
428 $res_cand3->execute();
429
430 list($descrizione)= $res_cand3->fetch(PDO::FETCH_NUM);
431 $list1 .=" a $descrizione <br/>";
432
433 }else{$list1='';}
434
435 # nome della lista
436 if (!isset($list2)) $list2='';
437 if (strstr( $op,'candidato')) {
438 $sql="SELECT num_lista, descrizione from ".$prefix."_ele_lista where id_lista=$id_lista";
439 $res_lis2 = $dbi->prepare("$sql");
440 $res_lis2->execute();
441
442 list($num_lista2,$descr_lista2)= $res_lis2->fetch(PDO::FETCH_NUM);
443 $nomefile=" Lista n. $num_lista2 - $descr_lista2 ";
444 $list2 .=" Lista n. $num_lista2 - $descr_lista2 <br/>";
445
446 $sql="SELECT concat(cognome,' ', nome) from ".$prefix."_ele_$tab where id_cons=$id_cons and id_lista=$id_lista and num_cand=$min";
447 $res_cand4 = $dbi->prepare("$sql");
448 $res_cand4->execute();
449
450 list($descrizione)= $res_cand4->fetch(PDO::FETCH_NUM);
451 $list3 ="da $descrizione ";
452 $sql="SELECT concat(cognome,' ', nome) from ".$prefix."_ele_$tab where id_cons=$id_cons and id_lista=$id_lista and num_cand=$offset";
453 $res_cand5 = $dbi->prepare("$sql");
454 $res_cand5->execute();
455
456 list($descrizione)= $res_cand5->fetch(PDO::FETCH_NUM);
457 $list3 .="a $descrizione <br/>";
458
459 }else{ $list2 .='';$list3='';}
460 if(!isset($tab15)) $tab15='';
461 $nomefile.="$descr_cons $tab15";
462 $_SESSION['nomefile']=strip_tags(str_replace(" ", "_", $nomefile));
463 $datipdf="<b>"._COMUNE." $descr_comune</b> - "._RISULTATI.": $descr_cons<br/><b>$pagina</b><br/><br/> $list1 $list2 $list3 ";
464# verificare la stampa sulle circoscrizioni
465 echo "<div style=\"text-align:right;width:65%;margin-left:10px;margin-right:0px;font-size:12px; \">";
466 echo "<table style=\"text-align:center;margin-right:0px;border-top : 1px solid Blue;width: 280px;\"><tr style=\" background:#eceff5;\"><td>"._ESPORTA."<br />";
467 if($circo){ echo "<a href=\"modules.php?name=Elezioni&amp;op=$op&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;csv=1&amp;orvert=$orvert&amp;min=$min&amp;offset=$offset&amp;minsez=$minsez&amp;offsetsez=$offsetsez&amp;perc=$perc&amp;id_lista=$id_lista&amp;id_circ=$id_circ&amp;datipdf=$datipdf\" ><img class=\"image\" src=\"modules/Elezioni/images/printer.gif\" alt=\"Stampa\" /></a>";
468 }else{
469 echo "<a href=\"modules.php?name=Elezioni&amp;op=$op&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;csv=1&amp;orvert=$orvert&amp;min=$min&amp;offset=$offset&amp;minsez=$minsez&amp;offsetsez=$offsetsez&amp;perc=$perc&amp;id_lista=$id_lista&amp;datipdf=$datipdf\" ><img class=\"image\" src=\"modules/Elezioni/images/printer.gif\" alt=\"Stampa\" /></a>";
470 echo "<a href=\"modules.php?name=Elezioni&amp;op=$op&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;csv=1&amp;orvert=$orvert&amp;min=$min&amp;offset=$offset&amp;minsez=$minsez&amp;offsetsez=$offsetsez&amp;perc=$perc&amp;id_lista=$id_lista&amp;xls=1&amp;datipdf=$datipdf\" ><img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"Export Csv\" /></a>";
471 echo "<img class=\"image\" src=\"modules/Elezioni/images/rss.png\" alt=\"Export rss\" />";
472 echo " </td>";
473 # stampa pdf
474 echo "<td>";
475 echo "<form id=\"pdf\" method=\"post\" action=\"modules.php\">";
476 echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"></input>";
477 echo "<input type=\"hidden\" name=\"op\" value=\"$op\"></input>";
478 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"></input>";
479 echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>";
480 echo "<input type=\"hidden\" name=\"csv\" value=\"1\"></input>";
481 echo "<input type=\"hidden\" name=\"orvert\" value=\"$orvert\"></input>";
482 echo "<input type=\"hidden\" name=\"min\" value=\"$min\"></input>";
483 echo "<input type=\"hidden\" name=\"offset\" value=\"$offset\"></input>";
484 echo "<input type=\"hidden\" name=\"minsez\" value=\"$minsez\"></input>";
485 echo "<input type=\"hidden\" name=\"offsetsez\" value=\"$offsetsez\"></input>";
486 echo "<input type=\"hidden\" name=\"perc\" value=\"$perc\"></input>";
487 echo "<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\"></input>";
488 echo "<input type=\"hidden\" name=\"pdf\" value=\"1\"></input>";
489 echo "<input type=\"hidden\" name=\"datipdf\" value=\"$datipdf\"></input>";
490 # echo "<input type=\"hidden\" name=\"name\" value=\"$elezioni\"></input>";
491 echo "<input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input>";
492 echo "<input type=\"image\" name=\"submit\" src=\"modules/Elezioni/images/pdf.gif\" align=\"left\">";
493 echo "&nbsp; L &nbsp;<input type=\"radio\" name=\"orienta\" $land value=\"L\"></input>P &nbsp;<input
494 type=\"radio\" name=\"orienta\" $port value=\"P\"></input><br />";
495 echo "&nbsp; A3<input type=\"radio\" name=\"formato\" $A3 value=\"A3\"></input>A4<input
496 type=\"radio\" name=\"formato\" $A4 value=\"A4\"></input>";
497 echo " </form></td></tr></table> ";
498 }
499 echo "</div></br />";
500 }
501 if (!$csv){
502 echo "<h5> Sezioni scrutinate";
503 if ($tipo_cons!=4) echo ": $tot_scr su $tuttelesez &nbsp;&nbsp;&nbsp; ";
504 echo "</h5>&nbsp;";
505 }
506 $y=1;
507 $ar[0][0]=$tipo3;
508 $ra[0][0]=$tipo3;
509 $num_sez++;
510 $voticompl=0;
511 $ominsez=$minsez-1;
512 $valar=array();$percar=array();
513 ////////////////////////////////////////////////////////////////////
514 // sandro: carica i numeri di sezione dal DB - giugno 2009
515 // caso: sezioni in collegi diversi non consecutive
516 if (strstr( $op,'circo'))
517 $sql="select num_circ,id_circ from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' and num_circ>='$minsez' and num_circ<='$offsetsez' order by num_circ";
518 else{
519 if($circo) { $secirco=" and t2.id_circ=$id_circ";} else $secirco="and t1.num_sez >= $minsez and t1.num_sez <= $offsetsez";
520 $numsezioni = $offsetsez-$ominsez;
521 $sql="SELECT t1.num_sez,t1.id_sez from ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons=$id_cons and t1.id_sede=t2.id_sede $secirco order by t1.num_sez";
522 }
523 $res_numsez = $dbi->prepare("$sql");
524 $res_numsez->execute();
525 $sevaltot=0;
526 $senultot=0;
527 $sebiatot=0;
528 $secontot=0;
529 $sevnutot=0;
530 while($res=$res_numsez->fetch(PDO::FETCH_NUM)) {
531 $z=$res[0];
532##############inserimento percentuale di scrutinio nella sezione
533 $scruvalidi=0;
534 $scrunulli=0;
535 $grpercscru=0;
536 $altri=0;
537 $votiscru=0;
538 if($op=="gruppo_sezione"){
539 $sqlr="select sum(validi),sum(solo_lista) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'";
540 $sqlv="select sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='".$res[1]."'";
541 $resperc = $dbi->prepare("$sqlr");
542 $resperc->execute();
543 $votiperc = $dbi->prepare("$sqlv");
544 $votiperc->execute();
545 }
546 elseif($op=="lista_sezione"){
547 $sqlr="select sum(validi),sum(contestati_lista+solo_gruppo+voti_nulli_lista) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'";
548 $sqlv="select sum(voti) from ".$prefix."_ele_voti_lista where id_sez='".$res[1]."'";
549 $resperc = $dbi->prepare("$sqlr");
550 $resperc->execute();
551 $votiperc = $dbi->prepare("$sqlv");
552 $votiperc->execute();
553 }
554 if (isset($resperc) and $resperc)
555 list($scruvalidi,$scrunulli)=$resperc->fetch(PDO::FETCH_NUM);
556 if (isset($votiperc) and $votiperc)
557 list($votiscru)=$votiperc->fetch(PDO::FETCH_NUM);
558 $sql="select sum(voti_complessivi) from ".$prefix."_ele_voti_parziale where id_sez='".$res[1]."' group by data,orario order by data desc, orario desc limit 0,1 ";
559 $resperc = $dbi->prepare("$sql");
560 $resperc->execute();
561
562 if ($resperc)
563 list($totschede)=$resperc->fetch(PDO::FETCH_NUM);
564 if (isset($scruvalidi) and $scruvalidi>0 )
565 $grpercscru=$votiscru ? number_format(($votiscru+$scrunulli)*100/$scruvalidi,0) : 0;
566
567################### <span class=\"red\"><i>".$temp3[$key]." %</i></span>
568 $ar[$z][0]=$res[0]; if($grpercscru) {$ar[$z][0].="<br /><span class=\"red\"><i>$grpercscru%</i></span>";if(!strstr($ar[0][0],'scrutinio')) $ar[0][0].="<br /><span class=\"red\"><i>% scrutinio</i></span>"; }
569 $pos[$z]=$res[0];
570 #$valar[$z]=array();
571 }
572 if (!isset($pos)) $pos[0]=0;
573 $minpos=min($pos);
574 $maxpos=max($pos);
575 ////////////////////////////////////////////////////////////////////
576 if ($tab=="gruppo" or $genere==4 or ($genere==5 and $votog))
577 $sqlvoti2="select $tab3, sum(t3.validi),sum(t3.nulli),sum(t3.bianchi),sum(t3.contestati),sum(t3.voti_nulli) from ".$prefix."_ele_circoscrizione as t5, ".$prefix."_ele_sezioni as t3, ".$prefix."_ele_sede as t4 where t5.id_cons=$id_cons and t5.id_circ=t4.id_circ and t3.id_sede=t4.id_sede group by $tab3";
578 else
579 if ($votog) $sqlvoti2="select t1.num_circ, (t3.validi_lista),(t3.nulli),(t3.bianchi),(t3.contestati),(t3.voti_nulli) from ".$prefix."_ele_circoscrizione as t1, ".$prefix."_ele_sezioni as t3, ".$prefix."_ele_sede as t4 where t1.id_cons=$id_cons and t1.id_circ=t4.id_circ and t3.id_sede=t4.id_sede group by t1.num_circ";
580
581 else $sqlvoti2="select t1.num_circ, sum(t3.validi_lista),sum(t3.nulli),sum(t3.bianchi),sum(t3.contestati_lista),sum(t3.voti_nulli_lista+t3.voti_nulli) from ".$prefix."_ele_circoscrizione as t1, ".$prefix."_ele_sezioni as t3, ".$prefix."_ele_sede as t4 where t1.id_cons=$id_cons and t1.id_circ=t4.id_circ and t3.id_sede=t4.id_sede group by t1.num_circ";
582
583 $res_voti = $dbi->prepare("$sqlvoti2");
584 $res_voti->execute();
585
586 ///////////////////////////
587 if ($res_voti->rowCount())
588 while (list($num_circ,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){
589# if($genere==4) $sevalidi=$voti;
590 $z=array_search($num_circ, $pos);
591 if (!isset($votitot[($z)])) {
592 $votitot[($z)]=0;
593 if($sevalidi) $sevaltot+=$sevalidi;
594 if($senulli) $senultot+=$senulli;
595 if($sebianchi) $sebiatot+=$sebianchi;
596 if($secontestati) $secontot+=$secontestati;
597 if($sevonulli) $sevnutot+=$sevonulli;
598 }
599# $votitot[($z)]+=$voti;
600# if(!isset($valsez[$z])) $valsez[$z]=0;
601 $valsez[$z]=$sevalidi;
602 $nulsez[$z]=$senulli;
603 $biasez[$z]=$sebianchi;
604 $consez[$z]=$secontestati;
605 $vonsez[$z]=$sevonulli;
606# $voticompl+=$voti;
607 }
608 if ($voticompl) {
609 $res_voti = $dbi->prepare("$sqlvoti");
610 $res_voti->execute();
611 }
612 $piuvot=0;
613 if ($visvot!='cand') $piuvot=5;
614 for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[0][$y]="&nbsp;";
615 if (strstr( $op,'circo'))
616 $sql="select num_circ from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' and num_circ>='$minsez' and num_circ<='$offsetsez' order by num_circ";
617 else
618 $sql="select num_sez from ".$prefix."_ele_sezioni where id_cons='$id_cons' and num_sez>='$minsez' and num_sez<='$offsetsez' order by num_sez";
619 $lis_sez = $dbi->prepare("$sql");
620 $lis_sez->execute();
621 $nsezsel=$lis_sez->rowCount();
622 while(list($z)=$lis_sez->fetch(PDO::FETCH_NUM))
623 {
624 for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[$z][$y]="&nbsp;";} //inizializza le celle interne
625
626###################################################################
627# for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[0][$y]="&nbsp;";
628# for ($z=1;$z<=($offsetsez-$ominsez);$z++)
629 # for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[$z][$y]="&nbsp;"; //inizializza le celle interne
630 $onetime="";
631 if ($res_voti)
632 {
633 while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){
634 $z=array_search($num_circ, $pos);
635 $valar[($z)][$num_cand]=$voti;
636 }
637
638 foreach ($valar as $key=>$val){
639 if(isset($votitot[($key)]))
640 $percar[$key]=arrayperc($val,$votitot[($key)]);
641
642 }
643 # if($res_voti->rowCount()) {
644 $res_voti = $dbi->prepare("$sqlvoti");
645 $res_voti->execute();
646 #}
647
648 while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){
649 if($num_cand<$min or $num_cand>$offset) continue;
650 if($genere==4) $sevalidi=$voti;
651
652 if (!isset($temp[$num_cand])) $temp[$num_cand]=0;
653 $temp[$num_cand]+=$voti;
654 $z=array_search($num_circ, $pos);
655 if (!$z) continue;
656 if ($num_cand>=$min and $num_cand<=$offset){
657 if($num_circ>=$minpos and $num_circ <=$maxpos){
658 $ar[0][$num_cand]=$num_cand.") ".$nome;
659 if ($desc_circ && $onetime!=$desc_circ) {$ar[($z)][0].=") ".$desc_circ; $onetime=$desc_circ;}
660 $percento=$voti;
661 if ($perc=='true' and $votitot[($z)])
662 {
663 $percento=$voti."<br /><span class=\"red\" style=\"font-size:80%;\"><i>".number_format($percar[$z][$num_cand],2)." %</i></span>";
664 }
665
666 $ar[($z)][$num_cand]=$percento;
667 }
668 }
669 if (!strstr( $op,'candidato')){
670 if (!isset($tempar[$num_cand])) $tempar[$num_cand]=0;
671 $tempar[$num_cand]+=$voti;
672 }
673 if ($visvot!='cand'){
674 $posvoti=($offset);
675 $ar[0][$posvoti+1]='<b>Voti Validi</b>';
676 $ar[0][$posvoti+2]='<b>Schede Nulle</b>';
677 $ar[0][$posvoti+3]='<b>Schede Bianche</b>';
678 $ar[0][$posvoti+4]='<b>Voti Contestati</b>';
679 $ar[0][$posvoti+5]='<b>Voti Nulli</b>';
680 if (($maxpos)>=$num_circ and $minpos<=$num_circ){
681 //$posvoti++;
682 $ar[($z)][$posvoti+1]="<b>$valsez[$z]</b>";
683 $ar[($z)][$posvoti+2]="<b>$nulsez[$z]</b>";
684 $ar[($z)][$posvoti+3]="<b>$biasez[$z]</b>";
685 $ar[($z)][$posvoti+4]="<b>$consez[$z]</b>";
686 $ar[($z)][$posvoti+5]="<b>$vonsez[$z]</b>";
687 }
688 }
689 }
690 }
691
692 if (($offsetsez+1)>=$num_sez){
693 $ar[(1+$numsezmax)][0]="<b>"._TOT."<br />"._COMPLESSIVO."</b>";
694 if(isset($temp)) {
695 if (!isset($tab15) or !$tab15) $tab15="candidati";
696 if($tab15=="gruppo" or $genere==4){
697 if($votog) $tab15="lista";
698 $votigl=" sum(validi),sum(nulli),sum(bianchi),sum(contestati),sum(voti_nulli)";
699 }elseif($votog){
700 $votigl=" sum(validi),sum(nulli),sum(bianchi),sum(contestati),sum(voti_nulli)";
701 }else{
702 if($dettnulli) $votigl=" sum(validi_lista),sum(nulli),sum(bianchi),sum(contestati_lista),sum(voti_nulli_lista+voti_nulli)";
703 else $votigl=" sum(validi_lista),sum(nulli),sum(bianchi),sum(contestati_lista),sum(voti_nulli)";
704 }
705 if($circo)
706 $sql="SELECT $votigl from ".$prefix."_ele_sezioni AS t1 LEFT JOIN soraldo_ele_sede AS t2 ON t1.id_sede = t2.id_sede WHERE t1.id_cons='$id_cons' and t2.id_circ=$id_circ";
707 else
708 $sql="SELECT $votigl from ".$prefix."_ele_sezioni as t1 where t1.id_cons='$id_cons' and t1.id_sez=(select t2.id_sez from ".$prefix."_ele_voti_$tab15 as t2 where t2.id_sez=t1.id_sez group by t2.id_sez)";
709 $resv = $dbi->prepare("$sql");
710 $resv->execute();
711 list ($sevaltot,$senultot,$sebiatot,$secontot,$sevnutot)= $resv->fetch(PDO::FETCH_NUM);
712 $voticompl=$sevaltot+$senultot+$sebiatot+$secontot+$sevnutot;
713 $sql="SELECT voti from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons'";
714 $resvt = $dbi->prepare("$sql");
715 $resvt->execute();
716 if($resvt) list($votlt)=$resvt->fetch(PDO::FETCH_NUM); else $votlt=0;
717 if($perc) $temp3=arrayperc($temp,$sevaltot);
718
719 foreach($temp as $key=>$voti) {
720 if ($perc=='true' and $voticompl)
721 {
722 $percento="<b>$voti<br /><span class=\"red\"><i>".$temp3[$key]." %</i></span></b>";
723 } else
724 $percento="<b>$voti</b>";
725 $ar[1+$numsezmax][$key]=$percento;
726 }
727 }
728 if ($visvot!='cand') {
729 $key=$offset+1;
730 $tmp=array($sevaltot,$senultot,$sebiatot,$secontot,$sevnutot);
731 if($perc) $temp3=arrayperc($tmp,$voticompl);
732
733 foreach($tmp as $k=>$voti) {
734 if ($perc=='true' and $voticompl)
735 {
736 $percento="<b>$voti<br /><span class=\"red\"><i>".$temp3[$k]." %</i></span></b>";
737 } else $percento="<b>$voti</b>";
738 $ar[1+$numsezmax][++$key]=$percento;
739
740 }
741 }
742 }
743 if($orvert!=1) {
744 $i=0;
745 foreach ( $ar as $riga) {
746 $y=0;
747 foreach($riga as $cella) {
748 $ra[$y++][$i]=$cella;
749 }
750 $i++;
751 }
752 crea_tabella($ra);
753 }else{
754 crea_tabella($ar);
755 }
756//e' un referendum
757 }else{
758 $sql="SELECT id_gruppo, descrizione,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons order by num_gruppo";
759 $res_lis = $dbi->prepare("$sql");
760 $res_lis->execute();
761
762 if($res_lis) $numliste=$res_lis->rowCount(); else $numliste=0;
763
764 if (!isset($offset)) $offset=10;
765 if (!isset($min)) $min=1;
766 if (!isset($offsetsez)) $offsetsez=25; //lo 0 viene sostituito dal totale di sezioni presenti
767 if (!isset($minsez)) $minsez=1;
768 if (!$csv){
769 echo "<div><h5>$pagina</h5></div>";
770 echo "<form id=\"voti\" method=\"post\" action=\"modules.php\">";
771 echo "<div style=\"text-align:left;width:700px;margin:auto;font-size:12px \">
772 <input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input>";
773 echo "<input type=\"hidden\" name=\"op\" value=\"$op\"></input>";
774 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"></input>";
775 echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>";
776 echo ""._SCELTA." "._CONSULTAZIONE.": <select name=\"id_gruppo\">";
777 if($res_lis)
778 while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) {
779 if (!$id_gruppo) $id_gruppo=$id_rif;
780 $sel = ($id_rif == $id_gruppo) ? "selected=\"selected\"" : "";
781 echo "<option value=\"$id_rif\" $sel>";
782 for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
783 echo $num_lis.") ".strip_tags(substr($descrizione,0,50))."</option>";
784 }
785 echo "</select>";
786 echo "<br />"._VIS_PERC.": <input type=\"checkbox\" name=\"perc\" value=\"true\"";
787 if($perc=='true') echo " checked=\"true\"";
788 echo ">";
789 echo "<br /><input type=\"submit\" name=\"update\" value=\""._RICARICA."\"></form></div>";
790
791
792
793 }
794
795 $sql="select num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id_gruppo";
796 $res_ref = $dbi->prepare("$sql");
797 $res_ref ->execute();
798
799 $sql="select $tab2, t1.num_gruppo, t1.descrizione , t1.simbolo,
800 sum(t2.si), sum(t2.no),sum(t2.validi), sum(t2.nulli),sum(t2.bianchi), sum(t2.contestati)
801 from ".$prefix."_ele_gruppo as t1
802 left join ".$prefix."_ele_voti_ref as t2 on (t1.id_gruppo=t2.id_gruppo)
803 left join ".$prefix."_ele_sezioni as t3 on (t2.id_sez=t3.id_sez)
804 left join ".$prefix."_ele_sede as t4 on (t3.id_sede=t4.id_sede)
805 left join ".$prefix."_ele_circoscrizione as t5 on (t4.id_circ=t5.id_circ)
806 where t1.id_cons='$id_cons' and t1.id_gruppo=$id_gruppo
807 group by t2.id_gruppo,$tab2, t1.num_gruppo, t1.descrizione , t1.simbolo
808 order by $tab3, t1.num_gruppo
809 ";
810 $res = $dbi->prepare("$sql");
811 $res->execute();
812
813 if($res) $num_sez=$res->rowCount(); else $num_sez=0;
814 if($res_ref) list($num_gruppo,$descr)= $res_ref->fetch(PDO::FETCH_NUM); else {$num_gruppo=0;$descr='';}
815
816 if (!$csv){
817 # stampa
818
819 $datipdf="<b>"._COMUNE." $descr_comune</b> - "._RISULTATI.": $descr_cons<br/><b>$pagina</b><br/><br/> ";
820 $datipdf .="<br/><b>Referendum n. ".$num_gruppo." </b><br/>".$descr."";
821 echo "<div style=\"text-align:right;width:900px;margin-left:10px;margin-right:20px;font-size:12px \">";
822 echo "<table style=\"text-align:center;margin-right:0px;border-top : 1px solid Blue;width: 140px;\"><tr style=\" background:#eceff5;\"><td>"._ESPORTA."<br />";
823
824 echo "<a href=\"modules.php?name=Elezioni&amp;op=$op&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;csv=1&amp;perc=$perc&amp;id_gruppo=$id_gruppo&amp;datipdf=$datipdf\" ><img class=\"image\" src=\"modules/Elezioni/images/printer.gif\" alt=\"Stampa\" /></a>";
825 echo "<a href=\"modules.php?name=Elezioni&amp;op=$op&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;csv=1&amp;perc=$perc&amp;id_gruppo=$id_gruppo&amp;xls=1&amp;datipdf=$datipdf\" ><img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"Export Csv\" /></a>";
826
827 //echo "<a href=\"modules.php?name=Elezioni&amp;op=$op&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;csv=1&amp;perc=$perc&amp;id_gruppo=$id_gruppo&amp;pdf=1&amp;datipdf=$datipdf\" ><img class=\"image\" src=\"modules/Elezioni/images/pdf.gif\" alt=\"Export Pdf\" /></a>";
828
829
830 echo "<img class=\"image\" src=\"modules/Elezioni/images/rss.png\" alt=\"Export rss\" />";
831
832 echo " </td></tr>";
833
834
835 echo "<form id=\"pdf\" method=\"post\" action=\"modules.php\">";
836
837 echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"></input>";
838 echo "<input type=\"hidden\" name=\"op\" value=\"$op\"></input>";
839 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"></input>";
840 echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>";
841 echo "<input type=\"hidden\" name=\"csv\" value=\"1\"></input>";
842 echo "<input type=\"hidden\" name=\"orvert\" value=\"$orvert\"></input>";
843 echo "<input type=\"hidden\" name=\"min\" value=\"$min\"></input>";
844 echo "<input type=\"hidden\" name=\"offset\" value=\"$offset\"></input>";
845 echo "<input type=\"hidden\" name=\"minsez\" value=\"$minsez\"></input>";
846 echo "<input type=\"hidden\" name=\"offsetsez\" value=\"$offsetsez\"></input>";
847 echo "<input type=\"hidden\" name=\"perc\" value=\"$perc\"></input>";
848 echo "<input type=\"hidden\" name=\"id_gruppo\" value=\"$id_gruppo\"></input>";
849 echo "<input type=\"hidden\" name=\"pdf\" value=\"1\"></input>";
850 echo "<input type=\"hidden\" name=\"datipdf\" value=\"$datipdf\"></input>";
851 echo "<input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input>";
852
853 echo "<tr><td>";
854 echo "<input type=\"image\" name=\"submit\" src=\"modules/Elezioni/images/pdf.gif\" align=\"left\">";
855 echo "&nbsp; L &nbsp;<input type=\"radio\" name=\"orienta\" $land value=\"L\"></input>P &nbsp;<input
856 type=\"radio\" name=\"orienta\" $port value=\"P\"></input><br />";
857 echo "&nbsp; A3<input type=\"radio\" name=\"formato\" $A3 value=\"A3\"></input>A4<input
858 type=\"radio\" name=\"formato\" $A4 value=\"A4\"></input>";
859
860
861 echo " </td></tr></table></form> ";
862
863
864
865
866
867
868
869
870
871 echo "</div>";
872
873
874// numero sezioni scrutinate
875 $sql="select t3.id_sez from ".$prefix."_ele_voti_ref 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' group by t3.id_sez ";
876 $res4 = $dbi->prepare("$sql");
877 $res4->execute();
878
879 $numero=$res4->rowCount();
880 $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' ";
881 $res5 = $dbi->prepare("$sql");
882 $res5->execute();
883
884 $sezioni=$res5->rowCount();
885 if ($numero!=0) echo "<h5><i> "._SEZSCRU." $numero "._SU." $sezioni </i></h5>";
886
887}
888 $sql="select count(0) from ".$prefix."_ele_sezioni where id_cons='$id_cons'";
889 $res5 = $dbi->prepare("$sql");
890 $res5->execute();
891
892 list($num_sez) = $res5->fetch(PDO::FETCH_NUM);
893
894
895
896
897
898 if (!$csv)echo "<b>Referendum n. ".$num_gruppo." </b><br />".$descr."";
899
900 $y=1;
901 $ar[0][0]=$tipo2;
902 $ar[0][1]=_SI;
903 $ar[0][2]=_NO;
904 $ar[0][3]=_VALIDI;
905 $ar[0][4]=_NULLI;
906 $ar[0][5]=_BIANCHI;
907 $ar[0][6]=_CONTESTATI;
908 if($res_ref)
909 while (list($num_gruppo,$desc_ref) = $res_ref->fetch(PDO::FETCH_NUM)){
910 $ar[0][$i++]= $num_gruppo.") ".$desc_ref;
911 $ar[1][$y++]= "SI";
912 $ar[1][$y++]= "NO";
913 }
914 $num_sez++;
915 $tot_si=0;
916 $tot_no=0;
917 $tot_va=0;
918 $tot_nu=0;
919 $tot_bi=0;
920 $tot_co=0;
921 if($res)
922 while (list($num_circ,$desc_circ,$num_gruppo,$desc_ref,$simbolo,$si,$no,$validi,$nulli,$bianchi, $contestati) = $res->fetch(PDO::FETCH_NUM)){
923 $i=1;
924 $votanti=$validi+$nulli+$bianchi+$contestati;
925 $tot_si+=$si;
926 $tot_no+=$no;
927 $tot_va+=$validi;
928 $tot_nu+=$nulli;
929 $tot_bi+=$bianchi;
930 $tot_co+=$contestati;
931 $ar[$num_circ][0]=$num_circ."<br />".$desc_circ;
932 if($validi){
933 $ar[$num_circ][$i++]= $perc=='true' ? $si."<br /><span class=\"red\"><i>".number_format($si*100/$validi,2)."%</i></span>":$si;
934 $ar[$num_circ][$i++]= $perc=='true' ? $no."<br /><span class=\"red\"><i>".number_format($no*100/$validi,2)."%</i></span>":$no;
935 }else{
936 $ar[$num_circ][$i++]= $perc=='true' ? $si."<br /><span class=\"red\"><i>0.00%</i></span>":$si;
937 $ar[$num_circ][$i++]= $perc=='true' ? $no."<br /><span class=\"red\"><i>0.00%</i></span>":$no;
938 }
939 if($votanti){
940 $ar[$num_circ][$i++]= $perc=='true' ? $validi."<br /><span class=\"red\"><i>".number_format($validi*100/$votanti,2)."%</i></span>":$validi;
941 $ar[$num_circ][$i++]= $perc=='true' ? $nulli."<br /><span class=\"red\"><i>".number_format($nulli*100/$votanti,2)."%</i></span>":$nulli;
942 $ar[$num_circ][$i++]= $perc=='true' ? $bianchi."<br /><span class=\"red\"><i>".number_format($bianchi*100/$votanti,2)."%</i></span>":$bianchi;
943 $ar[$num_circ][$i++]= $perc=='true' ? $contestati."<br /><span class=\"red\"><i>".number_format($contestati*100/$votanti,2)."%</i></span>":$contestati;
944 }else{
945 $ar[$num_circ][$i++]= $perc=='true' ? $validi."<br /><span class=\"red\"><i>0.00%</i></span>":$validi;
946 $ar[$num_circ][$i++]= $perc=='true' ? $nulli."<br /><span class=\"red\"><i>0.00%</i></span>":$nulli;
947 $ar[$num_circ][$i++]= $perc=='true' ? $bianchi."<br /><span class=\"red\"><i>0.00%</i></span>":$bianchi;
948 $ar[$num_circ][$i++]= $perc=='true' ? $contestati."<br /><span class=\"red\"><i>0.00%</i></span>":$contestati;
949 }
950 }
951 $i=1;
952 $tot_vo=$tot_va+$tot_nu+$tot_bi+$tot_co;
953# if($tot_va==0) $tot_va=1;
954# if($tot_vo==0) $tot_vo=1;
955 $ar[$num_sez][0]=_TOT."<br />"._COMPLESSIVO;
956 if($tot_va){
957 $ar[$num_sez][$i++]= $perc=='true' ? $tot_si."<br /><span class=\"red\">".number_format($tot_si*100/$tot_va,2)."%</span>":$tot_si;
958 $ar[$num_sez][$i++]= $perc=='true' ? $tot_no."<br /><span class=\"red\">".number_format($tot_no*100/$tot_va,2)."%</span>":$tot_no;
959 }else{
960 $ar[$num_sez][$i++]= $perc=='true' ? $tot_si."<br /><span class=\"red\">0.00%</span>":$tot_si;
961 $ar[$num_sez][$i++]= $perc=='true' ? $tot_no."<br /><span class=\"red\">0.00%</span>":$tot_no;
962 }
963 if($tot_vo){
964 $ar[$num_sez][$i++]= $perc=='true' ? $tot_va."<br /><span class=\"red\">".number_format($tot_va*100/$tot_vo,2)."%</span>":$tot_va;
965 $ar[$num_sez][$i++]= $perc=='true' ? $tot_nu."<br /><span class=\"red\">".number_format($tot_nu*100/$tot_vo,2)."%</span>":$tot_nu;
966 $ar[$num_sez][$i++]= $perc=='true' ? $tot_bi."<br /><span class=\"red\">".number_format($tot_bi*100/$tot_vo,2)."%</span>":$tot_bi;
967 $ar[$num_sez][$i++]= $perc=='true' ? $tot_co."<br /><span class=\"red\">".number_format($tot_co*100/$tot_vo,2)."%</span>":$tot_co;
968 }else{
969 $ar[$num_sez][$i++]= $perc=='true' ? $tot_va."<br /><span class=\"red\">0.00%</span>":$tot_va;
970 $ar[$num_sez][$i++]= $perc=='true' ? $tot_nu."<br /><span class=\"red\">0.00%</span>":$tot_nu;
971 $ar[$num_sez][$i++]= $perc=='true' ? $tot_bi."<br /><span class=\"red\">0.00%</span>":$tot_bi;
972 $ar[$num_sez][$i++]= $perc=='true' ? $tot_co."<br /><span class=\"red\">0.00%</span>":$tot_co;
973 }
974 crea_tabella($ar);
975 }
976 if ($csv) echo "</body>\n</html>";
977}
978
979?>
Note: See TracBrowser for help on using the repository browser.