AliasNbPages();
$pdf->SetAutoPageBreak(0, 15);
// recupero dati
$qm=mysql_query("SELECT * FROM sezioni WHERE ID=$IDmenu");
$rm=mysql_fetch_array($qm);
if ($IDarticolo) {
// stampa singolo articolo
$qart=" and articoli.ID=$IDarticolo ";
} else {
// stampa collezione
$y0=10;
$y1=$y0+30;
$x0=10;
$i=0;
$qart='';
$pdf->AddPage("P");
$pdf->Image("copertina.jpg",0,0,210);
$pdf->AddPage("P");
$pdf->SetFillColor(0);
$pdf->SetXY(0,0);
$pdf->Cell(210,297,'',0,1,'L',1);
$pdf->Image('fondo.png',0,0,210);
//$pdf->Image('logo_neg.png',$x0,$y0,30);
$pdf->SetTextColor(255);
$pdf->SetFont('Helvetica','b',14);
$pdf->SetXY($x0,$y0+18);
$pdf->Cell(210,10,stripslashes($rm["titolo$lang"]),0,1,'L');
$qa=mysql_query("SELECT articoli.*,sez_art.IDsezione as IDs
FROM articoli INNER JOIN sez_art ON sez_art.IDarticolo=articoli.ID
WHERE articoli.attiva=2 and sez_art.IDsezione='$IDmenu' and articoli.lingue LIKE '%$_SESSION[lingua]%'
ORDER BY sez_art.IDdumm");
while ($ra=mysql_fetch_array($qa)) {
$qf=mysql_query("SELECT * FROM foto WHERE IDarticolo=$ra[ID] and posizione=1;");
$rf=mysql_fetch_array($qf);
$pdf->SetXY($x0+$i*48,$y1);
$pdf->SetFillColor(80);
$pdf->SetTextColor(240);
$pdf->Cell(46,26,'',0,1,'L',1);
if (is_file("../public/"."icona_".$rf[link]))
$pdf->Image(UPLOADABS."icona_".$rf[link],$x0+$i*48,$y1,46);
$pdf->SetFont('Helvetica','',8);
$pdf->SetXY($x0+$i*48,$y1+21);
$pdf->Cell($x0+$i*48,5,stripslashes($ra["titolo"]),0,1,'L');
$i++;
if ($i==4) {
$i=0;
$y1+=27;
}
}
$pdf->SetTextColor(0);
}
$qa=mysql_query("SELECT articoli.*,sez_art.IDsezione as IDs
FROM articoli INNER JOIN sez_art ON sez_art.IDarticolo=articoli.ID
WHERE articoli.attiva=2 and sez_art.IDsezione='$IDmenu' $qart and articoli.lingue LIKE '%$_SESSION[lingua]%'
ORDER BY sez_art.IDdumm");
// LIMIT 0,2");
while ($ra=mysql_fetch_array($qa)) {
$qf=mysql_query("SELECT * FROM foto WHERE IDarticolo=$ra[ID] and posizione=1;");
$rf=mysql_fetch_array($qf);
$qc=mysql_query("SELECT * FROM foto WHERE IDarticolo=$ra[ID] and (visibile=1) ORDER BY IDord;");
$pdf->AddPage("P");
$pdf->SetFont('Arial','',8);
$pdf->SetLineWidth(0.1);
$i=0;$nriga=0;
$x0=10;
$y0=10;
$pdf->Image('logo.png',$x0,$y0,47);
if (file_exists("../qrimg/qrcode$ra[ID].png"))
$pdf->Image("../qrimg/qrcode$ra[ID].png",$x0+169,$y0-2,22);
$pdf->SetFont('Helvetica','',18);
$pdf->SetXY($x0,$y0+18);
$pdf->Cell(210,10,stripslashes($rm["titolo$lang"])." / ".stripslashes($ra["titolo$lang"]),0,1,'L');
if (is_file("../public/".$rf[link])) $pdf->Image(UPLOADABS.$rf[link],$x0,$y0+30,190);
// descrizione
$pdf->SetFont('Helvetica','',8);
$pdf->SetXY($x0,$y0+113);
$pdf->MultiCell(90,3,html2txt(stripslashes($ra["testolungo$lang"])),0,'L',false);
if (html2txt(stripslashes($ra["testolungo$lang"]))) $x1=$x0+95;
else $x1=$x0;
$pdf->SetXY($x1,$y0+113);
$pdf->SetFont('Helvetica','b',8);
//$pdf->MultiCell(90,3,($lang?"LEATHERS":"PELLAMI"),0,'L',false);
$pdf->SetFont('Helvetica','',8);
if ($ra[pellami]) {
$qp=mysql_query("SELECT * FROM pellami WHERE ID IN ($ra[pellami]) ORDER BY nome$lang");
$i=0;
while ($rp=mysql_fetch_array($qp)) {
$pdf->SetX($x1);
$pdf->Cell(60,3,stripslashes($rp["nome$lang"]),0,1,'L');
$i++;
if ($i==5) {
$pdf->SetY($y0+116);
$x1+=30;
$i=0;
}
};
}
$y1=$y0+125;
$i=0;
$pdf->SetFont('Helvetica','B',8);
$pdf->SetXY($x0,$y1);
//$pdf->Cell($x0,5,($lang?"COLORS":"COLORI"),0,1,'L');
//$y1+=5;
$colori = coloricatalogo($rm[ID],$ra[ID]);
foreach ($colori as $col) if (($col[1]) && ($col[0])) {
$col[1]=str_replace("fotocatalogo","fotoottimizzate",$col[1]);
$pdf->SetXY($x0+$i*38.5,$y1);
$pdf->SetFillColor(160);
//$pdf->Cell(36,23,'',0,1,'L',1);
if (is_file("../".$col[1]))
$pdf->Image(URLBASE."".$col[1],$x0+$i*38.5,$y1,36);
$pdf->SetFont('Helvetica','B',8);
$l=36-($pdf->GetStringWidth($col[0])+3);
$pdf->SetXY($x0+$i*38.5+$l,$y1+18);
//$pdf->Cell(38+$x0+$i*38,5,stripslashes($col[0]),0,1,'R');
$pdf->SetTextColor(255);
$pdf->MultiCell(36-$l,3,stripslashes($col[0]),0,'R',true);
$i++;
if ($i==5) {
$i=0;
$y1+=24;
}
}
$pdf->SetTextColor(0);
$y2=283;
$pdf->SetLineWidth(0.1);
$pdf->Line($x0, $y2, $x0+190, $y2);
if ($IDarticolo) {
$pdf->SetFont('Helvetica','',7);
$pdf->SetXY($x0,$y2+1);
$pdf->MultiCell(200,3,"� Copyrights ECOPELL 2000 srl - Via del Trebbio Nord, 41 - 56029 Santa Croce sull'Arno (Pisa)",0,'L',false);
$pdf->SetXY($x0,$y2+1);
$pdf->MultiCell(190,3,"T. +39 0571 366674 - info@ecopell.it",0,'R',false);
$titolo="_".$ra['titolo'];
}
}
if (!$IDarticolo) {
$pdf->AddPage("P");
$pdf->Image("retro.jpg",0,0,210);
}
$pdf->Output("Ecopell$titolo.pdf",'D');
?>