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

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

client: Correzione ulteriore per la gestione delle stampe
admin: modifica degli avvisi di errore presenti nel file di aggiornamento del db

File size: 48.8 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='';
[372]39#if (isset($param['datipdf'])) $datipdf=addslashes($param['datipdf']); else $datipdf='';
[254]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);
[373]46if(isset($_SESSION['datipdf'])) $datipdf= $_SESSION['datipdf'];
[254]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='';
[372]483 $nomefile.="$descr_cons $tab15";
484 $_SESSION['nomefile']=strip_tags(str_replace(" ", "_", $nomefile));
485 $datipdf="<b>"._COMUNE." $descr_comune</b> - "._RISULTATI.": $descr_cons<br/><b>$pagina</b><br/><br/> $list1 $list2 $list3 ";
486 $_SESSION['datipdf']= $datipdf;
[265]487# verificare la stampa sulle circoscrizioni
[372]488 echo "<div style=\"text-align:right;width:65%;margin-left:10px;margin-right:0px;font-size:12px; \">";
489 echo "<table style=\"text-align:center;margin-right:0px;border-top : 1px solid Blue;width: 280px;\"><tr style=\" background:#eceff5;\"><td>"._ESPORTA."<br />";
490 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\" ><img class=\"image\" src=\"modules/Elezioni/images/printer.gif\" alt=\"Stampa\" /></a>";
[254]491 }else{
[372]492 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\" ><img class=\"image\" src=\"modules/Elezioni/images/printer.gif\" alt=\"Stampa\" /></a>";
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;xls=1\" ><img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"Export Csv\" /></a>";
[265]494 echo "<img class=\"image\" src=\"modules/Elezioni/images/rss.png\" alt=\"Export rss\" />";
[347]495 echo " </td>";
[265]496 # stampa pdf
[347]497 echo "<td>";
[265]498 echo "<form id=\"pdf\" method=\"post\" action=\"modules.php\">";
499 echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"></input>";
500 echo "<input type=\"hidden\" name=\"op\" value=\"$op\"></input>";
501 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"></input>";
502 echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>";
503 echo "<input type=\"hidden\" name=\"csv\" value=\"1\"></input>";
504 echo "<input type=\"hidden\" name=\"orvert\" value=\"$orvert\"></input>";
505 echo "<input type=\"hidden\" name=\"min\" value=\"$min\"></input>";
[254]506 echo "<input type=\"hidden\" name=\"offset\" value=\"$offset\"></input>";
[265]507 echo "<input type=\"hidden\" name=\"minsez\" value=\"$minsez\"></input>";
508 echo "<input type=\"hidden\" name=\"offsetsez\" value=\"$offsetsez\"></input>";
509 echo "<input type=\"hidden\" name=\"perc\" value=\"$perc\"></input>";
510 echo "<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\"></input>";
511 echo "<input type=\"hidden\" name=\"pdf\" value=\"1\"></input>";
[375]512# echo "<input type=\"hidden\" name=\"datipdf\" value=\"$datipdf\"></input>";
[265]513 # echo "<input type=\"hidden\" name=\"name\" value=\"$elezioni\"></input>";
514 echo "<input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input>";
515 echo "<input type=\"image\" name=\"submit\" src=\"modules/Elezioni/images/pdf.gif\" align=\"left\">";
516 echo "&nbsp; L &nbsp;<input type=\"radio\" name=\"orienta\" $land value=\"L\"></input>P &nbsp;<input
517 type=\"radio\" name=\"orienta\" $port value=\"P\"></input><br />";
518 echo "&nbsp; A3<input type=\"radio\" name=\"formato\" $A3 value=\"A3\"></input>A4<input
519 type=\"radio\" name=\"formato\" $A4 value=\"A4\"></input>";
[347]520 echo " </form></td></tr></table> ";
[254]521 }
522 echo "</div></br />";
[265]523 }
[254]524 if (!$csv){
525 echo "<h5> Sezioni scrutinate";
[356]526 if ($tipo_cons!=4) ;echo ": $tot_scr su $tuttelesez &nbsp;&nbsp;&nbsp; ";
[254]527 echo "</h5>&nbsp;";
528 }
529 $y=1;
530 $ar[0][0]=$tipo3;
531 $ra[0][0]=$tipo3;
532 $num_sez++;
533 $voticompl=0;
534 $ominsez=$minsez-1;
535 $valar=array();$percar=array();
536 ////////////////////////////////////////////////////////////////////
537 // sandro: carica i numeri di sezione dal DB - giugno 2009
538 // caso: sezioni in collegi diversi non consecutive
539 if (strstr( $op,'circo'))
[318]540 $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]541 else{
542 if($circo) { $secirco=" and t2.id_circ=$id_circ";} else $secirco="and t1.num_sez >= $minsez and t1.num_sez <= $offsetsez";
543 $numsezioni = $offsetsez-$ominsez;
[318]544 $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]545 }
[265]546 $res_numsez = $dbi->prepare("$sql");
[344]547 $res_numsez->execute();
[318]548 $sevaltot=0;
549 $senultot=0;
550 $sebiatot=0;
551 $secontot=0;
552 $sevnutot=0;
[337]553 while($res=$res_numsez->fetch(PDO::FETCH_NUM)) {
[265]554 $z=$res[0];
[254]555##############inserimento percentuale di scrutinio nella sezione
[265]556 $scruvalidi=0;
557 $scrunulli=0;
558 $grpercscru=0;
559 $altri=0;
560 $votiscru=0;
561 if($op=="gruppo_sezione"){
562 $sqlr="select sum(validi),sum(solo_lista) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'";
563 $sqlv="select sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='".$res[1]."'";
564 $resperc = $dbi->prepare("$sqlr");
565 $resperc->execute();
566 $votiperc = $dbi->prepare("$sqlv");
567 $votiperc->execute();
568 }
569 elseif($op=="lista_sezione"){
[318]570 $sqlr="select sum(validi),sum(contestati_lista+solo_gruppo+voti_nulli_lista) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'";
571 $sqlv="select sum(voti) from ".$prefix."_ele_voti_lista where id_sez='".$res[1]."'";
[265]572 $resperc = $dbi->prepare("$sqlr");
573 $resperc->execute();
574 $votiperc = $dbi->prepare("$sqlv");
575 $votiperc->execute();
576 }
577 if (isset($resperc) and $resperc)
578 list($scruvalidi,$scrunulli)=$resperc->fetch(PDO::FETCH_NUM);
579 if (isset($votiperc) and $votiperc)
580 list($votiscru)=$votiperc->fetch(PDO::FETCH_NUM);
[318]581 $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 ";
582 $resperc = $dbi->prepare("$sql");
583 $resperc->execute();
[254]584
[265]585 if ($resperc)
586 list($totschede)=$resperc->fetch(PDO::FETCH_NUM);
587 if (isset($scruvalidi) and $scruvalidi>0 )
588 $grpercscru=$votiscru ? number_format(($votiscru+$scrunulli)*100/$scruvalidi,0) : 0;
589
[254]590################### <span class=\"red\"><i>".$temp3[$key]." %</i></span>
[265]591 $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>"; }
592 $pos[$z]=$res[0];
593 #$valar[$z]=array();
594 }
[254]595 if (!isset($pos)) $pos[0]=0;
596 $minpos=min($pos);
597 $maxpos=max($pos);
598 ////////////////////////////////////////////////////////////////////
[352]599 if ($tab=="gruppo" or $genere==4 or ($genere==5 and $votog) or defined('_NULLISTA'))
[347]600 $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";
601 else
[353]602 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";
603# 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
604# camera 2008 e 2001 --> tipo cons=6 non funziona
[350]605
[353]606 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]607 $res_voti = $dbi->prepare("$sqlvoti2");
608 $res_voti->execute();
[353]609# echo "TEST: ---- $sqlvoti2";
[347]610 ///////////////////////////
[265]611 if ($res_voti->rowCount())
[347]612 while (list($num_circ,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){
[318]613# if($genere==4) $sevalidi=$voti;
[265]614 $z=array_search($num_circ, $pos);
[254]615 if (!isset($votitot[($z)])) {
[265]616 $votitot[($z)]=0;
617 if($sevalidi) $sevaltot+=$sevalidi;
618 if($senulli) $senultot+=$senulli;
619 if($sebianchi) $sebiatot+=$sebianchi;
620 if($secontestati) $secontot+=$secontestati;
621 if($sevonulli) $sevnutot+=$sevonulli;
[254]622 }
[347]623# $votitot[($z)]+=$voti;
624# if(!isset($valsez[$z])) $valsez[$z]=0;
[318]625 $valsez[$z]=$sevalidi;
[347]626 $nulsez[$z]=$senulli;
627 $biasez[$z]=$sebianchi;
628 $consez[$z]=$secontestati;
629 $vonsez[$z]=$sevonulli;
630# $voticompl+=$voti;
[254]631 }
[265]632 if ($voticompl) {
633 $res_voti = $dbi->prepare("$sqlvoti");
634 $res_voti->execute();
635 }
[353]636 $piuvot=0;
637
638 if ($visvot!='cand') if($tab15=="gruppo" or $genere==4 or ($genere==5 and $votog) or defined('_NULLISTA')) $piuvot=5; else $piuvot=4;
[265]639 for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[0][$y]="&nbsp;";
640 if (strstr( $op,'circo'))
[318]641 $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]642 else
[318]643 $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]644 $lis_sez = $dbi->prepare("$sql");
645 $lis_sez->execute();
646 $nsezsel=$lis_sez->rowCount();
647 while(list($z)=$lis_sez->fetch(PDO::FETCH_NUM))
648 {
649 for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[$z][$y]="&nbsp;";} //inizializza le celle interne
[254]650
651###################################################################
652# for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[0][$y]="&nbsp;";
653# for ($z=1;$z<=($offsetsez-$ominsez);$z++)
654 # for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[$z][$y]="&nbsp;"; //inizializza le celle interne
[265]655 $onetime="";
656 if ($res_voti)
657 {
658 while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){
[254]659 $z=array_search($num_circ, $pos);
[265]660 $valar[($z)][$num_cand]=$voti;
[254]661 }
[318]662
[254]663 foreach ($valar as $key=>$val){
664 if(isset($votitot[($key)]))
665 $percar[$key]=arrayperc($val,$votitot[($key)]);
[318]666
667 }
668 # if($res_voti->rowCount()) {
669 $res_voti = $dbi->prepare("$sqlvoti");
[371]670 $res_voti->execute();
671 if (!$res_voti->rowCount()) {
672 $res_voti = $dbi->prepare("$sqldesc");
673 $res_voti->execute();
674#include("TEST: $sqldesc");
675 }
[318]676 #}
677
[371]678 while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = $res_voti->fetch(PDO::FETCH_NUM)){
[265]679 if($num_cand<$min or $num_cand>$offset) continue;
[318]680 if($genere==4) $sevalidi=$voti;
681
[265]682 if (!isset($temp[$num_cand])) $temp[$num_cand]=0;
[371]683 $temp[$num_cand]+=intval($voti);
[265]684 $z=array_search($num_circ, $pos);
[371]685 if (!$z) $z=$minpos; #continue;
[265]686 if ($num_cand>=$min and $num_cand<=$offset){
[371]687 if(($num_circ>=$minpos and $num_circ <=$maxpos) or $num_circ==''){
[265]688 $ar[0][$num_cand]=$num_cand.") ".$nome;
689 if ($desc_circ && $onetime!=$desc_circ) {$ar[($z)][0].=") ".$desc_circ; $onetime=$desc_circ;}
690 $percento=$voti;
691 if ($perc=='true' and $votitot[($z)])
692 {
693 $percento=$voti."<br /><span class=\"red\" style=\"font-size:80%;\"><i>".number_format($percar[$z][$num_cand],2)." %</i></span>";
694 }
[318]695
[265]696 $ar[($z)][$num_cand]=$percento;
697 }
[254]698 }
[265]699 if (!strstr( $op,'candidato')){
700 if (!isset($tempar[$num_cand])) $tempar[$num_cand]=0;
[371]701 $tempar[$num_cand]+=intval($voti);
[265]702 }
703 if ($visvot!='cand'){
704 $posvoti=($offset);
[353]705 if($tab15=="gruppo" or $genere==4 or ($genere==5 and $votog) or defined('_NULLISTA')){
706 $ar[0][$posvoti+1]='<b>Voti Validi</b>';
707 $ar[0][$posvoti+2]='<b>Schede Nulle</b>';
708 $ar[0][$posvoti+3]='<b>Schede Bianche</b>';
709 $ar[0][$posvoti+4]='<b>Voti Contestati</b>';
710 $ar[0][$posvoti+5]='<b>Voti Nulli</b>';
711 }else{
712 $ar[0][$posvoti+1]='<b>Voti Validi</b>';
713 $ar[0][$posvoti+2]='<b>Voti Nulli</b>';
714 $ar[0][$posvoti+3]='<b>Voti Contestati</b>';
715 $ar[0][$posvoti+4]='<b>Solo Gruppo</b>';
716 }
[265]717 if (($maxpos)>=$num_circ and $minpos<=$num_circ){
718 //$posvoti++;
[318]719 $ar[($z)][$posvoti+1]="<b>$valsez[$z]</b>";
[347]720 $ar[($z)][$posvoti+2]="<b>$nulsez[$z]</b>";
721 $ar[($z)][$posvoti+3]="<b>$biasez[$z]</b>";
722 $ar[($z)][$posvoti+4]="<b>$consez[$z]</b>";
[353]723 if($tab15=="gruppo" or $genere==4 or ($genere==5 and $votog) or defined('_NULLISTA')) $ar[($z)][$posvoti+5]="<b>$vonsez[$z]</b>";
[265]724 }
725 }
[254]726 }
727 }
728
[265]729 if (($offsetsez+1)>=$num_sez){
730 $ar[(1+$numsezmax)][0]="<b>"._TOT."<br />"._COMPLESSIVO."</b>";
731 if(isset($temp)) {
732 if (!isset($tab15) or !$tab15) $tab15="candidati";
[353]733 if($tab15=="gruppo" or $genere==4 or ($genere==5 and $votog) or defined('_NULLISTA')){
[344]734 if($votog) $tab15="lista";
735 $votigl=" sum(validi),sum(nulli),sum(bianchi),sum(contestati),sum(voti_nulli)";
[265]736 }elseif($votog){
[318]737 $votigl=" sum(validi),sum(nulli),sum(bianchi),sum(contestati),sum(voti_nulli)";
[265]738 }else{
[353]739 # if($dettnulli)
740 $votigl=" sum(validi_lista),sum(voti_nulli_lista),sum(contestati_lista),sum(solo_gruppo),0";
741# else $votigl=" sum(validi_lista),sum(nulli),sum(bianchi),sum(contestati_lista),sum(voti_nulli_lista+voti_nulli)";
[265]742 }
[254]743 if($circo)
[318]744 $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]745 else
[318]746 $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]747 $resv = $dbi->prepare("$sql");
[353]748 $resv->execute(); #echo "TEST2: --- $sql";
[265]749 list ($sevaltot,$senultot,$sebiatot,$secontot,$sevnutot)= $resv->fetch(PDO::FETCH_NUM);
[254]750 $voticompl=$sevaltot+$senultot+$sebiatot+$secontot+$sevnutot;
[318]751 $sql="SELECT voti from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons'";
752 $resvt = $dbi->prepare("$sql");
[265]753 $resvt->execute();
754 if($resvt) list($votlt)=$resvt->fetch(PDO::FETCH_NUM); else $votlt=0;
[254]755 if($perc) $temp3=arrayperc($temp,$sevaltot);
[344]756
757 foreach($temp as $key=>$voti) {
[254]758 if ($perc=='true' and $voticompl)
759 {
760 $percento="<b>$voti<br /><span class=\"red\"><i>".$temp3[$key]." %</i></span></b>";
761 } else
762 $percento="<b>$voti</b>";
763 $ar[1+$numsezmax][$key]=$percento;
764 }
765 }
766 if ($visvot!='cand') {
767 $key=$offset+1;
[353]768
769# if(!defined('_NULLISTA'))
770 if($tab15=="gruppo" or $genere==4 or ($genere==5 and $votog) or defined('_NULLISTA'))
771 $tmp=array($sevaltot,$senultot,$sebiatot,$secontot,$sevnutot);
772 else $tmp=array($sevaltot,$senultot,$sebiatot,$secontot);
[254]773 if($perc) $temp3=arrayperc($tmp,$voticompl);
[344]774
775 foreach($tmp as $k=>$voti) {
[254]776 if ($perc=='true' and $voticompl)
777 {
778 $percento="<b>$voti<br /><span class=\"red\"><i>".$temp3[$k]." %</i></span></b>";
779 } else $percento="<b>$voti</b>";
780 $ar[1+$numsezmax][++$key]=$percento;
781
782 }
783 }
784 }
785 if($orvert!=1) {
786 $i=0;
787 foreach ( $ar as $riga) {
788 $y=0;
789 foreach($riga as $cella) {
790 $ra[$y++][$i]=$cella;
791 }
792 $i++;
793 }
794 crea_tabella($ra);
795 }else{
796 crea_tabella($ar);
797 }
798//e' un referendum
799 }else{
[318]800 $sql="SELECT id_gruppo, descrizione,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons order by num_gruppo";
801 $res_lis = $dbi->prepare("$sql");
802 $res_lis->execute();
[254]803
[265]804 if($res_lis) $numliste=$res_lis->rowCount(); else $numliste=0;
805
[254]806 if (!isset($offset)) $offset=10;
807 if (!isset($min)) $min=1;
808 if (!isset($offsetsez)) $offsetsez=25; //lo 0 viene sostituito dal totale di sezioni presenti
809 if (!isset($minsez)) $minsez=1;
810 if (!$csv){
811 echo "<div><h5>$pagina</h5></div>";
812 echo "<form id=\"voti\" method=\"post\" action=\"modules.php\">";
813 echo "<div style=\"text-align:left;width:700px;margin:auto;font-size:12px \">
814 <input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input>";
815 echo "<input type=\"hidden\" name=\"op\" value=\"$op\"></input>";
816 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"></input>";
817 echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>";
818 echo ""._SCELTA." "._CONSULTAZIONE.": <select name=\"id_gruppo\">";
819 if($res_lis)
[265]820 while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) {
[254]821 if (!$id_gruppo) $id_gruppo=$id_rif;
822 $sel = ($id_rif == $id_gruppo) ? "selected=\"selected\"" : "";
823 echo "<option value=\"$id_rif\" $sel>";
824 for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
825 echo $num_lis.") ".strip_tags(substr($descrizione,0,50))."</option>";
826 }
827 echo "</select>";
828 echo "<br />"._VIS_PERC.": <input type=\"checkbox\" name=\"perc\" value=\"true\"";
829 if($perc=='true') echo " checked=\"true\"";
830 echo ">";
831 echo "<br /><input type=\"submit\" name=\"update\" value=\""._RICARICA."\"></form></div>";
832
833
834
835 }
[371]836 if(!$id_gruppo) $id_gruppo=0;
[318]837 $sql="select num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id_gruppo";
838 $res_ref = $dbi->prepare("$sql");
839 $res_ref ->execute();
[265]840
841 $sql="select $tab2, t1.num_gruppo, t1.descrizione , t1.simbolo,
[254]842 sum(t2.si), sum(t2.no),sum(t2.validi), sum(t2.nulli),sum(t2.bianchi), sum(t2.contestati)
843 from ".$prefix."_ele_gruppo as t1
844 left join ".$prefix."_ele_voti_ref as t2 on (t1.id_gruppo=t2.id_gruppo)
845 left join ".$prefix."_ele_sezioni as t3 on (t2.id_sez=t3.id_sez)
846 left join ".$prefix."_ele_sede as t4 on (t3.id_sede=t4.id_sede)
847 left join ".$prefix."_ele_circoscrizione as t5 on (t4.id_circ=t5.id_circ)
848 where t1.id_cons='$id_cons' and t1.id_gruppo=$id_gruppo
[320]849 group by t2.id_gruppo,$tab2, t1.num_gruppo, t1.descrizione , t1.simbolo
[254]850 order by $tab3, t1.num_gruppo
[318]851 ";
852 $res = $dbi->prepare("$sql");
853 $res->execute();
[265]854
[371]855 if($res->rowCount()) $num_sez=$res->rowCount();
856 else
857 {
858 $num_sez=0;
859 }
860 if($res_ref->rowCount()) list($num_gruppo,$descr)= $res_ref->fetch(PDO::FETCH_NUM); else {$num_gruppo=0;$descr='';}
[254]861 if (!$csv){
862 # stampa
863
864 $datipdf="<b>"._COMUNE." $descr_comune</b> - "._RISULTATI.": $descr_cons<br/><b>$pagina</b><br/><br/> ";
865 $datipdf .="<br/><b>Referendum n. ".$num_gruppo." </b><br/>".$descr."";
[371]866 $datipdf=str_replace('"',"'",$datipdf);
[372]867 $_SESSION['datipdf']= $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
[372]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\" ><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\" ><img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"Export Csv\" /></a>";
[254]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>";
[372]897# echo "<input type=\"hidden\" name=\"datipdf\" value=\"$datipdf\"></input>";
[254]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.