<?php
//PDF USING MULTIPLE PAGES
//FILE CREATED BY: Carlos José Vásquez Sáez
//YOU CAN CONTACT ME: carlos@magallaneslibre.com
//FROM PUNTA ARENAS, MAGALLANES
//INOVO GROUP - http://www.inovo.cl
define('FPDF_INSTALLDIR', 'C:apachefriends/xampp/htdocs');
define('FPDF_FONTPATH', 'font/');
//require('fpdf.php');
require(FPDF_INSTALLDIR.'/fpdf153/fpdf.php');
require(FPDF_INSTALLDIR.'/code39ext/code39.php');
//Connect to your database
include("db_connect.tpl.inc");
//Create new pdf file
//$unit=cm;
//$format=array('24','155');
//$pdf=new FPDF('p', 'mm', 'A3');
$format=array('155','24');
$pdf=new FPDF('L','mm',$format);
//$pdf=new FPDF();
$pdf=new PDF_Code39();
//Open file
$pdf->Open();
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
//Add first page
$pdf->AddPage();
//set initial y axis position per page
$y_axis_initial = 4;
$y_axis = 4;
//print column titles for the actual page
//$pdf->SetFillColor(0, 25, 255);
$pdf->SetFont('Arial', 'B', 6);
$y_axis = $y_axis + $row_height;
//Select the Products you want to show in your PDF file
//$result=mysql_query('select lieferant,warengruppe,vk,allid,ek,datumlagein,liefartnr,vestk,wiedenstk from allgemein where vegedrucktkz ="1" ORDER BY allid');
$result=mysql_query('select * from allgemein where wdgedrucktkz ="1" ORDER BY allid');
// Abschnitt codierung des EKs
include ("./f_zensieren.tpl.inc");
// Abschnitt codierung des EKs -- ENDE --
include ("./f_date.tpl.inc");
include ("./f_datemo.tpl.inc");
//include ("./cutatspace.tpl.inc");
//initialize counter
$i = 0;
//$vestk = 1;
//$wdstk = 1;
//Set maximum rows per page
$max = 5;
//Set Row Height
$row_height = 53;
while($row = mysql_fetch_array($result))
{
$vestkist = $row['vestk'];
$wdstkist = $row['wiedenstk'];
$edvnr1 = $row['allid'];
$edvnr = str_pad($edvnr1.'0000', 12, 0, STR_PAD_LEFT);
for ($wiedenstk = 0; $wiedenstk < $wdstkist; $wiedenstk++)
{
//If the current row is the last one, create new page and print column title
if ($i == $max)
{
$pdf->AddPage();
//print column titles for the current page
$pdf->SetY($y_axis_initial);
$pdf->SetX(0);
/* $pdf->Cell(30, 6, 'Lieferant', 1, 0, 'L', 1);
$pdf->Cell(100, 6, 'EK', 1, 0, 'L', 1);
$pdf->Cell(30, 6, 'VK', 1, 0, 'R', 1);
*/
//Go to next row
//$y_axis = $y_axis + $row_height;
$y_axis = 10;
//Set $i variable to 0 (first row)
$i = 0;
}
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------- Anfang Teil fuer mehr als Etiketten
// ---------------------------------------------------------------------------------------------------------------------
//Etikettendaten allid, Lieferant, Warengruppe, Filiale, preis EK, VK,
$code = $row['lieferant'];
$price = $row['vk'];
$name = $row['warengruppe'];
// $filiale = $row['xxxxx'];
$ekread = $row['ek'];
$date = $row['datumlagein'];
$datemo0 = $date;
$liefbez= $row['liefartnr'];
$pdf->SetY($y_axis);
$pdf->SetX(2);
$pdf->SetFont('Arial', '', 8);
//include("ekcode.tpl.inc");
$ek = zensieren($ekread);
$year1 = dateformat($date);
//$year1 = cutatspace($year2, 2);
$month1 = dateformatmo($datemo0);
//$date1 = date("d.m.Y",$year1);
// Abscnitt Codierung ---Anfang---
// (br,hoe,test ,border,rahmen,pos,
// $pdf->Cell(15,15,FirstLine, 0, 0, 'l', 0);
$pdf->Cell(1, 15, 2, 0, 0, 'r', 0);
$pdf->Cell(1.3, 15, L, 0, 0, 'r', 0);
$pdf->Cell(3, 15, $code, 0, 0, 'r', 0);
$pdf->Cell(2, 15, W, 0, 0, 'l', 0);
$pdf->Cell(3, 15, $name, 0, 0, 'L', 0);
$pdf->Cell(1.5, 15, Y, 0, 0, 'r', 0);
$pdf->Cell(1.5, 15, $year1, 0, 0, 'l', 0);
$pdf->Cell(2, 15, M, 0, 0, 'l', 0);
$pdf->Cell(3, 15, $month1, 0, 0, 'l', 0);
$pdf->Cell(2, 15, "$ek", 0, 0, 'l', 0);
/* $pdf->Cell(12, 15, "stueck soll:", 0, 0, 'l', 0);
$pdf->Cell(2, 15, "$vestkist", 0, 0, 'l', 0);
$pdf->Cell(22, 15, "stueck gezaehlt:", 0, 0, 'l', 0);
$pdf->Cell(2, 15, "$vestk", 0, 0, 'l', 0);
*/
///test zelle fuer stueckzahlzaehlung
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(40);
$pdf->Cell(2, 15, € , 0, 0, 'l', 0);
$pdf->Cell(5, 15, $price, 0, 0, 'l', 0);
$ybar1_axis = $y_axis + 9;
$pdf->SetY($ybar1_axis);
$pdf->SetX(2);
$pdf->SetFont('Arial', '', 8);
$pdf->Cell(2,15, $edvnr, 0, 0,'r', 0);
$ybar1_axis = $y_axis + 13;
$pdf->SetY($ybar1_axis);
$pdf->SetX(2);
$pdf->Cell(2,15, $liefbez, 0, 0,'r', 0);
$ybar1_axis = $y_axis + 18;
$pdf->SetY($ybar1_axis);
$pdf->SetX(2);
$pdf->Cell(1, 15, 2, 0, 0, 'r', 0);
$pdf->Cell(1.3, 15, L, 0, 0, 'r', 0);
$pdf->Cell(3, 15, $code, 0, 0, 'L', 0);
$pdf->Cell(2, 15, W, 0, 0, 'r', 0);
$pdf->Cell(3, 15, $name, 0, 0, 'L', 0);
$pdf->Cell(1.5, 15, Y, 0, 0, 'r', 0);
$pdf->Cell(1.5, 15, $year1, 0, 0, 'l', 0);
$pdf->Cell(2, 15, M, 0, 0, 'l', 0);
$pdf->Cell(3, 15, $month1, 0, 0, 'l', 0);
$pdf->Cell(2, 15, "$ek", 0, 0, 'l', 0);
/* // pruef cellen
$pdf->Cell(1, 15, puefcelle, 0, 0, 'L', 0);
$pdf->Cell(4, 15, $ekread, 0, 0, 'L', 0);
// $pdf->Cell(5, 15, $string, 0, 0, 'l', 0);
*/
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(40);
$pdf->Cell(2, 15, €, 0, 0, 'l', 0);
$pdf->Cell(5, 15, $price, 0, 0, 'l', 0);
// Code39(x,y,wert,erweitertetr modus,,breite Barcode,höhe,,) Barcode,
// $pdf->Code39(60, $y_axis, $edvnr,true,true,0.4,2,true);
// $pdf->SetFont('arial', '', 2);
$ybar_axis = $y_axis + 28;
$pdf->SetX(2);
$pdf->code39(2,$ybar_axis, $edvnr1,true,false,0.5,8,true);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
// $vestk = $vestk +1;
}
}
//mysql_close($link);
//Create file
$pdf->Output();
?>