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