[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 |
|
---|
| 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 |
|
---|
| 27 |
|
---|
| 28 | global $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 |
|
---|
| 41 | if ($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 |
|
---|
| 55 | echo "$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&file=foto&id_comune=".$id_comune."\" align=\"left\" alt=\"logo\" /> ";
|
---|
| 112 | $html .= "</td><td>$datipdf</td></td></table>";
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 116 |
|
---|
[354] | 117 | $html .= "<table class=\"table-docs\">";
|
---|
[348] | 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\">";
|
---|
[354] | 130 | $i="class=\"td-150c\"";
|
---|
[348] | 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";
|
---|
[354] | 145 | $i="class=\"td-150b\"";
|
---|
[348] | 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 |
|
---|
[352] | 167 | # padding: 1px;
|
---|
[354] | 168 | # border: solid #666666; border-color: black;
|
---|
| 169 |
|
---|
[352] | 170 | /* margin: 4px 4px 40px;*/
|
---|
| 171 |
|
---|
[348] | 172 | $style ="
|
---|
| 173 | <style type=\"text/css\">
|
---|
| 174 | <!--
|
---|
| 175 | .table-docs {
|
---|
| 176 | font-size: 10px;
|
---|
| 177 | text-align:center;
|
---|
[354] | 178 | border: 1px;
|
---|
| 179 | border-color: black;
|
---|
[348] | 180 | }
|
---|
| 181 | .bggray {
|
---|
| 182 | background: #d2d2d2;
|
---|
| 183 | FONT-SIZE: 13px;
|
---|
| 184 | FONT-FAMILY: Helvetica;
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | .bggray2 {
|
---|
| 188 | background: #EFEFEF;
|
---|
| 189 | FONT-SIZE: 13px;
|
---|
| 190 | FONT-FAMILY: Helvetica;
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | bggray3 {
|
---|
| 194 | background: #EFEFEF;
|
---|
| 195 | FONT-SIZE: 10px;
|
---|
| 196 | FONT-FAMILY: Helvetica;
|
---|
| 197 | text-align: left
|
---|
| 198 | }
|
---|
| 199 |
|
---|
| 200 | .bgw {
|
---|
| 201 | background: #ffffff;
|
---|
| 202 | FONT-SIZE: 13px;
|
---|
| 203 | FONT-FAMILY: Helvetica;
|
---|
| 204 | border: 1px;
|
---|
| 205 |
|
---|
| 206 | }
|
---|
| 207 | .td-130 {
|
---|
| 208 | float: right;
|
---|
| 209 | margin: 0px 0 0 1px;
|
---|
| 210 | width: 130px;
|
---|
[354] | 211 | border: 1px;
|
---|
[348] | 212 | background-color: #d2d2d2;
|
---|
| 213 | padding: 0px;
|
---|
| 214 | }
|
---|
| 215 | .td-130c {
|
---|
| 216 | float: right;
|
---|
| 217 | text-align:left;
|
---|
[352] | 218 | margin: 0px 0px 0px 1px;
|
---|
[348] | 219 | width: 130px;
|
---|
[354] | 220 | border: 1px;
|
---|
| 221 |
|
---|
[348] | 222 | }
|
---|
| 223 |
|
---|
| 224 | td {
|
---|
[354] | 225 | border: 2px;
|
---|
[348] | 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 |
|
---|
[352] | 251 | $style .="<table style=\"margin: auto;border-collapse: collapse;\"><tr><td border=0>$immagine</td> ";
|
---|
[348] | 252 |
|
---|
| 253 | $style .= "<td border=0>$datipdf</td></tr></table><br/><br/>";
|
---|
| 254 | $style .= "<table style=\"margin: auto;\"><tr><td>$html</td></tr></table>";
|
---|
[352] | 255 | $style .= "<table style=\"margin: auto;border-collapse: collapse;\"><tr><td border=0>";
|
---|
[348] | 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 | ?>
|
---|