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

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

esporta risultati pdf : scelta formato A3/A4 e Landscape/Portrait

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