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