Jump to content

Customize Printable or PDF Invoice


davet

Recommended Posts

ok i see. I figured out how to move the logo and how to justify my company address to the left instead of right. Does anyone have any advice as to how i can move my company address down about 1/2" ?

 

How about moving the customer's address down about 1" ?

 

I tried playing around with the settings but just can't figure it out.

Link to comment
Share on other sites

Thanks! That worked perfect. I also found the docs at http://wiki.whmcs.com/PDF_Invoice which are very helpful.

 

Does anyone know how to add # of days past due to the invoice? I don't see this as a variable in the documentation. Is there some php code which can take the current date and figure out how many days past due the invoice is and only display "PAST DUE X DAYS" if it is past due?

Link to comment
Share on other sites

  • 3 months later...

thanks for the reply david i have just checked on your link i have got the font colour changed and most of the text in correct postition but still need to get the company address and client address on the same row and when i try to add a new page for the terms and conditions i dont get anything at all

 

i wonder if you can help??

 

<?php

# Logo
$pdf->Image(ROOTDIR.'/images/logo.jpg',5,5);

# Header Bar
$pdf->Ln(4);
$invoiceprefix = $_LANG["invoicenumber"];
/*
** This code should be uncommented for EU companies using the sequential invoice numbering so that when unpaid it is shown as a proforma invoice **
if ($status!="Paid") {
$invoiceprefix = $_LANG["proformainvoicenumber"];
}
*/
$pdf->SetFont('Arial','B',14);
$pdf->SetFillColor(255,255,255);
$pdf->Cell(0,8,$invoiceprefix.$invoicenum,0,1,'R','1');
$pdf->SetFont('Arial','',12);
$pdf->Cell(0,6,$_LANG["invoicesdatecreated"].': '.$datecreated.'',0,1,'R','1');

$pdf->Ln(5);

# Company Details
$pdf->SetFont('Arial','',12);
$pdf->Cell(0,6,$companyname,0,1,'R');
$pdf->SetFont('Arial','',10);
for ( $i = 0; $i <= 4; $i += 1) {
$pdf->Cell(0,4,trim($companyaddress[$i]),0,1,'R');
}

# Clients Details
$pdf->SetFont('Arial','B',12);
$pdf->Cell(0,4,$_LANG["invoicesinvoicedto"],0,1);
$pdf->SetFont('Arial','',10);
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('Arial','',10);
$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["city"].", ".$clientsdetails["state"].", ".$clientsdetails["postcode"],0,1,'L');
$pdf->Cell(0,4,$clientsdetails["country"],0,1,'L'); 
$pdf->Ln(10);



# Invoice Table
$pdf->SetDrawColor(200);

$pdf->SetFont('Arial','B',12);
$pdf->SetFillColor(63,63,63);
$pdf->SetTextColor(117,188,232);
$pdf->Cell(130,7,$_LANG["invoicesdescription"],1,0,'C','1');
$pdf->Cell(40,7,$_LANG["invoicesamount"],1,0,'C','1');
$pdf->Ln();

$pdf->SetFont('Arial','',11);
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(0);

foreach ($invoiceitems AS $item) {
if (strlen($item["description"])>75) {
	$pdf->Cell(130,6,substr($item["description"],0,75),1);
	$pdf->Cell(40,6,$currencysymbol.$item["amount"],1,0,'C');
	$pdf->Ln();
	$pdf->Cell(130,6,substr($item["description"],75),1);
	$pdf->Cell(40,6,"",1,0,'C');
} else {
	$pdf->Cell(130,6,$item["description"],1);
	$pdf->Cell(40,6,$currencysymbol.$item["amount"],1,0,'C');
}
$pdf->Ln();
}

$pdf->SetFont('Arial','B',12);
$pdf->SetTextColor(117,188,232);
$pdf->Cell(130,7,$_LANG["invoicessubtotal"],1,0,'R','1');
$pdf->Cell(40,7,$currencysymbol.$subtotal,1,0,'C','1');
$pdf->Ln();

/* Add VAT Tax to the invoice un comment this
if ($taxrate!="0.00") {
$pdf->Cell(130,7,$taxrate."% ".$taxname,1,0,'R','1');
$pdf->Cell(40,7,$currencysymbol.$tax,1,0,'C','1');
$pdf->Ln();
}

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

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

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

$pdf->Ln();

# Invoice Notes
if ($notes) {
$pdf->SetFont('Arial','',10);
$pdf->SetTextColor(200);
$pdf->MultiCell(170,5,$_LANG["invoicesnotes"].": $notes");
}

# Invoice Status
$pdf->SetXY(45,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);
}
$pdf->SetFont('Arial','B',40);
$pdf->Cell(120,20,strtoupper($statustext),0,0,'C');

# New Page for T&Cs

function ChapterTitle($num,$label)
{
   //Arial 12
   $pdf->SetFont('Arial','',;
   //Background color
   $pdf->SetFillColor(255,255,255);
   //Title
   $pdf->Cell(0,6,"Chapter $num : $label",0,1,'C',true);
   //Line break
   $pdf->Ln(4);
}

function ChapterBody($file)
{
   //Read text file
   $f=fopen($file,'r');
   $txt=fread($f,filesize($file));
   fclose($f);
   //Times 12
   $pdf->SetFont('Times','',10);
   //Output justified text
   $pdf->MultiCell(0,5,$txt);
   $pdf->Ln();
}

function PrintChapter($num,$title,$file)
{
   $pdf->AddPage();
   $pdf->ChapterTitle($num,$title);
   $pdf->ChapterBody($file);
}

$pdf=new PDF();
$title='Terms & Conditions';
$pdf->SetTitle($title);
$pdf->SetAuthor('ILL IT Solutions');
$pdf->PrintChapter(1,'Terms & Conditions','T&C.txt');
$pdf->Output();

?>

 

regards

Link to comment
Share on other sites

i have read up on the cell command and it is being used but can not seem to get them to link up the coding i am using is

 

# Company Details
$pdf->SetFont('Arial','',12);
$pdf->Cell(0,6,$companyname,0,1,'R');
$pdf->SetFont('Arial','',10);
for ( $i = 0; $i <= 4; $i += 1) {
$pdf->Cell(0,4,trim($companyaddress[$i]),0,1,'R');
}

# Clients Details
$pdf->SetFont('Arial','B',12);
$pdf->Cell(0,4,$_LANG["invoicesinvoicedto"],0,1);
$pdf->SetFont('Arial','',10);
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('Arial','',10);
$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["city"].", ".$clientsdetails["state"].", ".$clientsdetails["postcode"],0,1,'L');
$pdf->Cell(0,4,$clientsdetails["country"],0,1,'L'); 
$pdf->Ln(10);

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

For the WHMCS team....

 

After seeing a significant number of posts regarding PDF invoices and users having troubles customizing their invoices, I figured I would mention this.

 

We have a custom PDF library we picked up from a ditched project and did a bunch of rewrites to resurrect it and fine-tune the output formatting for use with reports and invoices in our ecommerce software. The library accepts HTML files and outputs them to PDF format. It would seem that this might be a whole lot more useful for WHMCS to incorporate such a library as it would allow users to work with a smarty template instead of a PHP script to edit the formatting of their invoice. We have this library working well with HTML pages containing nested tables and various formatting applied. Shouldn't be much trouble to integrate with WHMCS. Please let me know if you're interested and I will put in a support ticket to discuss further.

Link to comment
Share on other sites

Okay so I noticed that the invoice item doesn't include the actual item description that I put in when I enter the product. Invoice just shows the name of the product / price. How can I show the full description of the item that is being billed for on the invoice.

 

Thank you.

Link to comment
Share on other sites

I was afraid it would be something like that instead of having a smartfield or something to the current template. I had asked the same question in a different thread the end of January and still haven't received a reply on it.

 

keeping my fingers crossed that someone knows how to do it and will assist those of us who are smarty and php unknowledgable.

 

betty

Link to comment
Share on other sites

I don't see subject or keywords filled out and I too would like to see a blurb below to invoice details added. A standard text we can edit about invoice policy. I would also like to see the payment gateway and subscription ID whether it was auth trans ID & auth code or paypal trans ID

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