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