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

Last change on this file since 174 was 174, checked in by roby, 12 years ago

sistemazioni su report voti - da terminare

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