source: trunk/client/modules/Elezioni/affluenze-inc.php@ 388

Last change on this file since 388 was 376, checked in by roby, 2 years ago

Admin:

  • modificata la funzione aggiornadb per gestire il caso di cambiamento del nome del superutente e tolto il default per tipi campo text
  • modificata la funzione dei controlli per gestire il tipo consultazione Regionali in Sicilia

Install:

  • modificata la funzione di installazione per compatibilità con php 8.0

Client:

  • cambiata l'immagine "vuoto.jpg" nel formato png per gestire la trasparenza
  • modificate le funzioni affluenze e votanti per correggere l'esportazione in pdf e le stampe
  • per il tema Futura2 eliminato il taglio della descrizione della consultazione
File size: 13.7 KB
RevLine 
[376]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
9if (!defined('MODULE_FILE')) {
10 die ("You can't access this file directly...");
11}
12
13if (isset($param['id_cons_gen'])) $id_cons_gen=intval($param['id_cons_gen']); else $id_cons_gen='';
14if (isset($param['num_ref'])) $num_ref=intval($param['num_ref']);
15if (isset($param['num_refs'])) $num_refs=intval($param['num_refs']);
16if (isset($param['id_comune'])) $id_comune=intval($param['id_comune']);
17if (isset($param['xls'])) $xls=intval($param['xls']);
18if (isset($param['pdf'])) $pdf=intval($param['pdf']);
19$sql="SELECT t1.tipo_cons,t3.genere,t2.id_cons,t2.vismf 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'";
20$res = $dbi->prepare("$sql");
21$res->execute();
22list($tipo_cons,$genere,$id_cons,$vismf) = $res->fetch(PDO::FETCH_NUM);
23global $lang,$circo,$id_circ;
24
25if (isset($circo) and $circo) $circos="and t2.id_circ='$id_circ'";
26else $circos='';
27
28# testata
29include_once("modules/Elezioni/language/lang-$lang.php");
30$datipdf='';
31if($csv==1){
32 include_once("modules/Elezioni/funzioni.php");
33
34 $sql="SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
35 $res = $dbi->prepare("$sql");
36 $res->execute();
37 list($descr_com) = $res->fetch(PDO::FETCH_NUM);
38 $descr_com =stripslashes($descr_com);
39 $datipdf .= "<div style=\"margin:0px auto; text-align:center;\">";
40 $siteistat=$id_comune;
41 # salva sull'hardisk lo stemma del comune
42 $logo=verificasimbolo();
43 $immagine= "<img src=\"modules/Elezioni/images/$logo\" alt=\"logo\" align=\"left\"/>";
44
45 if($xls!=1) $datipdf .= "<table><tr><td>$immagine</td><td>";
46
47 $datipdf .= ""._COMUNE." $descr_com <br />
48 "._RISULTA." "._CONSULTA."<br/ >";
49 $datipdf .= "$descr_cons<br />"._DISCLAIMER."
50 <br /><b>"._DETTAGLIO." "._AFFLUENZE."</b>";
51 if($xls!=1) $datipdf .= "</td></tr></table>";
52 $datipdf .="</div>";
53
54 $html = "<style type=\"text/css\">
55 <!--
56
57 .td-89 {
58 width: 89%;
59 border: 1px;
60 text-align: left;
61 }
62 .td-vuoto {
63
64 width: 100%;
65 border: 1px;
66 text-align: left;
67
68}
69
70
71 .td-5 {
72
73 margin: 0px 0 0 0px;
74 width: 5%;
75 /*border: none;*/
76 padding: 0px;
77
78 text-align: center;
79 }
80
81 .bgw {
82 background: #ffffff;
83 font-size: 13px;
84 font-family: Helvetica;
85 text-align: right;
86 }
87
88 .bggray {
89 background: #ffffff;
90 FONT-SIZE: 13px;
91 FONT-FAMILY: Helvetica;
92 text-align: center;
93 }
94
95 .bggray2 {
96 background: #EFEFEF;
97 FONT-SIZE: 13px;
98 FONT-FAMILY: Helvetica;
99 text-align: right;
100 }
101 -->
102 </style>";
103}
104 // referendum
105
106 $posref='';
107 if (!IsSet($num_ref)) {
108 $num_ref=1;
109 $sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons'";
110 $resg = $dbi->prepare("$sql");
111 $resg->execute();
112 $num_refs= $resg->rowCount(); //quante pagine?
113 }
114 if($genere=='0'){
115 $sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' and num_gruppo='$num_ref'";
116 $resg = $dbi->prepare("$sql");
117 $resg->execute();
118 list($id_gruppo)=$resg->fetch(PDO::FETCH_NUM);
119 $posref="&amp;num_ref=$num_ref&amp;num_refs=$num_refs";
120 }
121 // icone stampa e grafici
122 if (!$csv){
123 if(!isset($html)) $html='';
124 $html .= "<div>
125 <a href=\"modules.php?name=Elezioni&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;op=affluenze_graf\">
126 "._VER_GRAF." <img class=\"image\" src=\"modules/Elezioni/images/grafici.png\" alt=\"\" /></a>
127 <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=affluenze_sez$posref&amp;csv=1\">"._VER_STAMPA."
128 <img class=\"image\" src=\"modules/Elezioni/images/printer.png\" alt=\"\" /></a>
129 <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=affluenze_sez$posref&amp;csv=1&amp;xls=1\">
130 <img class=\"image\" src=\"modules/Elezioni/images/csv.gif\" alt=\"\" /></a>
131 <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=affluenze_sez$posref&amp;csv=1&amp;pdf=1\">
132 <img class=\"image\" src=\"modules/Elezioni/images/pdf.gif\" alt=\"\" /></a>
133 </div>
134 <h2><b>"._DETTAGLIO." "._AFFLUENZE."</b></h2>";
135 }
136 // descrizione
137 if ($genere==0){
138 $sql="select descrizione from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
139 $des = $dbi->prepare("$sql");
140 $des->execute();
141 list($descrizione)=$des->fetch(PDO::FETCH_NUM);
142 if(!isset($html)) $html='';
143 $html .= "<div><h4>$descrizione</h4></div>";
144 }
145 $cond= $genere==0 ? "and t3.id_gruppo='$id_gruppo'" : "";
146 $i=1;
147 $sql="SELECT num_sez,id_sez,t1.id_sede, t2.id_circ,maschi,femmine,(maschi+femmine) as elettori FROM ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede $circos order by num_sez";
148 $res = $dbi->prepare("$sql");
149 $res->execute();
150 while ($linka[$i++] = $res->fetch(PDO::FETCH_BOTH));
151# while (list($appo) = mysql_fetch_array($res)) {$i=$appo['num_sez']; $linka[$i] = $appo;echo "\nnum:$i:".$linka[$i]['num_sez'];}die();
152 $num_sez = $res->rowCount(); //numero totale delle sezioni
153 if (isset($linka[1]['num_sez'])) $sez_da=$linka[1]['num_sez']; else $sez_da=0;
154 $sez_a=$sez_da+$num_sez-1;
155 $tot_compl=0;$tot_u=0;$tot_d=0;
156// $ar['riga1'][0]="<hr>";
157 $tot= array();
158 $ar[0][0]="<b>TOTALI</b>";
159 $ar['perc'][0]="Perc.";
160// $ar['riga2'][0]="<hr>";
161# foreach($linka['num_sez'] as $i)
162 $y=1;
163 for ($i=$sez_da;$i<=$sez_a;$i++,$y++) {
164# $ar[$i]['numsez']=$i;
165 if(!isset($linka[$y]['num_sez'])) { $linka[$y]['num_sez']=0; $linka[$y]['elettori']=0;}
166 $z=$linka[$y]['num_sez'];
167 $ar[$z]['numsez']=$linka[$y]['num_sez'];
168 $ar[$z]['elettori']=number_format($linka[$y]['elettori'],0,',','.');
169 $tot_compl+=$linka[$y]['elettori'];
170 $tot_u+=$linka[$y]['maschi'];
171 $tot_d+=$linka[$y]['femmine'];
172 }
173 $ar[0][1]="<b>".number_format($tot_compl,0,',','.')."</b>";
174 $ar['perc'][1]=" ";
175 $perc_u=0;$perc_d=0;$perc_c=0;
176 $sql="SELECT t1.data,t1.orario FROM ".$prefix."_ele_rilaff as t1 left join ".$prefix."_ele_voti_parziale as t2 on t2.data=t1.data and t2.orario=t1.orario left join ".$prefix."_ele_cons_comune as t3 on t3.id_cons_gen=t1.id_cons_gen where t1.id_cons_gen='$id_cons_gen' and t3.id_cons=t2.id_cons group by t1.data,t1.orario order by t1.data,t1.orario";
177 $resril = $dbi->prepare("$sql");
178 $resril->execute();
179 $num_ril= $resril->rowCount(); //numero delle rilevazioni previste
180 if(!isset($html)) $html='';
181 $html .= "<table class=\"td-89\">";
182 $html .= "<tr class=\"bggray\"><td>"._SEZIONI."</td><td>"._ISCR_SEZ."</td>";
183 $sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
184 $resuo = $dbi->prepare("$sql");
185 $resuo->execute();
186 list($ultora,$ultdata)=$resuo->fetch(PDO::FETCH_NUM);
187 $sql="select t3.data,t3.orario,sum(t3.voti_complessivi),sum(t3.voti_uomini),sum(t3.voti_donne) from ".$prefix."_ele_voti_parziale 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' $circos $cond group by t3.data,t3.orario,t3.id_gruppo order by t3.data,t3.orario";
188 $ressomma = $dbi->prepare("$sql");
189 $ressomma->execute();
190 $perc_u=array(); $perc_d=array(); $perc_c=array();
191 while (list($data,$ora,$somma,$votiu,$votid) = $ressomma->fetch(PDO::FETCH_NUM)) {
192 $perc_u[$data.$ora]=0;
193 $perc_d[$data.$ora]=0;
194 $perc_c[$data.$ora]=0;
195 if($votiu or $votid)
196# if(($data==$ultdata) and ($ora==$ultora))
197 {
198 $tot[$data.$ora]="<table style=\"width:180px;\"><tr class=\"bggray2\"><td style=\"width:33%;text-align:center;\">
199 <b>".number_format($votiu,0,',','.')."</b></td><td style=\"width:33%;text-align:center;\">
200 <b>".number_format($votid,0,',','.')."</b></td><td style=\"width:33%;text-align:center;\">
201 <b>".number_format($somma,0,',','.')."</b></td>
202 </tr></table>";
203 $perc_u[$data.$ora]=number_format($votiu*100/$tot_u,2);
204 $perc_d[$data.$ora]=number_format($votid*100/$tot_d,2);
205 $perc_c[$data.$ora]=number_format($somma*100/$tot_compl,2);
206 }
207 else
208 $tot[$data.$ora]=$somma;
209 }
210 $ud=0;$ora_rif="";
211 while (list($data1,$ora1) = $resril->fetch(PDO::FETCH_NUM))
212 {
213 $ud++;
214 list($hour, $minute, $second) = explode(":", $ora1);
215 $ora_ril=$hour.":".$minute;
216 $html .= "<td";
217 if ($ud==$num_ril and (isset($perc_u[$data1.$ora1]) or isset($perc_d[$data1.$ora1]))) {$ora_rif="$data1.$ora1";}
218 $html .= ">";
219 $data_a=form_data($data1);
220 $html .= "".$data_a."<br />"._ORE." ".$ora_ril;
221 $sql="SELECT count(data) FROM ".$prefix."_ele_voti_parziale 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 t1.id_cons='$id_cons' and data='$data1' and orario='$ora_ril' $circos group by t3.id_gruppo";
222 $resaff = $dbi->prepare("$sql");
223 $resaff->execute();
224 list($num_scr) = $resaff->fetch(PDO::FETCH_NUM); //numero delle sezioni inserite
225 $html .= "<br />"._SEZIONI." $num_scr "._SU." $num_sez";
226## if ($ud==$num_ril and ($perc_u or $perc_d)) $html .= "<br />
227 $html .= "<br /><table style=\"width:180px;\"><tr class=\"bggray\">";
228 if ((isset($perc_u[$data1.$ora1]) or isset($perc_d[$data1.$ora1])) and ($perc_u[$data1.$ora1]+$perc_d[$data1.$ora1])>0)
229 $html .= "<th style=\"width:28%;text-align:center;\">"._UOMINI."</th><th style=\"width:28%;text-align:center;\">"._DONNE."</th>";
230 $html .= "<th style=\"width:28%;text-align:center;\">"._COMPLESSIVI."</th></tr></table></td>";
231
232 if (isset($tot[$data1.$ora1])){
233 ## if ($ora_rif=="$data1.$ora1")
234 if (($perc_u[$data1.$ora1] or $perc_d[$data1.$ora1])){
235 $ar['perc'][$data1.$ora1]="<table style=\"width:180px;\"><tr class=\"bggray2\">
236 <td style=\"width:33%;text-align:center;\"><b><i><span class=\"red\">".$perc_u[$data1.$ora1]."%</span></i></b></td>
237 <td style=\"width:33%;text-align:center;\"><b><i><span class=\"red\">".$perc_d[$data1.$ora1]."%</span></i></b></td>
238 <td style=\"width:33%;text-align:center;\" ><span class=\"red\"><b><i>".$perc_c[$data1.$ora1]."%</i></b></span></td>
239 </tr></table>";
240 $ar[0][$data1.$ora1]=$tot[$data1.$ora1];
241 }
242 else
243 {
244 $ar['perc'][$data1.$ora1]="<b><span class=\"red\"><i>
245 ".number_format($tot[$data1.$ora1]*100/$tot_compl,2)."%</i></span></b>";
246 $ar[0][$data1.$ora1]="<b>".(number_format($tot[$data1.$ora1],0,',','.'))."</b>";
247 }
248
249 if (intval(preg_match('/[1-9]/',$tot[$data1.$ora1]))>0) {
250 #foreach($ar[['num_sez'] as $i)
251 ##########
252 $sql="select t1.num_sez from ".$prefix."_ele_sezioni as t1 left join ".$prefix."_ele_sede as t2 on t1.id_sede=t2.id_sede where t2.id_cons='$id_cons' $circos order by t1.num_sez ";
253 $resvoti = $dbi->prepare("$sql");
254 $resvoti->execute();
255
256 ###########
257 # for ($i=$sez_da;$i<=$sez_a;$i++)
258 while (list($i)=$resvoti->fetch(PDO::FETCH_NUM))
259 {
260 $ar[$i][$data1.$ora1]="<span style=\"color: rgb(255, 0, 0);\">non rilevata</span>";
261 }
262 }
263 }
264 }
265 $sql="select t3.data,t3.orario,t1.num_sez,voti_uomini, voti_donne, voti_complessivi from ".$prefix."_ele_voti_parziale 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' $circos $cond order by data,orario,t1.num_sez ";
266 $resvoti = $dbi->prepare("$sql");
267 $resvoti->execute();
268 $ud=0;
269 while (list($data,$ora,$numsez,$uomini,$donne,$complessivi) = $resvoti->fetch(PDO::FETCH_NUM)) {
270 if(($uomini+$donne)>0)
271 $ar[$numsez][$data.$ora]="<table style=\"width:180px;\"><tr>
272 <td style=\"width:33%;text-align:center;\">$uomini</td>
273 <td style=\"width:33%;text-align:center;\">$donne</td>
274 <td style=\"width:33%;text-align:center;\">$complessivi</td>
275 </tr></table>";
276 else
277 $ar[$numsez][$data.$ora]=$complessivi;
278 }
279 $html .= "</tr>";
280 foreach ($ar as $i => $arr) {
281 if(intval($i) % 2)
282 $html .= "<tr class=\"bgw\">";
283 else
284 $html .= "<tr class=\"bggray2\">";
285 foreach ($arr as $valore)
286 {
287 $html .= "<td>$valore</td>";
288 }
289 $html .= "</tr>";
290 }
291 $html .= "</table>";
292 if($genere==0){ //se e' referendum
293 #'Pagina precedente' e 'Pagina Successiva'
294 if ($xls!='1' && $pdf!='1' && $csv!='1'){
295 $html .= "<div class=\"modulo\">";
296 $cur=$num_ref;
297 if ($cur>1) {
298 $num_ref--;
299 $html .= "<a href=\"modules.php?name=Elezioni&amp;op=come&amp;info=affluenze_sez&amp;id_cons_gen=$id_cons_gen&amp;num_ref=$num_ref&amp;num_refs=$num_refs&amp;id_comune=$id_comune\">";
300 $html .= "[ <b>"._PREV_MATCH."</b> ] </a>";
301 }
302 if ($cur<$num_refs) {
303 $cur++;
304 $html .= "<a href=\"modules.php?name=Elezioni&amp;op=come&amp;info=affluenze_sez&amp;id_cons_gen=$id_cons_gen&amp;num_ref=$cur&amp;num_refs=$num_refs&amp;id_comune=$id_comune\">";
305 $html .= "[ <b>"._NEXT_MATCH."</b> ] </a>";
306 }
307 $html .= "</div>";
308 }
309}
310if(!isset($style)) $style='';
311if($csv==1){
312 $data=date("d-m-y G:i");
313 $style .="\t\t\n<br/><br/><br/><div style=\"margin:0px auto;text-align:center;\"><i>Stampato: $data</i></div>";
314 $style .="<br/><div style=\"text-align:center;\"><i>Eleonline by luciano apolito e roberto gigli - www.eleonline.it</i></div>";
315 $style .= "<br/> ";
316}
317
318?>
Note: See TracBrowser for help on using the repository browser.