source: trunk/client/modules/Elezioni/crea_pagina.php@ 352

Last change on this file since 352 was 348, checked in by roby, 3 years ago

Ripristino compatibilità con php <= 5.6

File size: 6.4 KB
Line 
1<?php
2
3/************************************************************************/
4/* Eleonline - Raccolta e diffusione dei dati elettorali */
5/* by Luciano Apolito & Roberto Gigli */
6/* http://www.eleonline.it */
7/* info@eleonline.it luciano@aniene.net rgigli@libero.it */
8/************************************************************************/
9
10//testa_riga[contenuto in posizione 0][y]
11//testa_colonna[x][contenuto in posizione 0]
12//corpo[da 1 a x][da 1 a y]
13
14if (!defined('MODULE_FILE')) {
15 die ("You can't access this file directly...");
16}
17
18global $name;
19
20function crea_tabella($ar) {
21
22
23global $prefix,$dbi,$pdf,$csv,$xls,$lang,$descr_cons,$prefix,$dbi,$id_comune,$descrizione,$siteistat,$min,$offset,$minsez,$offsetsez,$datipdf,$orienta,$formato;
24$sql="SELECT descrizione,simbolo,stemma FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
25 $res = $dbi->prepare("$sql");
26 $res->execute();
27
28 list($descr_com,$simbolo,$stemma) = $res->fetch(PDO::FETCH_NUM);
29
30
31
32$datipdf=stripslashes($datipdf);
33
34$data=date("d-m-y G:i");
35
36if ($xls==1) {
37
38 $nomefile=strip_tags(str_replace(array('"', "'", ' ', ','), "_", $datipdf).".xls");
39# $nomefile=$_SESSION['nomefile'].".xls";
40 header ("Content-Type: application/vnd.ms-excel");
41 header ("Content-Disposition: inline; filename=$nomefile");
42
43$datipdf=str_replace("<br/>","\n",$datipdf);
44
45$datipdf=strip_tags($datipdf);
46// $cella=str_replace("</b>"," ",$cella);
47// $cella=str_replace("<br />"," ",$cella);
48
49
50echo "$datipdf";
51
52 $y=1;$i='';$e='';
53 foreach ($ar as $riga) {
54 $e++;
55 if($y) {
56 echo "\n";
57 }else{
58
59 echo "\n";
60
61 }
62
63
64 foreach ($riga as $cella) {
65 $cella=str_replace("<b>"," ",$cella);
66 $cella=str_replace("</b>"," ",$cella);
67 $cella=str_replace("<br>"," ",$cella);
68 $cella=str_replace("<br />"," ",$cella);
69 $cella=str_replace("<span class=\"red\"><i>"," - ",$cella);
70 $cella=str_replace("<span class=\"red\" style=\"font-size:80%;\"><i>"," - ",$cella);
71 $cella=str_replace("</span>%</i>","%",$cella);
72 $cella=str_replace("</i></span>","",$cella);
73 $cella=str_replace("_CIRCOS","Circoscrizione ",$cella);
74 $cella=str_replace("_SEZIONI","Sezione ",$cella);
75 $cella=str_replace("_TOT","Totale",$cella);
76 $cella=str_replace("_COMPLESSIVO","Complessivo",$cella);
77
78 echo "$cella \t";
79
80
81 }
82 if ($y) $y=0;
83
84 }
85
86 echo"\n\n\nPowered by Eleonline http://www.eleonline.it \t \n";
87 echo"by luciano apolito & roberto gigli - stampato: $data \t \n";
88 die();
89
90}else{
91
92
93
94 $bg='bgw';
95
96 $tmpbg='bggray2';
97 $tmpbg1='bgw';
98 $tmpbg2='bggray';
99 $tmpbg3='bggray2';
100
101 $html ='';
102 if ($pdf!="1" && $csv=="1")
103 {
104
105 $html .="<center><table><tr><td>
106 <img src=\"modules.php?name=Elezioni&amp;file=foto&amp;id_comune=".$id_comune."\" align=\"left\" alt=\"logo\" /> ";
107 $html .= "</td><td>$datipdf</td></td></table>";
108 }
109
110
111
112 $html .= "<table class=\"table-docs\" cellspacing=\"0\" cellpadding=\"2\" border=\"1\" rules=\"all\">";
113
114
115
116
117 $y=1;$i='';$e='';
118 foreach ($ar as $riga) {
119 $e++;
120 if($y) {
121 $html .= "<tr class=\"bggray\">";
122 }else{
123 $bg= ($bg==$tmpbg) ? $tmpbg1:$tmpbg3;
124 $html .= "<tr class=\"$bg\">";
125 $i="class=\"td-130c\"";
126 }
127 foreach ($riga as $cella) {
128
129 $cella=str_replace("_CIRCOS","Circoscrizione ",$cella);
130 $cella=str_replace("_SEZIONI","Sezione ",$cella);
131 $cella=str_replace("_TOT","Totale",$cella);
132 $cella=str_replace("_COMPLESSIVO","",$cella);
133
134 if ($e==1){
135 $t="<td";$f="</td>";
136 }else{
137 $t="<td";$f="</td>";
138 }
139 $html .= "$t $i>$cella $f";
140 $i='';
141
142 }
143 if ($y) $y=0;
144 $html .= "</tr>";
145 }
146 $html .= "</table>";
147
148
149 if ($pdf!="1" && $csv=="1"){
150 $html .="<br/><span class=\"copy\"><i>Stampato: $data</i></span>";
151 $html .="<br/><span class=\"copy\"><i>Eleonline by luciano apolito & roberto gigli - www.eleonline.it</i></span>";
152 $html .="</center><br />";
153 }
154
155 # inizio stampa a video o pdf
156
157
158 if ($pdf!='1'){
159 echo $html;
160 }else{
161
162 $style ="
163 <style type=\"text/css\">
164 <!--
165 .table-docs {
166 font-size: 10px;
167 padding: 1px;
168 color: #000000;
169 /* margin: 4px 4px 40px;*/
170 border: solid #666666;
171 text-align:center;
172 }
173 .bggray {
174 background: #d2d2d2;
175 FONT-SIZE: 13px;
176 FONT-FAMILY: Helvetica;
177 border: 1px;
178 }
179
180 .bggray2 {
181 background: #EFEFEF;
182 FONT-SIZE: 13px;
183 FONT-FAMILY: Helvetica;
184 border: 1px;
185 }
186
187 bggray3 {
188 background: #EFEFEF;
189 FONT-SIZE: 10px;
190 FONT-FAMILY: Helvetica;
191 text-align: left
192 }
193
194 .bgw {
195 background: #ffffff;
196 FONT-SIZE: 13px;
197 FONT-FAMILY: Helvetica;
198 border: 1px;
199
200 }
201 .td-130 {
202 float: right;
203 margin: 0px 0 0 1px;
204 width: 130px;
205 border: none;
206 background-color: #d2d2d2;
207 padding: 0px;
208
209 }
210 .td-130c {
211 float: right;
212 text-align:left;
213 margin: 0px 0 0 1px;
214 width: 130px;
215 border: none;
216 padding: 0px;
217 }
218
219 td {
220 border: .2px;
221 }
222 .red {
223 BACKGROUND: none;
224 COLOR: #ff0000;
225 FONT-SIZE: 12px;
226 FONT-FAMILY: Helvetica
227 }
228 .copy {
229 background: #d2d2d2;
230 FONT-SIZE: 8px;
231 FONT-FAMILY: Helvetica;
232 border: 1px;
233 }
234 .cen {
235 margin: 10px auto 0 auto;
236 }
237 -->
238 </style>";
239
240
241 # salva sull'hardisk lo stemma del comune
242 $logo=verificasimbolo();
243 $immagine= "<img src=\"modules/Elezioni/images/$logo\" alt=\"logo\" align=\"left\"/>";
244
245
246 $style .="<table style=\"margin: auto;\" cellspace=0 border=0 cellpadding=0><tr><td border=0>$immagine</td> ";
247
248 $style .= "<td border=0>$datipdf</td></tr></table><br/><br/>";
249 $style .= "<table style=\"margin: auto;\"><tr><td>$html</td></tr></table>";
250 $style .= "<table style=\"margin: auto;\" cellspace=0 border=0 cellpadding=0><tr><td border=0>";
251
252 $data=date("d-m-y G:i");
253 $style .="<br/><span class=\"copy\"><i>Stampato il $data</i></span>";
254 $style .="<br/><span class=\"copy\"><i>Eleonline by luciano apolito & roberto gigli - www.eleonline.it</i></span>";
255 $style .="</td></tr></table>";
256 $nomefile=strip_tags($datipdf).".pdf";
257# $nomefile=$_SESSION['nomefile'].".pdf";
258 $nomefile=str_replace(" ", "_",$nomefile);
259 // conversion HTML => PDF
260 //$nomefile="elezioni_tabelle.pdf";
261 //$orienta="P";
262 $html2pdf = new Html2Pdf($orienta,$formato, 'it');
263 $html2pdf->WriteHTML($style, isset($_GET['vuehtml']));
264 $html2pdf->Output($nomefile);
265
266
267
268 }
269
270
271
272
273 }
274}
275
276
277
278
279
280?>
Note: See TracBrowser for help on using the repository browser.