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

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

Sistemazione elementi grafici e di esportaione dati

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