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

Last change on this file since 114 was 114, checked in by eol, 13 years ago

stampa xls: eliminazione tag html

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