Jump to content

Problem with PDF Batch after upgrade to 5.2.2


easyswiss

Recommended Posts

Hi all,

 

I have an own pdf invoice style.. but now the pdf batch does not work if i export more than one invoice -> fails.

Single Export works great.

 

What is wrong with my invoicepdf.tpl? :?::?::?:

 

<?php
// Paginaberekening
$paginanummer = 1;
$paginatotaal = ceil(count($invoiceitems) / 22);

if($opgeroepen !== 1)
{
// Custom header & footer
class MYPDF extends TCPDF
{		
	// Header
	public function Header($direct=0,$clientsdetails=0,$invoicenum=0,$datecreated=0,$paginanummer=0,$paginatotaal=0)
	{		
		if($direct == 1)
		{
			$this->Image(ROOTDIR.'/templates/portal/xxxx.png',115,15,80,'','','',true);

			$this->Ln(35);

			$this->SetFont('arial','',7);
			$this->Cell(0,0,'xxxx AG',0);

			$this->Ln(5);

			if($clientsdetails["companyname"])
			{
				$v1 = $clientsdetails["companyname"];
				$v2 = $clientsdetails["firstname"]." ".$clientsdetails["lastname"];
				$v3 = $clientsdetails["address1"]." ".$clientsdetails["address2"];
				$v4 = $clientsdetails["postcode"]." ".$clientsdetails["city"];
				$v5 = $clientsdetails["country"];
			}
			else
			{
				$v1 = $clientsdetails["firstname"]." ".$clientsdetails["lastname"];
				$v2 = $clientsdetails["address1"]." ".$clientsdetails["address2"];
				$v3 = $clientsdetails["postcode"]." ".$clientsdetails["city"];
				$v4 = $clientsdetails["country"];
				$v5 = "";
			}

			$this->SetFont('arial','','9.5');
			$this->Cell(110,'',$v1,'','','L');
			$this->Cell(30,'','Rechnungsdatum','','','R');
			$this->Cell(5,'','','','','');
			$this->Cell(35,'',str_replace('/','.',$datecreated),'','','L');
			$this->Ln();
			$this->Cell(110,'',$v2,'','','L');
			$this->Cell(30,'','Rechnungs-Nr.','','','R');
			$this->Cell(5,'','','','','');
			$this->Cell(35,'',$invoicenum,'','','L');
			$this->Ln();
			$this->Cell(110,'',$v3,'','','L');
			$this->Cell(30,'','Kundennummer','','','R');
			$this->Cell(5,'','','','','');
			$this->Cell(35,'',$clientsdetails["id"],'','','L');
			$this->Ln();
			$this->Cell(110,'',$v4,'','','L');
			$this->Cell(30,'','E-Mail','','','R');
			$this->Cell(5,'','','','','');
			$this->Cell(35,'','info@xxxxxx.com','','','L');
			$this->Ln();
			$this->Cell(110,'',$v5,'','','L');
			$this->Cell(30,'','Seite','','','R');
			$this->Cell(5,'','','','','');
			$this->Cell(35,'',$paginanummer.'/'.$paginatotaal.'','','L');

			$this->Ln(40);
		}
	}

	// Footer
	public function Footer()
	{
		$this->SetFont('arial','','6.5');
		$this->Cell(40,'','xxxx AG','','','L');
		$this->Cell(35,'','Kontakt Buchhaltung:','','','L');
		$this->Cell(35,'','xxxx@xxxx.com','','','L');
		$this->Cell(20,'','Konto (EURO):','','','L');
		$this->Cell(30,'','xxxxxx / xxxxxx
','','','L');
		$this->Cell(20,'','','','','L');
		$this->Cell(30,'','','','','L');
		$this->Ln();
		$this->Cell(40,'','xxxxxx','','','L');
		$this->Cell(35,'','MWST-Nummer:','','','L');
		$this->Cell(35,'','xxxxxx','','','L');
		$this->Cell(20,'','Konto (CHF):','','','L');
		$this->Cell(30,'','xxxxxx
','','','L');
		$this->Cell(20,'','             ','','','L');
		$this->Cell(30,'','','','','L');
		$this->Ln();
		$this->Cell(40,'','xxxxxx','','','L');
		$this->Cell(35,'','Zahlungszweck:','','','L');
		$this->Cell(35,'','Rechnungsnummer eintragen','','','L');
		$this->Cell(20,'','Bank:','','','L');
		$this->Cell(30,'','xxxxxxxx','','','L');
		$this->Cell(20,'','','','','L');
		$this->Cell(30,'','','','','L');
		$this->Ln();
	}
}

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, 115, PDF_MARGIN_RIGHT,60);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(20);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 
$pdf->setLanguageArray($l); 

$pdf->AddPage();
}
$opgeroepen = 1;

$pdf->header(1,$clientsdetails,$invoicenum,$datecreated,$paginanummer,$paginatotaal);

$pdf->SetFont('arial','B','11.5');
$pdf->Cell('','','Rechnung','','','L');

$pdf->Ln(10);

$pdf->SetFont('arial','B','9.5');
$pdf->Cell(145,'','Artikelbeschreibung','','','L');
$pdf->Cell(35,'','Preis','','','C');

$pdf->Ln(6);

$pdf->WriteHTML('<hr>');

$pdf->Ln(-2);

$pdf->SetFont('arial','','9.5');

$a = 0;

foreach ($invoiceitems AS $item) 
{	
$a++;

$pdf->Cell(145,'',$item["description"],'','','L');
$pdf->Cell(35,'',$item["amount"],'','','C');
$pdf->Ln(6);

if($a == 22)
{	
	$paginanummer++;
	$pdf->WriteHTML('<hr>');
	$pdf->AddPage();	
	$pdf->header(1,$clientsdetails,$invoicenum,$datecreated,$paginanummer,$paginatotaal);
	$pdf->SetFont('arial','B','9.5');
	$pdf->Cell(145,'','Artikelbeschreibung','','','L');
	$pdf->Cell(35,'','Preis','','','C');
	$pdf->Ln(6);
	$pdf->WriteHTML('<hr>');
	$pdf->Ln(-2);
	$pdf->SetFont('arial','','9.5');

	$a = 0;	
}
}

$pdf->WriteHTML('<hr>');

$pdf->Ln(-2);

$pdf->Ln();

if ($taxname) {
$pdf->Cell(145,'',$taxrate."% ".$taxname,'','','R');
$pdf->Cell(35,'',$tax,'','','C');
$pdf->Ln();
}

if ($taxname2) {
$pdf->Cell(145,'',$taxrate2."% ".$taxname2,'','','R');
$pdf->Cell(35,'',$tax2,'','','C');
$pdf->Ln();
}

$pdf->Cell(145,'',$_LANG["invoicescredit"],'','','R');
$pdf->Cell(35,'',$credit,'','','C');
$pdf->Ln();

$pdf->Cell(145,'',$_LANG["invoicestotal"],'','','R');
$pdf->Cell(35,'',$total,'','','C');

$pdf->SetFont('arial','B','9.5');
$pdf->Cell(145,'','Gesamt','','','R');
$pdf->SetFont('arial','','9.5');
$pdf->Cell(35,'',$total,'','','C');

$pdf->Ln(15);

$pdf->SetFont('arial','B','9.5');
$pdf->Cell('','','Angaben für Ihre Bezahlung:','','','L');
$pdf->Ln(6);
$pdf->WriteHTML('<hr>');

$pdf->Ln(-2);

if ($notes)
$notities = $notes;
else
$notities = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.";

$pdf->SetFont('arial','','9.5');
$pdf->Cell('','',$notities,'','','L');

$startpage = $pdf->GetPage();
$endpage = $pdf->GetPage();
$pdf->setPage($endpage);

$paginanummer = 1;

?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated