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

Last change on this file since 250 was 225, checked in by roby, 10 years ago

client: ulteriore modifica della funzione di proiezione del consiglio comunale

  • predisposta la possibilità di modifica del nome. a volte troppo lungo, del file dai dati da scaricare (da terminare)
File size: 41.3 KB
RevLine 
[2]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}
[74]12if ($xls=='1' or $pdf=='1') {
13include_once("modules/Elezioni/language/lang-$lang.php");
14include_once("modules/Elezioni/funzioni.php");
15}
[2]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='';
[118]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='';
[12]41# anti-xss nov. 2009
42$id_comune=htmlentities($id_comune);
43$id_comune=intval($id_comune);
[39]44$perc=htmlentities($perc);
[12]45$perc_lista=floatval($perc_lista);
[39]46#$datipdf= htmlentities($datipdf);
[12]47$op= htmlentities($op);
48$info= htmlentities($info);
49$files=htmlentities($files);
50$lettera=htmlentities($lettera);
[118]51$orienta=htmlentities($orienta);
52$formato=htmlentities($formato);
[2]53
54
55
56
57
[118]58include("crea_pagina.php");
[2]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 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) = 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;
[128]80 global $id_comune,$id_cons_gen,$op,$minsez,$id_lista,$id_circ,$csv,$min,$orienta,$formato,
[225]81 $orvert,$offset,$offsetsez,$perc,$info,$files,$nomefile;
82 $nomefile="";
[2]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
[20]95 if (strstr( $op,'circo')) { //$op=='gruppo_circo' or $op=='lista_circo') {
[2]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 }
[20]110 if (strstr( $op,"gruppo")){
[2]111 $tab="gruppo";
[20]112 }elseif (strstr( $op,'lista')) {
[2]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 }
[118]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
[2]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
[20]184 if(strstr( $op,"circo")) {
[2]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='';
[104]205
206 if (!$csv) echo "<div><h5>$pagina</h5></div>";
[118]207 if (!$csv) echo "<div style=\" text-align:left; margin-left:20px;\">";
[104]208
[20]209 if(strstr( $op,'candidato')){
[2]210// $numliste=mysql_num_rows($res_lis);
211 $visvot="cand";
212 if (!$csv){
[104]213
214
[2]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
[104]217 echo "<p>"._SCEGLI_LISTA.":
[2]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
[174]274 if ($votog) $votigl=" (t3.validi_lista),(t3.nulli),(t3.bianchi),(t3.contestati),(t3.voti_nulli)";
[146]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)";
[2]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) {
[104]311 if(strstr( $op,'lista')){$scelta=_SCEGLI_LISTA;}else{$scelta=_SCEGLI_CANDI;}
312 echo "<p>$scelta "._DA.":&nbsp; <select name=\"min\" class=\"modulo\">";
[2]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 }
[104]321 echo "</select>";
322 echo "&nbsp;&nbsp;"._A.":&nbsp; <select name=\"offset\" class=\"modulo\">";
[2]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 }
[104]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
[2]358 if(!$circo)
[104]359
360 echo "<div style=\"margin-left:10px;\"><br/>"._MOSTRA." $tipo2 "._PERCOL."<input type=\"radio\" name=\"orvert\" $righe value=\"0\"></input>"._PERRIGHE." <input
[2]361 type=\"radio\" name=\"orvert\" $colonne value=\"1\"></input>";
362 echo "<input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input>
[104]363 </div>";
[2]364
365
366
[104]367 echo "<p>";
[20]368 if (!strstr( $op,'candidato')) {
[104]369 echo ""._VIS_PERC.": <input type=\"checkbox\" name=\"perc\" value=\"true\"";
[2]370 if($perc=='true') echo " checked=\"true\"";
[104]371 echo "></input><br/>";
[2]372 }
[104]373 echo "";
[82]374 if($circo)
375 echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"></input>";
[2]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
[105]382 echo " <input type=\"submit\" name=\"update\" value=\""._RICARICA."\"></input></p></div></form>";
[2]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
[20]391 if (!strstr( $op,'candidato')) {
[2]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
[30]405 if (!isset($list2)) $list2='';
[20]406 if (strstr( $op,'candidato')) {
[2]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);
[225]409 $nomefile=" Lista n. $num_lista2 - $descr_lista2 ";
[2]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='';}
[225]420 if(!isset($tab15)) $tab15='';
421 $nomefile.="$descr_cons $tab15";
422 $_SESSION['nomefile']=strip_tags(str_replace(" ", "_", $nomefile));
[82]423 $datipdf="<b>"._COMUNE." $descr_comune</b> - "._RISULTATI.": $descr_cons<br/><b>$pagina</b><br/><br/> $list1 $list2 $list3 ";
[104]424
[2]425
426 # verificare la stampa sulle circoscrizioni
[118]427
[119]428 echo "<div style=\"text-align:right;width:900px;margin-left:10px;margin-right:0px;font-size:12px; \">";
[123]429 echo "<table style=\"text-align:center;margin-right:0px;border-top : 1px solid Blue;width: 140px;\"><tr style=\" background:#eceff5;\"><td>"._ESPORTA."<br />";
[118]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{
[105]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>";
[119]434
[118]435 echo "<img class=\"image\" src=\"modules/Elezioni/images/rss.png\" alt=\"Export rss\" />";
436
[119]437 echo " </td></tr> ";
[118]438
[119]439 # stampa pdf
[118]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>";
[128]447 echo "<input type=\"hidden\" name=\"orvert\" value=\"$orvert\"></input>";
[118]448 echo "<input type=\"hidden\" name=\"min\" value=\"$min\"></input>";
[147]449 echo "<input type=\"hidden\" name=\"offset\" value=\"$offset\"></input>";
[118]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>";
[225]456# echo "<input type=\"hidden\" name=\"name\" value=\"$elezioni\"></input>";
[118]457 echo "<input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input>";
458
[119]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
[118]463 type=\"radio\" name=\"orienta\" $port value=\"P\"></input><br />";
[119]464 echo "&nbsp; A3<input type=\"radio\" name=\"formato\" $A3 value=\"A3\"></input>A4<input
[118]465 type=\"radio\" name=\"formato\" $A4 value=\"A4\"></input>";
466
467
468 echo " </td></tr></table></form> ";
469
470
[2]471 }
[118]472
473
474
475 echo "</div></br />";
[104]476 /*
[118]477
[104]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/>";
[2]481
[20]482 if (strstr( $op,'candidato')) echo $list2;
[104]483 */
[2]484
485 }
[105]486
[2]487 if (!$csv){
[118]488 echo "<h5> Sezioni scrutinate";
[104]489 if ($tipo_cons!=4) echo ": $tot_scr su $tot_sez &nbsp;&nbsp;&nbsp; ";
[118]490 echo "</h5>&nbsp;";
[2]491 }
[105]492
[2]493 $y=1;
[113]494 $ar[0][0]=$tipo3;
495 $ra[0][0]=$tipo3;
[2]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;
[66]504 $valar=array();$percar=array();
[14]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;
[82]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);
[14]511 for ($z=1;$z<=($offsetsez-$ominsez);$z++) {
512 $res=mysql_fetch_row($res_numsez);
[105]513
[82]514##############inserimento percentuale di scrutinio nella sezione
[85]515 $scruvalidi=0;
516 $scrunulli=0;
[82]517 $grpercscru=0;
518 if($op=="gruppo_sezione")
[152]519 $resperc=mysql_query("select sum(validi),sum(nulli+bianchi+contestati+voti_nulli+solo_lista) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'",$dbi);
[176]520 elseif($op=="lista_sezione" and $votog)
521 $resperc=mysql_query("select sum(validi),sum(nulli+bianchi+contestati+voti_nulli) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'",$dbi);
522
[82]523 elseif($op=="lista_sezione")
[146]524 $resperc=mysql_query("select sum(validi_lista),sum(nulli+bianchi+contestati+voti_nulli+contestati_lista+solo_gruppo+voti_nulli_lista) from ".$prefix."_ele_sezioni where id_sez='".$res[1]."'",$dbi);
[85]525 if (isset($resperc) and $resperc)
[82]526 list($scruvalidi,$scrunulli)=mysql_fetch_row($resperc);
527 $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);
528 if ($resperc)
529 list($totschede)=mysql_fetch_row($resperc);
530 if (isset($totschede) and $totschede>0 )
531 $grpercscru=number_format(($scruvalidi+$scrunulli)*100/$totschede,0);
532
533################### <span class=\"red\"><i>".$temp3[$key]." %</i></span>
[104]534 $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>"; }
[14]535 $pos[$z]=$res[0];
[66]536 #$valar[$z]=array();
[14]537 }
[105]538
539
[30]540 if (!isset($pos)) $pos[0]=0;
[14]541 $minpos=min($pos);
542 $maxpos=max($pos);
543 ////////////////////////////////////////////////////////////////////
[105]544
[2]545 if ($res_voti)
546 while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = mysql_fetch_row($res_voti)){
[14]547 if ($num_circ<$minpos or $num_circ>$maxpos) continue;
548 $z=array_search($num_circ, $pos);
549 if (!isset($votitot[($z)])) {
550 $votitot[($z)]=0;
[2]551 $sevaltot+=$sevalidi;
552 $senultot+=$senulli;
553 $sebiatot+=$sebianchi;
554 $secontot+=$secontestati;
555 $sevnutot+=$sevonulli;
556 }
[14]557 $votitot[($z)]+=$voti;
[2]558 $voticompl+=$voti;
559 }
560 if ($voticompl) mysql_data_seek($res_voti,0);
561 $piuvot=0;
562 if ($visvot!='cand') $piuvot=5;
563
564
565
566
567 for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[0][$y]="&nbsp;";
568 for ($z=1;$z<=($offsetsez-$ominsez);$z++)
[14]569 for ($y=$min;$y<=($offset+$piuvot);$y++) $ar[$z][$y]="&nbsp;"; //inizializza le celle interne
[16]570 $onetime="";
[2]571 if ($res_voti)
[66]572 {
[102]573 while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = mysql_fetch_row($res_voti)){
[66]574 $z=array_search($num_circ, $pos);
575 $valar[($z)][$num_cand]=$voti;
[82]576 }
577 foreach ($valar as $key=>$val){
[225]578 if(isset($votitot[($key)]))
[66]579 $percar[$key]=arrayperc($val,$votitot[($key)]);
580 }
[82]581
[66]582 mysql_data_seek($res_voti,0);
[2]583 while (list($num_circ,$desc_circ,$num_cand,$nome,$voti,$sevalidi,$senulli,$sebianchi,$secontestati,$sevonulli) = mysql_fetch_row($res_voti)){
[103]584 $z=array_search($num_circ, $pos);
[2]585 if ($num_cand>=$min and $num_cand<=$offset){
[14]586 if($num_circ>=$minpos and $num_circ <=$maxpos){
[2]587 $ar[0][$num_cand]=$num_cand.") ".$nome;
[16]588 if ($desc_circ && $onetime!=$desc_circ) {$ar[($z)][0].=") ".$desc_circ; $onetime=$desc_circ;}
[2]589 $percento=$voti;
[14]590 if ($perc=='true' and $votitot[($z)])
[2]591 {
[111]592 $percento=$voti."<br /><span class=\"red\" style=\"font-size:80%;\"><i>".number_format($percar[$z][$num_cand],2)." %</i></span>";
[2]593 }
[14]594 $ar[($z)][$num_cand]=$percento;
[2]595 }
596 if (!isset($temp[$num_cand])) $temp[$num_cand]=0;
597 $temp[$num_cand]+=$voti;
[14]598
[2]599 }
[102]600 if (!isset($tempar[$num_cand])) $tempar[$num_cand]=0;
601 $tempar[$num_cand]+=$voti;
[2]602 if ($visvot!='cand'){
603 $posvoti=($offset);
604 $ar[0][$posvoti+1]='<b>Voti Validi</b>';
605 $ar[0][$posvoti+2]='<b>Schede Nulle</b>';
606 $ar[0][$posvoti+3]='<b>Schede Bianche</b>';
607 $ar[0][$posvoti+4]='<b>Voti Contestati</b>';
608 $ar[0][$posvoti+5]='<b>Voti Nulli</b>';
[14]609 if (($maxpos)>=$num_circ and $minpos<=$num_circ){
[2]610 $posvoti++;
[14]611 $ar[($z)][$posvoti++]="<b>$sevalidi</b>";
612 $ar[($z)][$posvoti++]="<b>$senulli</b>";
613 $ar[($z)][$posvoti++]="<b>$sebianchi</b>";
614 $ar[($z)][$posvoti++]="<b>$secontestati</b>";
615 $ar[($z)][$posvoti]="<b>$sevonulli</b>";
[2]616 }
617 }
618 }
[66]619 }
[2]620 if (($offsetsez+1)>=$num_sez){
621 $ar[(2+$offsetsez-$minsez)][0]="<b>"._TOT."<br />"._COMPLESSIVO."</b>";
622 if(isset($temp)) {
[79]623 if (!isset($tab15)) $tab15="candidati";
[64]624 if($tab15=="gruppo"){
625 $votigl=" sum(validi),sum(nulli),sum(bianchi),sum(contestati),sum(voti_nulli)";
[177]626 }elseif($votog){
627 $votigl=" sum(validi_lista),sum(nulli),sum(bianchi),sum(contestati_lista),sum(voti_nulli)";
[64]628 }else{
[181]629 //$votigl=" sum(validi_lista),sum(nulli),sum(bianchi),sum(contestati_lista),sum(voti_nulli_lista)";
630 $votigl=" sum(validi_lista),sum(nulli),sum(bianchi),sum(contestati_lista),sum(voti_nulli)";
[64]631 }
[82]632 if($circo)
633 $resv = mysql_query("SELECT $votigl from ".$prefix."_ele_sezioni AS t1
634LEFT 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);
635 else
636 $resv = mysql_query("SELECT $votigl from ".$prefix."_ele_sezioni where id_cons='$id_cons'",$dbi);
[64]637 list ($sevaltot,$senultot,$sebiatot,$secontot,$sevnutot)= mysql_fetch_row($resv);
638 $voticompl=$sevaltot+$senultot+$sebiatot+$secontot+$sevnutot;
639 $resvt = mysql_query("SELECT voti from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons'",$dbi);
640 list($votlt)=mysql_fetch_row($resvt);
[102]641 $temp3=arrayperc($tempar,$sevaltot);
[2]642 while (list($key,$voti)= each($temp)) {
643 if ($perc=='true' and $voticompl)
644 {
[65]645 $percento="<b>$voti<br /><span class=\"red\"><i>".$temp3[$key]." %</i></span></b>";
[66]646 } else
647 $percento="<b>$voti</b>";
[2]648 $ar[2+$offsetsez-$minsez][$key]=$percento;
649 }
650 }
651 if ($visvot!='cand') {
652 $key=$offset+1;
653 $tmp=array($sevaltot,$senultot,$sebiatot,$secontot,$sevnutot);
[65]654 $temp3=arrayperc($tmp,$voticompl);
655 while(list($k,$voti)= each($tmp)) {
656
657 if ($perc=='true' and $voticompl)
658 {
659 $percento="<b>$voti<br /><span class=\"red\"><i>".$temp3[$k]." %</i></span></b>";
660 } else $percento="<b>$voti</b>";
661 $ar[2+$offsetsez-$minsez][++$key]=$percento;
[2]662
663 }
664 }
665 }
666 if($orvert!=1) {
667 $i=0;
668 foreach ( $ar as $riga) {
669 $y=0;
670 foreach($riga as $cella) {
671 $ra[$y++][$i]=$cella;
672 }
673 $i++;
674 }
675 crea_tabella($ra);
676 }else{
677 crea_tabella($ar);
678 }
679//e' un referendum
680 }else{
681 $res_lis = mysql_query("SELECT id_gruppo, descrizione,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons order by num_gruppo",$dbi);
682 $numliste=mysql_num_rows($res_lis);
683
684 if (!isset($offset)) $offset=10;
685 if (!isset($min)) $min=1;
686 if (!isset($offsetsez)) $offsetsez=25; //lo 0 viene sostituito dal totale di sezioni presenti
687 if (!isset($minsez)) $minsez=1;
[115]688 if (!$csv){
689 echo "<div><h5>$pagina</h5></div>";
690 echo "<form id=\"voti\" method=\"post\" action=\"modules.php\">";
691 echo "<div style=\"text-align:left;width:700px;margin:auto;font-size:12px \">
692 <input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input>";
693 echo "<input type=\"hidden\" name=\"op\" value=\"$op\"></input>";
694 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"></input>";
695 echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>";
696 echo ""._SCELTA." "._CONSULTAZIONE.": <select name=\"id_gruppo\">";
697 while(list($id_rif,$descrizione,$num_lis) = mysql_fetch_row($res_lis)) {
698 if (!$id_gruppo) $id_gruppo=$id_rif;
699 $sel = ($id_rif == $id_gruppo) ? "selected=\"selected\"" : "";
700 echo "<option value=\"$id_rif\" $sel>";
701 for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
702 echo $num_lis.") ".strip_tags(substr($descrizione,0,50))."</option>";
703 }
704 echo "</select>";
705 echo "<br />"._VIS_PERC.": <input type=\"checkbox\" name=\"perc\" value=\"true\"";
706 if($perc=='true') echo " checked=\"true\"";
707 echo ">";
708 echo "<br /><input type=\"submit\" name=\"update\" value=\""._RICARICA."\"></form></div>";
709
710
711
[2]712 }
[115]713
[2]714 $res_ref= mysql_query("select num_gruppo,descrizione from ".$prefix."_ele_gruppo where id_gruppo=$id_gruppo", $dbi);
715 $res = mysql_query("select $tab2, t1.num_gruppo, t1.descrizione , t1.simbolo,
716 sum(t2.si), sum(t2.no),sum(t2.validi), sum(t2.nulli),sum(t2.bianchi), sum(t2.contestati)
717 from ".$prefix."_ele_gruppo as t1
718 left join ".$prefix."_ele_voti_ref as t2 on (t1.id_gruppo=t2.id_gruppo)
719 left join ".$prefix."_ele_sezioni as t3 on (t2.id_sez=t3.id_sez)
720 left join ".$prefix."_ele_sede as t4 on (t3.id_sede=t4.id_sede)
721 left join ".$prefix."_ele_circoscrizione as t5 on (t4.id_circ=t5.id_circ)
722 where t1.id_cons='$id_cons' and t1.id_gruppo=$id_gruppo
723 group by t2.id_gruppo,$tab3
724 order by $tab3, t1.num_gruppo
725 ", $dbi);
726 $num_sez=mysql_num_rows($res);
727 list($num_gruppo,$descr)= mysql_fetch_row($res_ref);
[115]728
729 if (!$csv){
730 # stampa
731
732 $datipdf="<b>"._COMUNE." $descr_comune</b> - "._RISULTATI.": $descr_cons<br/><b>$pagina</b><br/><br/> ";
733 $datipdf .="<br/><b>Referendum n. ".$num_gruppo." </b><br/>".$descr."";
[118]734 echo "<div style=\"text-align:right;width:900px;margin-left:10px;margin-right:20px;font-size:12px \">";
[123]735 echo "<table style=\"text-align:center;margin-right:0px;border-top : 1px solid Blue;width: 140px;\"><tr style=\" background:#eceff5;\"><td>"._ESPORTA."<br />";
[115]736
737 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>";
738 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>";
739
[118]740 //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>";
[115]741
[118]742
743 echo "<img class=\"image\" src=\"modules/Elezioni/images/rss.png\" alt=\"Export rss\" />";
744
[119]745 echo " </td></tr>";
[118]746
747
748 echo "<form id=\"pdf\" method=\"post\" action=\"modules.php\">";
749
750 echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"></input>";
751 echo "<input type=\"hidden\" name=\"op\" value=\"$op\"></input>";
752 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"></input>";
753 echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>";
754 echo "<input type=\"hidden\" name=\"csv\" value=\"1\"></input>";
[128]755 echo "<input type=\"hidden\" name=\"orvert\" value=\"$orvert\"></input>";
[118]756 echo "<input type=\"hidden\" name=\"min\" value=\"$min\"></input>";
[128]757 echo "<input type=\"hidden\" name=\"offset\" value=\"$offset\"></input>";
[118]758 echo "<input type=\"hidden\" name=\"minsez\" value=\"$minsez\"></input>";
759 echo "<input type=\"hidden\" name=\"offsetsez\" value=\"$offsetsez\"></input>";
760 echo "<input type=\"hidden\" name=\"perc\" value=\"$perc\"></input>";
761 echo "<input type=\"hidden\" name=\"id_gruppo\" value=\"$id_gruppo\"></input>";
762 echo "<input type=\"hidden\" name=\"pdf\" value=\"1\"></input>";
763 echo "<input type=\"hidden\" name=\"datipdf\" value=\"$datipdf\"></input>";
764 echo "<input type=\"hidden\" name=\"name\" value=\"Elezioni\"></input>";
765
[119]766 echo "<tr><td>";
767 echo "<input type=\"image\" name=\"submit\" src=\"modules/Elezioni/images/pdf.gif\" align=\"left\">";
768 echo "&nbsp; L &nbsp;<input type=\"radio\" name=\"orienta\" $land value=\"L\"></input>P &nbsp;<input
[118]769 type=\"radio\" name=\"orienta\" $port value=\"P\"></input><br />";
[119]770 echo "&nbsp; A3<input type=\"radio\" name=\"formato\" $A3 value=\"A3\"></input>A4<input
[118]771 type=\"radio\" name=\"formato\" $A4 value=\"A4\"></input>";
772
773
774 echo " </td></tr></table></form> ";
775
776
777
778
779
780
781
782
783
[115]784 echo "</div>";
785
786
787// numero sezioni scrutinate
788 $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);
789 $numero=mysql_num_rows($res4);
790 $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);
791 $sezioni=mysql_num_rows($res5);
792
793 if ($numero!=0) echo "<h5><i> "._SEZSCRU." $numero "._SU." $sezioni </i></h5>";
794
795}
[128]796 $res5=mysql_query("select count(0) from ".$prefix."_ele_sezioni where id_cons='$id_cons'", $dbi);
797 list($num_sez) = mysql_fetch_row($res5);
[115]798
799
800
801
802
803 if (!$csv)echo "<b>Referendum n. ".$num_gruppo." </b><br />".$descr."";
804
[2]805 $y=1;
806 $ar[0][0]=$tipo2;
807 $ar[0][1]=_SI;
808 $ar[0][2]=_NO;
809 $ar[0][3]=_VALIDI;
810 $ar[0][4]=_NULLI;
811 $ar[0][5]=_BIANCHI;
812 $ar[0][6]=_CONTESTATI;
813
814 while (list($num_gruppo,$desc_ref) = mysql_fetch_row($res_ref)){
815 $ar[0][$i++]= $num_gruppo.") ".$desc_ref;
816 $ar[1][$y++]= "SI";
817 $ar[1][$y++]= "NO";
818 }
819 $num_sez++;
820 $tot_si=0;
821 $tot_no=0;
822 $tot_va=0;
823 $tot_nu=0;
824 $tot_bi=0;
825 $tot_co=0;
826 while (list($num_circ,$desc_circ,$num_gruppo,$desc_ref,$simbolo,$si,$no,$validi,$nulli,$bianchi, $contestati) = mysql_fetch_row($res)){
827 $i=1;
828 $votanti=$validi+$nulli+$bianchi+$contestati;
829 $tot_si+=$si;
830 $tot_no+=$no;
831 $tot_va+=$validi;
832 $tot_nu+=$nulli;
833 $tot_bi+=$bianchi;
834 $tot_co+=$contestati;
835 $ar[$num_circ][0]=$num_circ."<br />".$desc_circ;
836 if($validi){
[115]837 $ar[$num_circ][$i++]= $perc=='true' ? $si."<br /><span class=\"red\"><i>".number_format($si*100/$validi,2)."%</i></span>":$si;
838 $ar[$num_circ][$i++]= $perc=='true' ? $no."<br /><span class=\"red\"><i>".number_format($no*100/$validi,2)."%</i></span>":$no;
[2]839 }else{
[115]840 $ar[$num_circ][$i++]= $perc=='true' ? $si."<br /><span class=\"red\"><i>0.00%</i></span>":$si;
841 $ar[$num_circ][$i++]= $perc=='true' ? $no."<br /><span class=\"red\"><i>0.00%</i></span>":$no;
[2]842 }
843 if($votanti){
[115]844 $ar[$num_circ][$i++]= $perc=='true' ? $validi."<br /><span class=\"red\"><i>".number_format($validi*100/$votanti,2)."%</i></span>":$validi;
845 $ar[$num_circ][$i++]= $perc=='true' ? $nulli."<br /><span class=\"red\"><i>".number_format($nulli*100/$votanti,2)."%</i></span>":$nulli;
846 $ar[$num_circ][$i++]= $perc=='true' ? $bianchi."<br /><span class=\"red\"><i>".number_format($bianchi*100/$votanti,2)."%</i></span>":$bianchi;
847 $ar[$num_circ][$i++]= $perc=='true' ? $contestati."<br /><span class=\"red\"><i>".number_format($contestati*100/$votanti,2)."%</i></span>":$contestati;
[2]848 }else{
[115]849 $ar[$num_circ][$i++]= $perc=='true' ? $validi."<br /><span class=\"red\"><i>0.00%</i></span>":$validi;
850 $ar[$num_circ][$i++]= $perc=='true' ? $nulli."<br /><span class=\"red\"><i>0.00%</i></span>":$nulli;
851 $ar[$num_circ][$i++]= $perc=='true' ? $bianchi."<br /><span class=\"red\"><i>0.00%</i></span>":$bianchi;
852 $ar[$num_circ][$i++]= $perc=='true' ? $contestati."<br /><span class=\"red\"><i>0.00%</i></span>":$contestati;
[2]853 }
854 }
855 $i=1;
856 $tot_vo=$tot_va+$tot_nu+$tot_bi+$tot_co;
857# if($tot_va==0) $tot_va=1;
858# if($tot_vo==0) $tot_vo=1;
859 $ar[$num_sez][0]=_TOT."<br />"._COMPLESSIVO;
860 if($tot_va){
861 $ar[$num_sez][$i++]= $perc=='true' ? $tot_si."<br /><span class=\"red\">".number_format($tot_si*100/$tot_va,2)."%</span>":$tot_si;
862 $ar[$num_sez][$i++]= $perc=='true' ? $tot_no."<br /><span class=\"red\">".number_format($tot_no*100/$tot_va,2)."%</span>":$tot_no;
863 }else{
864 $ar[$num_sez][$i++]= $perc=='true' ? $tot_si."<br /><span class=\"red\">0.00%</span>":$tot_si;
865 $ar[$num_sez][$i++]= $perc=='true' ? $tot_no."<br /><span class=\"red\">0.00%</span>":$tot_no;
866 }
867 if($tot_vo){
868 $ar[$num_sez][$i++]= $perc=='true' ? $tot_va."<br /><span class=\"red\">".number_format($tot_va*100/$tot_vo,2)."%</span>":$tot_va;
869 $ar[$num_sez][$i++]= $perc=='true' ? $tot_nu."<br /><span class=\"red\">".number_format($tot_nu*100/$tot_vo,2)."%</span>":$tot_nu;
870 $ar[$num_sez][$i++]= $perc=='true' ? $tot_bi."<br /><span class=\"red\">".number_format($tot_bi*100/$tot_vo,2)."%</span>":$tot_bi;
871 $ar[$num_sez][$i++]= $perc=='true' ? $tot_co."<br /><span class=\"red\">".number_format($tot_co*100/$tot_vo,2)."%</span>":$tot_co;
872 }else{
873 $ar[$num_sez][$i++]= $perc=='true' ? $tot_va."<br /><span class=\"red\">0.00%</span>":$tot_va;
874 $ar[$num_sez][$i++]= $perc=='true' ? $tot_nu."<br /><span class=\"red\">0.00%</span>":$tot_nu;
875 $ar[$num_sez][$i++]= $perc=='true' ? $tot_bi."<br /><span class=\"red\">0.00%</span>":$tot_bi;
876 $ar[$num_sez][$i++]= $perc=='true' ? $tot_co."<br /><span class=\"red\">0.00%</span>":$tot_co;
877 }
878 crea_tabella($ar);
879 }
880 if ($csv) echo "</body>\n</html>";
881}
882
883?>
Note: See TracBrowser for help on using the repository browser.