Jump to content

PDF invoice error


urbee

Recommended Posts

Hello,

 

I've changed my invoicepdf.tpl abit to suit my needs. I guess i've made a mistake somewhere, because my notes gets all screwed up, it makes alot of spaces between the words if the note is too short to fit in the whole length of the line. Here's a preview:

 

invoicepdf.JPG

 

Here's my invoicepdf.tpl file - i guess i've made a mistake somewhere but i've got no idea where!

 

<?php

# Logo
$pdf->Image(ROOTDIR.'/images/logo.jpg',20,15,80,26);

# Company Details
$pdf->SetFont('freesans','',13);
$pdf->Cell(0,6,trim($companyaddress[0]),0,1,'R');
$pdf->SetFont('freesans','',;
for ( $i = 1; $i <= count($companyaddress); $i += 1) {
$pdf->Cell(0,4,trim($companyaddress[$i]),0,1,'R');
}
$pdf->Cell(0,1,$_LANG["telefon"]." +386 (0)70 834 873 ",0,1,'R');
$pdf->Cell(0,4,$_LANG["eposta"]." admin@si-shell.net ",0,1,'R');
$pdf->Cell(0,1,$_LANG["transakcijski"]." 3300 0000 1653 841 ",0,1,'R');
$pdf->Cell(0,1,$_LANG["davcna"]." SI41998456 ",0,1,'R');

$pdf->Ln(4);


# Clients Details
$pdf->SetFont('helvetica','B',10);
# $pdf->Cell(0,4,$_LANG["invoicesinvoicedto"],0,1);
$pdf->SetFont('helvetica','B',11);
if ($clientsdetails["companyname"]) {
$pdf->Cell(0,4,$clientsdetails["companyname"],0,1,'L'); }
#	$pdf->Cell(0,4,$_LANG["invoicesattn"].": ".$clientsdetails["firstname"]." ".$clientsdetails["lastname"],0,1,'L'); }
else {
$pdf->Cell(0,4,$clientsdetails["firstname"]." ".$clientsdetails["lastname"],0,1,'L');
}
$pdf->SetFont('helvetica','',11);
$pdf->Cell(0,4,$clientsdetails["address1"],0,1,'L');
if ($clientsdetails["address2"]) {
$pdf->Cell(0,4,$clientsdetails["address2"],0,1,'L');
}
$pdf->Cell(0,4,$clientsdetails["postcode"]." ".$clientsdetails["city"],0,1,'L');
$pdf->Cell(0,4,$clientsdetails["country"],0,1,'L');
$pdf->Ln(10);

if ($clientsdetails["customfields1"]) {
$pdf->Cell(0,4,$_LANG["davcna"]." ".$clientsdetails["customfields1"],0,1,'L');
}
$pdf->Ln(20);


# Header Bar
$invoiceprefix = $_LANG["invoicenumber"];

if ($status!="Paid") {
       $invoiceprefix = $_LANG["proformainvoicenumber"];
}

$pdf->SetFont('helvetica','B',15);
$pdf->SetFillColor(239);
$pdf->Cell(0,8,$invoiceprefix.$invoicenum,0,1,'L','1');
$pdf->SetFont('helvetica','',10);
$pdf->Cell(0,6,$_LANG["invoicesdatecreated"].': '.$datecreated.'',0,1,'L','1');

if ($status!="Paid") {
$pdf->Cell(0,6,$_LANG["invoicesdatedue"].': '.$duedate.'',0,1,'L','1'); }
else {
$pdf->Cell(0,6,$_LANG["orderpaymentmethod"].': '.$paymentmethod.'',0,1,'L','1');
}

$pdf->Ln(10);

$startpage = $pdf->GetPage();



$pdf->SetDrawColor(200);

$pdf->SetFont('helvetica','B',10);
$pdf->SetFillColor(239);
$pdf->Cell(130,7,$_LANG["invoicesdescription"],1,0,'C','1');
$pdf->Cell(40,7,$_LANG["invoicesamount"],1,0,'C','1');
$pdf->Ln();

$pdf->SetFont('helvetica','',10);

foreach ($invoiceitems AS $item) {

   $numlines = ceil(strlen($item["description"])/75);
   $cellheight = $numlines * 5;

   $startx = $pdf->GetX();
   $starty = $pdf->GetY();

   $pdf->MultiCell(130,5,$item["description"],1,'L','',1);

   $finishy = $pdf->GetY();
   $pdf->SetXY($startx+130,$starty);

   $pdf->MultiCell(40,$finishy-$starty,$item["amount"],1,'C','',1);

   if ($pdf->GetY()>=250) $pdf->AddPage();
}

$pdf->SetFont('helvetica','B',10);

$pdf->Cell(130,7,$_LANG["invoicessubtotal"],1,0,'R','1');
$pdf->Cell(40,7,$subtotal,1,0,'C','1');
$pdf->Ln();

if ($taxname) {
$pdf->Cell(130,7,$taxrate."% ".$taxname,1,0,'R','1');
$pdf->Cell(40,7,$tax,1,0,'C','1');
$pdf->Ln();
}

if ($taxname2) {
$pdf->Cell(130,7,$taxrate2."% ".$taxname2,1,0,'R','1');
$pdf->Cell(40,7,$tax2,1,0,'C','1');
$pdf->Ln();
}

$pdf->Cell(130,7,$_LANG["invoicescredit"],1,0,'R','1');
$pdf->Cell(40,7,$credit,1,0,'C','1');
$pdf->Ln();

$pdf->Cell(130,7,$_LANG["invoicestotal"],1,0,'R','1');
$pdf->Cell(40,7,$total,1,0,'C','1');
$pdf->Ln();

$pdf->Ln();

if ($notes) {
$pdf->SetFont('helvetica','',;
$pdf->MultiCell(170,5,$_LANG["invoicesnotes"].": $notes");
}

$pdf->SetFont('helvetica','B',10);
if ($status!="Paid") {
$pdf->Cell(0,10,$_LANG["placilosklic"].' 00 '.$invoicenum.'',0,1); }
else {
$pdf->Cell(0,6,$_LANG["placanodne"].': '.$datecreated.'',0,1,'L','1');
}

$pdf->Cell(150,70,trim($companyaddress[0]),0,1,'R');

$endpage = $pdf->GetPage();

$pdf->setPage($startpage);
$pdf->SetXY(70,90);
if ($status=="Cancelled") {
$statustext = $_LANG["invoicescancelled"];
   $pdf->SetTextColor(245,245,245);
} elseif ($status=="Unpaid") {
$statustext = $_LANG["invoicesunpaid"];
   $pdf->SetTextColor(204,0,0);
} elseif ($status=="Paid") {
$statustext = $_LANG["invoicespaid"];
   $pdf->SetTextColor(153,204,0);
} elseif ($status=="Refunded") {
$statustext = $_LANG["invoicesrefunded"];
   $pdf->SetTextColor(34,68,136);
} elseif ($status=="Collections") {
$statustext = $_LANG["invoicescollections"];
   $pdf->SetTextColor(255,204,0);
}

$pdf->SetFont('helvetica','B',20);
$pdf->Cell(120,20,strtoupper($statustext),0,0,'C');

# Footer
$pdf->SetMargins(15, 27, 15); // left, top, right
$pdf->SetAutoPageBreak(TRUE, 5); // TRUE, margin down
$pdf->SetFooterMargin(5);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);

// Factuur footer
$pdf->SetXY(15,-15); # Set Location
//Set font
$pdf->SetFont('Arial', '', 6.5); # Use 6.5pt Text
$pdf->SetTextColor(128);

//Centered text in a framed 80*5 mm cell and line break
$pdf->MultiCell(180, 3, "Spletne storitve, Urban Jazbinąek s.p. - Gorica pri Slivnici 121 - 3263 Gorica pri Slivnici\nIBAN: SI56 3300 0000 1653 841 - SWIFT / BIC: HAABSI22 - Hypo Alpe Adria Bank - ID ąt. za DDV SI41998456 \nIzjavljamo da nismo davčni zavezanci zato DDV ni obračunan. Pogoje poslovanja najdete na spletni strani http://www.Si-Shell.net", 0, 'C');


#$pdf->setPage($endpage);

?>

 

Also, does anyone have an idea how to change the encoding on this pdf? I get no scarrons in the file, which is pretty bad because i'm Slovenian and i need those letters badly :) I think some utf-8 encoding should do..

Link to comment
Share on other sites

Try replacing:

 

if ($notes) {
$pdf->SetFont('helvetica','',;
$pdf->MultiCell(170,5,$_LANG["invoicesnotes"].": $notes");
}

 

with:

 

if ($notes) {
$pdf->SetFont('helvetica','',;
$pdf->MultiCell(170,5,$_LANG["invoicesnotes"].": $notes","","L");
}

Link to comment
Share on other sites

Thanks alot, m00! That did the job!

 

I forgot about another issue, not huge as the one before, but anyway. U can see my signature on the image (Urban Jazbinšek s.p.) - the thing is, when i have more then 3 services/products on an invoice, it moves it down to the next page and i print out one page with the invoice and the other page with the signature only. I guess there should be some static position for it, because every line i add to the invoice above the signature it moves the signature down.

 

Thanks for your time and answer, u're a life savior! 8)

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