source: trunk/client/modules/Elezioni/crea_paginaphp7.php@ 348

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

Ripristino compatibilità con php <= 5.6

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