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

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

Segue adattamento per php7
modifica gestione consultazioni con e senza voto nullo di lista

File size: 6.5 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
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\" style=\"border-collapse: collapse;border:=1px solid black;\">";
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="class=\"td-130b\"";
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# padding: 1px;
168# border: solid #666666;
169 /* margin: 4px 4px 40px;*/
170
171 $style ="
172 <style type=\"text/css\">
173 <!--
174 .table-docs {
175 font-size: 10px;
176 color: #000000;
177 text-align:center;
178 border: 1px solid black;
179 }
180 .bggray {
181 background: #d2d2d2;
182 FONT-SIZE: 13px;
183 FONT-FAMILY: Helvetica;
184 }
185
186 .bggray2 {
187 background: #EFEFEF;
188 FONT-SIZE: 13px;
189 FONT-FAMILY: Helvetica;
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 0px 0px 1px;
219 width: 130px;
220 border: 1px solid black;
221 }
222
223 td {
224 border: 2px solid black;
225 }
226 .red {
227 BACKGROUND: none;
228 COLOR: #ff0000;
229 FONT-SIZE: 12px;
230 FONT-FAMILY: Helvetica
231 }
232 .copy {
233 background: #d2d2d2;
234 FONT-SIZE: 8px;
235 FONT-FAMILY: Helvetica;
236 border: 1px;
237 }
238 .cen {
239 margin: 10px auto 0 auto;
240 }
241 -->
242 </style>";
243
244
245 # salva sull'hardisk lo stemma del comune
246 $logo=verificasimbolo();
247 $immagine= "<img src=\"modules/Elezioni/images/$logo\" alt=\"logo\" align=\"left\"/>";
248
249
250 $style .="<table style=\"margin: auto;border-collapse: collapse;\"><tr><td border=0>$immagine</td> ";
251
252 $style .= "<td border=0>$datipdf</td></tr></table><br/><br/>";
253 $style .= "<table style=\"margin: auto;\"><tr><td>$html</td></tr></table>";
254 $style .= "<table style=\"margin: auto;border-collapse: collapse;\"><tr><td border=0>";
255
256 $data=date("d-m-y G:i");
257 $style .="<br/><span class=\"copy\"><i>Stampato il $data</i></span>";
258 $style .="<br/><span class=\"copy\"><i>Eleonline by luciano apolito & roberto gigli - www.eleonline.it</i></span>";
259 $style .="</td></tr></table>";
260 $nomefile=strip_tags($datipdf).".pdf";
261# $nomefile=$_SESSION['nomefile'].".pdf";
262 $nomefile=str_replace(" ", "_",$nomefile);
263 // conversion HTML => PDF
264 //$nomefile="elezioni_tabelle.pdf";
265 //$orienta="P";
266 $html2pdf = new Html2Pdf($orienta,$formato, 'it');
267 $html2pdf->WriteHTML($style, isset($_GET['vuehtml']));
268 $html2pdf->Output($nomefile);
269
270
271
272 }
273
274
275
276
277 }
278}
279
280
281
282
283
284?>
Note: See TracBrowser for help on using the repository browser.