Jump to content

customising Invoice


leew87

Recommended Posts

hi

 

just signed up to WHMCS i am trying to edit the invoice sent out by this system i have tried to edit pdfconfig.php to do this but now i get blank invoices sent

 

below is a copy of my pdfconfig.php file

 

<?php

# Logo

$pdf->Image(ROOTDIR.'/images/logo.jpg',20,25);

# Company Details

$pdf->SetFont('Arial','',13);

$pdf->Cell(0,6,$companyname,0,1,'R');

$pdf->SetFont('Arial','',;

for ( $i = 0; $i <= 4; $i += 1) {

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

}

$pdf->Ln(5);

# Header Bar

$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->SetFillColor(239);

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

$pdf->Cell(0,6,$_LANG["invoicesdatecreated"].': '.$datecreated.'',0,1,'R','1');

$pdf->SetFont('Arial','B',15);

$pdf->Cell(0,8,$invoiceprefix.$invoicenum,0,1,'R','1');


# $pdf->Cell(0,6,$_LANG["invoicesdatedue"].': '.$duedate.'',0,1,'R','1');

$pdf->Ln(10);

# Clients Details

$pdf->Cell(0,4,$_LANG["invoicesinvoicedto"],0,1);

$pdf->SetFont('Arial','B',;

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','',;

$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);



$pdf->SetDrawColor(200);



$pdf->SetFont('OCR A Extended','B',16);

$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('Arial','',10);

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',10);


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

$pdf->Cell(40,7,$currencysymbol.$subtotal,1,0,'C','1');

$pdf->Ln();

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();



if ($notes) {

$pdf->SetFont('Arial','',;

$pdf->MultiCell(170,5,$_LANG["invoicesnotes"].": $notes");

}

$pdf->SetXY(50,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');

?>

 

 

i just learning Php to be honest it is more than likely something i have done

 

i am trying to make it look like this invoice http://www.illit.co.uk/ILLITInvoice.pdf

 

can anyone help?

 

thanks in advance

 

Leew87

Link to comment
Share on other sites

just signed up to WHMCS i am trying to edit the invoice sent out by this system i have tried to edit pdfconfig.php to do this but now i get blank invoices sent

 

When you say "blank invoices are sent" do you mean the pdf page is just plain white (blank), or do you mean no data is filled in?

Link to comment
Share on other sites

i am closer to creating my invoice that i sent link for now but still not 100% there as you can see this is my pdfconfig.pho now which seems to be working

 

<?php

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

# Header Bar
$pdf->Ln(4);
$invoiceprefix = $_LANG["invoicenumber"];

$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,4,$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(212,212,212);
$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,0,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,200,200);
$pdf->MultiCell(170,5,$_LANG["invoicesnotes"].": $notes");
}

# Invoice Status
$pdf->SetXY(45,90);
if ($status=="Cancelled") {
$statustext = $_LANG["invoicescancelled"];
   $pdf->SetTextColor(162,162,162);
} elseif ($status=="Unpaid") {
$statustext = $_LANG["invoicesunpaid"];
   $pdf->SetTextColor(204,0,0);
} elseif ($status=="Paid") {
$statustext = $_LANG["invoicespaid"];
   $pdf->SetTextColor(51,96,9);
}
$pdf->SetFont('Arial','B',40);
$pdf->Cell(120,20,strtoupper($statustext),0,0,'C');

//Page footer
function Footer()
{
   //Position at 1.5 cm from bottom
   $this->SetY(-15);
   //Arial italic 8
   $this->SetFont('Arial','I',;
   //Page number
   $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}


# Turn footer page number off
$pdf->setPrintFooter(false);


?>

 

i still need to find a way to make a extra page and add my own footer as the coding i have for this does not seem to work and move the company name in line with the invoice to field.

Link to comment
Share on other sites

right i am now about 90% complete i put i am having problems calling function from another php file i am getting errors

 

Fatal error: Call to a member function ChapterTitle() on a non-object in /home/illit/public_html/whmcs/includes/extrafunctions.php on line 63

 

can any1 help

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