source: trunk/client/modules/Elezioni/votanti.php@ 10

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

prova di modifica iniziale

File size: 15.0 KB
Line 
1<?php
2/************************************************************************/
3/* Eleonline - Raccolta e diffusione dei dati elettorali */
4/* by Luciano Apolito & Roberto Gigli */
5/* http://www.eleonline.it */
6/* info@eleonline.it luciano@aniene.net rgigli@libero.it */
7/************************************************************************/
8
9if (!defined('MODULE_FILE')) {
10 die ("Non puoi accedere al file direttamente...");
11}
12$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ?
13 $_GET : $_POST;
14
15
16
17$id_comune= (isset($param['id_comune'])) ? $param['id_comune']:$siteistat;
18if (isset($param['id_cons_gen'])) $id_cons_gen=intval($param['id_cons_gen']); else $id_cons_gen='';
19if (isset($param['op'])) $op=$param['op']; else $op='';
20if (isset($param['minsez'])) $minsez=intval($param['minsez']); else $minsez='';
21if (isset($param['id_lista'])) $id_lista=intval($param['id_lista']); else $id_lista='';
22if (isset($param['id_circ'])) $id_circ=intval($param['id_circ']); else $id_circ='';
23if (isset($param['csv'])) $csv=intval($param['csv']); else $csv='';
24if (isset($param['min'])) $min=intval($param['min']); else $min= 0;
25if (isset($param['orvert'])) $orvert=intval($param['orvert']); else $orvert='';
26if (isset($param['offset'])) $offset=intval($param['offset']); else $offset='';
27if (isset($param['offsetsez'])) $offsetsez=intval($param['offsetsez']); else $offsetsez='';
28if (isset($param['perc'])) $perc=$param['perc']; else $perc='';
29if (isset($param['info'])) get_magic_quotes_gpc() ? $info=$param['info']:$info=addslashes($param['info']); else $info='';
30if (isset($param['files'])) get_magic_quotes_gpc() ? $files=$param['files']:$files=addslashes($param['files']); else $files='';
31if (isset($param['voti_lista'])) $voti_lista=intval($param['voti_lista']); else $voti_lista= 0;
32if (isset($param['perc_lista'])) $perc_lista=$param['perc_lista']; else $perc_lista= 0;
33if (isset($param['lettera'])) get_magic_quotes_gpc() ? $lettera=$param['lettera']:$lettera=addslashes($param['lettera']); else $lettera='';
34if (isset($param['id_gruppo'])) $id_gruppo=intval($param['id_gruppo']); else $id_gruppo='';
35if (isset($param['tipo_cons'])) $tipo_cons=intval($param['tipo_cons']); else $tipo_cons='';
36
37$id_comune=intval($id_comune);
38
39
40//$id_cons_gen=$_GET['id_cons_gen'];
41$res = mysql_query("SELECT t1.tipo_cons,t3.genere,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.tipo_cons=t3.tipo_cons and t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'" , $dbi);
42list($tipo_cons,$genere,$id_cons) = mysql_fetch_row($res);
43
44if (isset($param['ops'])) $ops=$param['ops']; else $ops='';
45if (isset($param['pag'])) $pag=$param['pag']; else $pag=0;
46if (isset($param['num_ref'])) $num_ref=$param['num_ref'];
47if (isset($param['num_refs'])) $num_refs=$param['num_refs'];
48$bgcolor2='#cacaca';
49//**************************************************************************
50// ELE
51//**************************************************************************
52//controllo_finale($id_cons);
53
54global $prefix, $dbi,$id_circ,$lang;
55
56include_once("modules/Elezioni/language/lang-$lang.php");
57# testata
58
59if($csv==1){
60 include_once("modules/Elezioni/funzioni.php");
61
62 $res = mysql_query("SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ", $dbi);
63 list($descr_com) = mysql_fetch_row($res);
64 $descr_com =stripslashes($descr_com);
65 $datipdf .= "<div style=\"margin:0px auto; text-align:center;\">";
66 $siteistat=$id_comune;
67 if($xls!=1) $datipdf .= "<table><tr><td><img src=\"modules.php?name=Elezioni&amp;file=foto&amp;id_comune=".$id_comune."\" alt=\"mappa\" /></td><td>";
68 $datipdf .= ""._COMUNE." $descr_com <br/>
69 "._RISULTA." "._CONSULTA."<br/>";
70 $datipdf .= "<h1>$descr_cons</h1>"._DISCLAIMER."";
71 if($xls!=1) $datipdf .= "</td></tr></table>";
72 $datipdf .="</div>";
73
74
75
76
77
78
79}
80
81
82
83 // icone stampa e grafici
84 if ($csv!=1){
85 if (!isset($html)) $html='';
86 $html .= "<div>
87 <a href=\"modules.php?name=Elezioni&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;op=graf_votanti\">
88 "._VER_GRAF." <img class=\"image\" src=\"modules/Elezioni/images/grafici.png\" alt=\"\" /></a>
89 <a href=\"modules.php?name=Elezioni&amp;op=come&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;info=votanti&amp;csv=1&amp;pag=$pag\">"._VER_STAMPA."
90 <img class=\"image\" src=\"modules/Elezioni/images/printer.png\" alt=\"\" /></a>
91 <a href=\"modules.php?name=Elezioni&amp;op=come&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;info=votanti&amp;xls=1&csv=1;&amp;pag=$pag\">
92 <img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"\" /></a>
93
94
95 </div>";
96 }
97
98
99
100 $res = mysql_query("SELECT sum(maschi),sum(femmine) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'", $dbi);
101 list($totm,$totf) = mysql_fetch_row($res);
102 $totel=$totm+$totf;
103 if (!IsSet($pag)) {$pag=0;} //inizializza il numero di pagina
104 if (!IsSet($num_ref)) {
105 $num_ref=1;
106 $resg = mysql_query("SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
107 $num_refs= mysql_num_rows($resg); //quante pagine?
108 }
109 if(($genere!=4) and $pag==0){ //diverso da liste a piu' candidati
110 $ops=4; //gestione gruppi (anche liste uninominali)
111 }else{
112 $ops=3; //gestione liste
113 }
114
115 $resg = mysql_query("SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref", $dbi);
116 list($idg,$numg) = mysql_fetch_row($resg);
117 $res = mysql_query("SELECT id_sez,num_sez,t1.id_sede as id_sede,t2.id_circ as id_circ FROM ".$prefix."_ele_sezioni as t1,".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez ", $dbi);
118 $max = mysql_num_rows($res); //quante sezioni?
119 $res = mysql_query("SELECT id_sez,num_sez,t1.id_sede as id_sede,t2.id_circ as id_circ FROM ".$prefix."_ele_sezioni as t1,".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez ", $dbi);
120 $num_sez = mysql_num_rows($res); //quante sezioni?
121 for ($i=1;$i<=$num_sez;$i++){
122 $sezione[$i]=mysql_fetch_array($res, 3); //inizializza l'array delle sezioni
123 $ar[$i]=0;
124 }
125 $tab3="_ele_voti_lista";
126 if ($genere>0) { //se non e' un referendum
127 if (!($genere==4) and $pag==0){ //se non e' una lista uninominale ed e' la prima pagina
128 $tab="SELECT 0,t2.id_sez,t2.num_sez,t2.validi,'0',t2.validi,t2.nulli,t2.bianchi,t2.contestati, t4.id_circ,t2.id_sede,'0' FROM ".$prefix."_ele_sezioni as t2 left join ".$prefix."_ele_sede as t4 on (t2.id_sede=t4.id_sede) where t2.id_cons='$id_cons' and t2.validi+t2.nulli+t2.bianchi+t2.contestati>0 group by t2.id_sez order by t2.num_sez ";
129
130 }else{ // e' una lista uninominale o la seconda pagina
131 $tab="SELECT '0',t1.id_sez,t1.num_sez,sum(t2.voti),t1.solo_gruppo,t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t1.id_sede,'0'
132 FROM ".$prefix."_ele_sezioni as t1 left join ".$prefix.$tab3." as t2 on (t1.id_sez=t2.id_sez)
133 left join ".$prefix."_ele_sede as t4 on (t1.id_sede=t4.id_sede)
134 where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons group by t2.id_sez order by t1.num_sez ";
135 }
136
137 $riga1 = "<div style=\"margin:0px auto;text-align:center;\">";
138 if($pag==0)$riga1 .="<h2>"._DETTAGLIO." "._VOTIE."</h2></div>";
139 else $riga1 .="<h2>"._DETTAGLIO." "._VOTIE." "._ASOLA_LISTA."</h2></div>";
140
141 }else{ // e' un referendum
142 $tab="SELECT t1.id_gruppo,t1.id_sez,t2.num_sez,t1.si,t1.no,t1.validi,t1.nulli,t1.bianchi,t1.contestati, t4.id_circ,t2.id_sede,t3.num_gruppo
143 FROM ".$prefix."_ele_voti_ref as t1 left join ".$prefix."_ele_sezioni as t2 on (t1.id_sez=t2.id_sez)
144 left join ".$prefix."_ele_gruppo as t3 on (t1.id_gruppo=t3.id_gruppo) left join ".$prefix."_ele_sede as t4 on (t2.id_sede=t4.id_sede)
145 where t1.id_cons='$id_cons' and t1.id_gruppo='$idg' order by t2.num_sez ";
146 $riga1 = "<div style=\"margin:0px auto;text-align:center;\">";
147 $riga1 ="<h2>"._DETTAGLIO." "._VOTIE."</h2></div>";
148
149 $des = mysql_query("select descrizione from ".$prefix."_ele_gruppo where id_gruppo='$idg'", $dbi);
150 list($descrizione)=mysql_fetch_array($des);
151 $riga1 .="<h4>$descrizione</h4>";
152 }
153 $res = mysql_query("$tab ", $dbi);
154 $num_scr = mysql_num_rows($res);
155 //$riga2= "<div>"._SEZSCR." $num_scr su $num_sez</div>";//sezioni scrutinate
156
157 $riga2 = "<table style=\"border:1px solid #6A6A6A;\" summary=\"Tabella dei voti espressi\">";
158 $riga3 = "<tr class=\"bggray\">
159 <td>"._SEZIONI."</td>
160 <td>"._VOTIU."</td>
161 <td>"._VOTID."</td>
162 <td>"._VOTIE."</td>"; //testata con nomi dei campi
163 if ($genere==0) { //se e' un referendum
164 $riga3 .= "<td>"._SI."</td><td>"._NO."</td>";
165 } elseif ((($genere==5) or ($genere==3)) and $pag==1){
166 $riga3 .= "<td>"._ASOLA_LISTA."</td><td>"._ASOLO_GRUPPO."</td>";
167 }
168 $riga3 .= "<td>"._VALIDI."</td><td>"._NULLI."</td><td>"._BIANCHI."</td><td>"._CONTESTATI."</td>"
169 ."</tr>\n";
170 $res = mysql_query("$tab ", $dbi);
171 $num_scr = mysql_num_rows($res);
172 $righe= "";
173 $scrutinate=1;
174 $tot_u=0;$tot_d=0;$tot_voti=0; $tot_si=0;$tot_no=0;$tot_validi=0;$tot_nulli=0;$tot_bianchi=0;$tot_contestati=0;
175 while (list($id_gruppo,$id,$num,$si,$no,$validi,$nulli,$bianchi,$contestati,$id_circ,$id_sede,$gruppo) = mysql_fetch_row($res)){
176 // inserimento numeri di sez non scrutinate
177 while ($scrutinate < $num) {
178 $righe.= "<tr><td><span style=\"color: rgb(255, 0, 0);\">$scrutinate</span></td></tr>\n";
179 $scrutinate++;
180 }
181 $scrutinate++;
182 // fine inserimento
183 $tab2="SELECT max(voti_donne),max(voti_uomini),max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id'";
184 if ($genere==0) $tab2 .= " and id_gruppo=$id_gruppo";
185 $res2 = mysql_query($tab2, $dbi);
186 list($votid,$votiu,$voti) = mysql_fetch_row($res2);
187// $voti=$votiu+$votid;
188 $tot_u+=$votiu;
189 $tot_d+=$votid;
190 $tot_voti+=$voti;
191 $tot_si+=$si;
192 $tot_no+=$no;
193 $tot_validi+=$validi;
194 $tot_nulli+=$nulli;
195 $tot_bianchi+=$bianchi;
196 $tot_contestati+=$contestati;
197 $righe .= "<tr class=\"bggray\">
198 <td>$num</td>
199 <td>".number_format($votiu,0,',','.')."</td>
200 <td>".number_format($votid,0,',','.')."</td>
201 <td>".number_format($voti,0,',','.')."</td>";
202 if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){$righe
203 .= "<td>".number_format($si,0,',','.')."</td>
204 <td>".number_format($no,0,',','.')."</td>";}
205
206 $righe .= "<td>".number_format($validi,0,',','.')."</td>
207 <td>$nulli</td>
208 <td>$bianchi</td>
209 <td>$contestati</td></tr>";
210 }
211 if ($num<$num_sez) {
212 for (;$scrutinate<=$num_sez;$scrutinate++) {
213 $righe .= "<tr><td>";
214 $righe .="<span style=\"color: rgb(255, 0, 0);\">$scrutinate</span></td></tr>";
215 }
216 }
217 if($num_scr){
218 $righet = "<tr class=\"bggray\">
219 <td ></td>
220 <td>"._VOTIU."</td>
221 <td>"._VOTID."</td>
222 <td>"._VOTIE."</td>"; //testata con nomi dei campi
223 if ($genere==0) { //se e' un referendum
224 $righet .= "<td>"._SI."</td><td>"._NO."</td>";
225 } elseif ((($genere==5) or ($genere==3)) and $pag==1){
226 $righet .= "<td>"._ASOLA_LISTA."</td><td>"._ASOLO_GRUPPO."</td>";
227 }
228 if($totel==0) $totelrip="0.00"; else $totelrip=number_format($tot_voti*100/$totel,2);
229 if($totf==0) $totfrip="0.00"; else $totfrip=number_format($tot_d*100/$totf,2);
230 if($totm==0) $totmrip="0.00"; else $totmrip=number_format($tot_u*100/$totm,2);
231 $righet .= "<td>"._VALIDI."</td><td>"._NULLI."</td><td>"._BIANCHI."</td><td>"._CONTESTATI."</td>"
232 ."</tr>
233
234
235
236 <tr class=\"td-vuotoc\"><td><b>"._TOT."</b></td><td><b>".number_format($tot_u,0,',','.')."</b><br /><i>(".$totmrip." %)</i></td><td><b>".number_format($tot_d,0,',','.')."</b><br /><i>(".$totfrip." %)</i></td><td><b>".number_format($tot_voti,0,',','.')."</b><br /><i>(".$totelrip." %)</i></td>";
237
238 // se e' un referendum o una consultazione con raggruppamenti
239
240 if($tot_validi){
241 if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){$righet .= "<td><b>".number_format($tot_si,0,',','.')."</b><br /><i>(".number_format($tot_si*100/$tot_validi,2)." %)</i></td><td><b>".number_format($tot_no,0,',','.')."</b><br /><i>(".number_format($tot_no*100/$tot_validi,2)." %)</i></td>";}
242 $righet .= "<td><b>".number_format($tot_validi,0,',','.')."</b><br /><i>(".number_format($tot_validi*100/$tot_voti,2)." %)</i></td><td><b>"
243 .number_format($tot_nulli,0,',','.')."</b><br /><i>(".number_format($tot_nulli*100/$tot_voti,2)." %)</i></td><td><b>".number_format($tot_bianchi,0,',','.')."</b><br /><i>(".number_format($tot_bianchi*100/$tot_voti,2)." %)</i></td><td><b>".number_format($tot_contestati,0,',','.')."</b><br /><i>(".number_format($tot_contestati*100/$tot_voti,2)." %)</i></td></tr>";
244 }else{
245 if ($genere==0 or ((($genere==5) or ($genere==3)) and $pag==1)){$righet .= "<td><b>".number_format($tot_si,0,',','.')."</b><br /><i>(0.00 %)</i></td><td><b>".number_format($tot_no,0,',','.')."</b><br /><i>(0.00 %)</i></td>";}
246 $righet .= "<td><b>0</b><br /><i>(0.00 %)</i></td><td><b>"
247 .number_format($tot_nulli,0,',','.')."</b><br /><i>(".number_format($tot_nulli*100/$tot_voti,2)." %)</i></td><td><b>".number_format($tot_bianchi,0,',','.')."</b><br /><i>(".number_format($tot_bianchi*100/$tot_voti,2)." %)</i></td><td><b>".number_format($tot_contestati,0,',','.')."</b><br /><i>(".number_format($tot_contestati*100/$tot_voti,2)." %)</i></td></tr>";
248 }
249 }
250 $righe .= "</table>";
251
252 $html .= "$riga1";
253 $html .= $riga2."";
254 $html .= $righet;
255 $html .= $riga3;
256 $html .= $righe;
257
258
259 $html .="<div>";
260 if($genere==0){ //se e' referendum
261 #'Pagina precedente' e 'Pagina Successiva'
262 $cur=$num_ref;
263 if ($cur>1) {
264 $num_ref--;
265 $html .= "<a href=\"modules.php?name=Elezioni&amp;op=come&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;info=votanti&amp;num_ref=$num_ref&amp;num_refs=$num_refs&amp;csv=$csv\">";
266 $html .= "[ <b>"._PREV_MATCH."</b> ]</a>";
267 }
268 if ($cur<$num_refs) {
269 $cur++;
270 $html .= "<a href=\"modules.php?name=Elezioni&amp;op=come&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;info=votanti&amp;num_ref=$cur&amp;num_refs=$num_refs&amp;csv=$csv\">";
271
272 $html .= "[ <b>"._NEXT_MATCH."</b> ]</a>";
273 }
274 }elseif((($genere==5) or ($genere==3))){ //se vi sono raggruppamenti
275 if($csv!=1){
276
277 $pag=($pag==0 ? 1:0);
278 $html .= "<a href=\"modules.php?name=Elezioni&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;op=come&amp;info=votanti&amp;pag=$pag&amp;csv=$csv\"><b>";
279 if($pag) $html .= _VOTIL;
280 //_CONTR_CONS;
281 else $html .= _VOTIE;
282 //_CONTR_ESPR;
283 $html .= "</b></a>";
284 }
285 }
286
287
288if($csv==1){
289 $data=date("d-m-y G:i");
290 $html .="<br/><div style=\"margin:0px auto;text-align:center;\"><i>Stampato: $data</i></div>";
291 $html .="<br/><div style=\"text-align:center;\"><i>Eleonline by l. apolito & r. gigli - www.eleonline.it</i></div>";
292 //$html .= $html;
293
294}
295$html .= "</div>";
296
297
298############### stampa
299if ($xls!='1'){
300 echo "$datipdf $html";
301}else{
302 $nomefile="export.xls";
303 header ("Content-Type: application/vnd.ms-excel");
304 header ("Content-Disposition: inline; filename=$nomefile");
305
306 echo "$datipdf";
307 echo "$html \n";
308}
309
310
311if($csv!=1 ) include ("footer.php");
312
313
314
315?>
Note: See TracBrowser for help on using the repository browser.