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

Last change on this file since 371 was 371, checked in by roby, 2 years ago

In client:

  • rivista la funzione di esportazione pdf, xls e stampe
  • tema futura2: eliminato il taglio a 30 caratteri del nome della consultazione
  • modificata la barra da 2D a 3D per i grafici di affluenza e votanti

In admin:

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