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

Last change on this file since 261 was 261, checked in by roby, 7 years ago

ulteriori correzioni alla rev 259

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