Freshwebhosting Posted May 30, 2014 Share Posted May 30, 2014 How to Add Payment Details to your WHMCS PDF Invoices WHMCS provides some documentation on how to customise your PDF Invoices. Their article includes some specific pointers to help you add your own logo, and it gives an overview of the available variables which I found useful… however for the uninitiated or PHP-challenged I can imagine that doing something simple like adding available payment methods to your invoices would remain a mystery. So, here’s a simple tutorial you can follow to add payment details to your WHMCS PDF invoices /http://www.enigmaweb.com.au/how-to-add-payment-details-to-your-whmcs-pdf-invoices/ (this is not spam) THIS WORKS 0 Quote Link to comment Share on other sites More sharing options...
CCSupport Posted June 4, 2014 Share Posted June 4, 2014 Thanks. It did work with a bit of fiddling. A nice little addition to the PDF invoice We needed to align the text as well as dropping the text down too due to using the Invoice Auto Login for our PDF Invoices which conflicts on the same line. So...here's what we have done....just to note, we also added the self creating invoice number at the bottom of the Bank Transfer part: # Payment Details $pdf->Ln(; $pdf->SetFont('freesans','B',12); $pdf->Cell(28,7,"Ways To Pay",0,1,'C'); $pdf->SetFont('freesans','B',9); $pdf->Cell(60,7,"Bank Transfer",0,0,'L');$pdf->Cell(60,7,"Credit / Debit Card",0,0,'L'); $pdf->Ln(6); $pdf->SetFont('freesans','',9); $ypos = $pdf->GetY(); $pdf->SetXY(15,$ypos); $pdf->MultiCell(60,4,"Bank: [i]Bank_Name_here[/i]\nAcc. Name: [i]Account_Name_here[/i]\nSort Code: [i]12-34-56[/i]\nAccount No: [i]123456789[/i]\nRef:#$invoicenum"); $pdf->SetXY(75,$ypos); $pdf->MultiCell(60,4,"Please Click 'Pay Invoice'\nor Login to the Client Area\nto pay by Credit / Debit Card\n"); 0 Quote Link to comment Share on other sites More sharing options...
MattH Posted July 8, 2014 Share Posted July 8, 2014 Hi, I seem to have no end of issues trying to get this PDF Template updated. I've used one developer who had no luck so I figure the only way I can ever customize it is to do it myself. I added this excerpt of code: # Payment Details $pdf->Ln(; $pdf->SetFont('freesans','B',12); $pdf->Cell(28,7,"Ways To Pay",0,1,'C'); $pdf->SetFont('freesans','B',9); $pdf->Cell(60,7,"Bank Transfer",0,0,'L');$pdf->Cell(60,7,"Credit / Debit Card",0,0,'L'); $pdf->Ln(6); $pdf->SetFont('freesans','',9); $ypos = $pdf->GetY(); $pdf->SetXY(15,$ypos); $pdf->MultiCell(60,4,"Bank: [i]Bank_Name_here[/i]\nAcc. Name: [i]Account_Name_here[/i]\nSort Code: [i]12-34-56[/i]\nAccount No: [i]123456789[/i]\nRef:#$invoicenum"); $pdf->SetXY(75,$ypos); $pdf->MultiCell(60,4,"Please Click 'Pay Invoice'\nor Login to the Client Area\nto pay by Credit / Debit Card\n"); However the payments details just overlay the payee details at the top of the invoice and obfuscate the layout. Also, the font turns red, just like the Unpaid Colour. Would you have any suggestions for this? Also, how do you get the Unpaid/Paid stripe in the top right hand corner instead of the ugly "UNPAID/PAID" stamp? Thanks 0 Quote Link to comment Share on other sites More sharing options...
totallytech Posted September 29, 2014 Share Posted September 29, 2014 (edited) Hey, Did anyone fix this? Mine is looking the same as above, All text in red, horrible red stamp etc... Also, my logo doesn't show.... Any ideas? This is the code for the logo: # Logo $pdf->Image(ROOTDIR.'/images/pdflogo.png',374,55); I've checked that 'https://secure.mydomain.com/images/pdflogo.png' exists which is all good, the file size is 243px x 129px so it should all be ok What have I missed? Edited September 29, 2014 by totallytech 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 29, 2014 Share Posted September 29, 2014 Also, my logo doesn't show.... Any ideas? This is the code for the logo: # Logo $pdf->Image(ROOTDIR.'/images/pdflogo.png',374,55); I've checked that 'https://secure.mydomain.com/images/pdflogo.png' exists which is all good, the file size is 243px x 129px so it should all be ok What have I missed? as a temporary measure, try a jpg instead and see if that works. I think the problem might be caused by how you saved the .png - I think pdf is sensitive to the bit-depth of the png image... some settings work, some don't - but they'll all work in a browser! I just had a look at my logo png and it's 32-bit, so perhaps re-save your png as 32-bit and see if that helps.. 0 Quote Link to comment Share on other sites More sharing options...
totallytech Posted September 29, 2014 Share Posted September 29, 2014 (edited) as a temporary measure, try a jpg instead and see if that works. I think the problem might be caused by how you saved the .png - I think pdf is sensitive to the bit-depth of the png image... some settings work, some don't - but they'll all work in a browser! I just had a look at my logo png and it's 32-bit, so perhaps re-save your png as 32-bit and see if that helps.. Hey, Nope its just not happening I've tried jpg, png grrrrr... Also, I've added some code as above but its just gone screwy <?php # Logo $pdf->Image(ROOTDIR.'/images/pdflogo.jpg',374,55); # Company Details $pdf->SetFont('helvetica','',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->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->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'); $pdf->Cell(0,6,$_LANG["invoicesdatedue"].': '.$duedate.'',0,1,'L','1'); $pdf->Ln(10); $startpage = $pdf->GetPage(); # Clients Details $pdf->SetFont('helvetica','B',10); $pdf->Cell(0,4,$_LANG["invoicesinvoicedto"],0,1); $pdf->SetFont('helvetica','',; 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','',; $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('helvetica','B',10); $pdf->SetFillColor(239); $pdf->Cell(140,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) { $rowcount = $pdf->getNumLines($item['description'], 140); $pdf->MultiCell(140,$rowcount * 5,$item['description'],1,'L',0,0); $pdf->MultiCell(40,$rowcount * 5,$item['amount'],1,'C',0,0); $pdf->Ln(); } $pdf->SetFont('helvetica','B',10); $pdf->Cell(140,7,$_LANG["invoicessubtotal"],1,0,'R','1'); $pdf->Cell(40,7,$subtotal,1,0,'C','1'); $pdf->Ln(); if ($taxname) { $pdf->Cell(140,7,$taxrate."% ".$taxname,1,0,'R','1'); $pdf->Cell(40,7,$tax,1,0,'C','1'); $pdf->Ln(); } if ($taxname2) { $pdf->Cell(140,7,$taxrate2."% ".$taxname2,1,0,'R','1'); $pdf->Cell(40,7,$tax2,1,0,'C','1'); $pdf->Ln(); } $pdf->Cell(140,7,$_LANG["invoicescredit"],1,0,'R','1'); $pdf->Cell(40,7,$credit,1,0,'C','1'); $pdf->Ln(); $pdf->Cell(140,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"); } $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',40); $pdf->Cell(120,20,strtoupper($statustext),0,0,'C'); $pdf->setPage($endpage); # Payment Details $pdf->SetTextColor(0,0,0); $pdf->SetFont('helvetica','B',12); $pdf->Cell(180,110,"HOW TO PAY",0,0,'C'); $pdf->SetFont('helvetica','B',9); $pdf->Cell(60,7,"Cheque",0,0,'L');$pdf->Cell(60,7,"BACS",0,0,'L');$pdf->Cell(40,7,"Online",0,0,'L'); $pdf->Ln(); $pdf->SetFont('helvetica','',9); $ypos = $pdf->GetY(); $pdf->SetXY(20,$ypos); $pdf->MultiCell(60,4,"Please send cheque payable to\nTotally Tech IT Ltd\nTo:\n"); for ( $i = 1; $i <= count($companyaddress); $i += 1) { $pdf->MultiCell(60,4,trim($companyaddress[$i]),0,1,'L'); } $pdf->SetXY(80,$ypos); $pdf->MultiCell(60,4,"Account Name: XXXX\nSort Code: XXXX\nAccount No: XXXX\nRef: #$invoicenum\n"); $pdf->SetXY(140,$ypos); $pdf->MultiCell(60,4,"Please visit https://XXXX.XXXX.it\nto pay online with most credit or \ndebit cards.\n"); ?> Any ideas? Oh, MattH - Try adding $pdf->SetTextColor(0,0,0); above the section of code which adds the payment details etc, that changes it from the red I'm still working on the spacing Edited September 29, 2014 by totallytech 0 Quote Link to comment Share on other sites More sharing options...
mbit Posted September 29, 2014 Share Posted September 29, 2014 Why don't you create an HTML layout? Forget about cells 0 Quote Link to comment Share on other sites More sharing options...
totallytech Posted September 29, 2014 Share Posted September 29, 2014 Why don't you create an HTML layout? Forget about cells Trouble is I've no knowledge of this and I cannot find a simple starter guide for pdf php code... I'll need to have a google around and see what I can find 0 Quote Link to comment Share on other sites More sharing options...
mbit Posted September 29, 2014 Share Posted September 29, 2014 WHMCS default invoice template already contains a simple HTML table...take a look at the code and use it as a reference. If you have any knowledge of HTML, this should be quite easy 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 30, 2014 Share Posted September 30, 2014 mbit is absolutely right on this - i've designed/converted numerous custom whmcs invoice templates for clients and it's easier to use html tables where possible. quick logo fix... try using the following line for your logo instead... $pdf->Image(ROOTDIR.'/images/logo.png',20,25,75); but frankly, i'd recommend scrapping this - for the time it would take you to learn more about tcpdf and fix this, you might as well go back to the default invoicepdf.tpl template and make the changes you require to it - everything apart from your "STATUSTEXT" can be done as html tables. actually, if this payment method options are supposed to be below the invoice items, it's probably safer to do it in html anyway. I was sure that i'd posted a reply about doing a three column table for payment options - but I can't find it... I definitely did it for someone, so if it's not here, it was for a paying client... but the principles are simple - a couple of links below might help. http://forum.whmcs.com/showthread.php?82350-PDF-Invoice-custom-html-text&p=351055 http://forum.whmcs.com/showthread.php?73163-Place-bank-amp-cheque-details-at-the-end-of-invoice-Updated as an example, here's an invoice using a template that i've quickly tweaked to include your payment details... everything you see above is using 100% tables - your section doesn't quite match (as i've changed fonts), but that would be easily fixed... #Payment Method $pdf->SetFont('Helvetica','B',12); $pdf->Cell(0,4,"HOW TO PAY",0,1); $pdf->Ln(5); $pdf->SetFont('Helvetica','',; $paymethhtml = '<table width="100%" cellspacing="1" cellpadding="2" border="0"> <tr height="30"> <td width="33%" style="text-align:center;"><strong>Cheque</strong><br><br>Please send cheque payable to<br>Totally Tech IT Ltd<br>To:<br><br></td> <td width="34%" style="text-align:center;"><strong>BACS</strong><br><br>Account Name: XXXX<br>Sort Code: XXXX<br>Account No: XXXX<br>Ref: #'.$invoicenum.'</td> <td width="33%" style="text-align:center;"><strong>Online</strong><br><br>Please visit https://XXXX.XXXX.it to pay online with most credit or debit cards.</td> </tr></table>'; $pdf->writeHTML($paymethhtml, true, false, false, false, ''); now you can't just copy & paste the above code into your current template, but you should be able to follow how it works.. so if you wanted to add a fourth column, you just change the cell widths to 25% - much simpler than messing with tcpdf. 0 Quote Link to comment Share on other sites More sharing options...
Manchester Web Hosting Posted October 19, 2020 Share Posted October 19, 2020 @brian! I know this is an old post but trying to figure something out re pdf invoices and really struggling with some adjustments. Have read quite a few of the links but nothing has helped so far. On 9/30/2014 at 1:22 AM, brian! said: now you can't just copy & paste the above code into your current template, but you should be able to follow how it works.. so if you wanted to add a fourth column, you just change the cell widths to 25% - much simpler than messing with tcpdf. Yup, I get that. Actually tested and figured out how to get bank transfer text displayed if its the payment method being used with: if ($paymentmethod=="Bank Transfer") { $pdf->SetFont('$pdfFont','B',9); $pdf->Cell(180,7,"Bank Transfer",0,0,'R'); $pdf->Ln(10); $pdf->SetFont('$pdfFont','',9); $ypos = $pdf->GetY(); $pdf->SetXY(15,$ypos); $pdf->MultiCell(180,4,"Bank: [i]Bank_Name_here[/i]\nAcc. Name: [i]Account_Name_here[/i]\nSort Code: [i]12-34-56[/i]\nAccount No: [i]123456789[/i]\nRef:#$invoicenum"); $pdf->Ln(10); } It outputs the right info (after replacing the dummy text). The only issue I seem to be having is trying to get it all on the right adjcent to the invoice to details on a default six theme. Tried just about everything and all i seem to be able to get close to is overlapping the text at the top of the pdf and ontop of the company details (plus messes up the rest of the pdf :( ) Been at it a few hours but its going way over my head and heres me thinking hooks were difficult. Any chance you can help me with this last bit? FYI here is the full code from invoicepdf.tpl: <?php # Logo $logoFilename = 'placeholder.png'; if (file_exists(ROOTDIR . '/assets/img/logo.png')) { $logoFilename = 'logo.png'; } elseif (file_exists(ROOTDIR . '/assets/img/logo.jpg')) { $logoFilename = 'logo.jpg'; } $pdf->Image(ROOTDIR . '/assets/img/' . $logoFilename, 15, 25, 75); # Invoice Status $pdf->SetXY(0, 0); $pdf->SetFont($pdfFont, 'B', 28); $pdf->SetTextColor(255); $pdf->SetLineWidth(0.75); $pdf->StartTransform(); $pdf->Rotate(-35, 100, 225); if ($status == 'Draft') { $pdf->SetFillColor(200); $pdf->SetDrawColor(140); } elseif ($status == 'Paid') { $pdf->SetFillColor(151, 223, 74); $pdf->SetDrawColor(110, 192, 70); } elseif ($status == 'Cancelled') { $pdf->SetFillColor(200); $pdf->SetDrawColor(140); } elseif ($status == 'Refunded') { $pdf->SetFillColor(131, 182, 218); $pdf->SetDrawColor(91, 136, 182); } elseif ($status == 'Collections') { $pdf->SetFillColor(3, 3, 2); $pdf->SetDrawColor(127); } else { $pdf->SetFillColor(223, 85, 74); $pdf->SetDrawColor(171, 49, 43); } if ($status == 'Payment Pending'){ $pdf->Cell(100, 18, strtoupper(Lang::trans('invoices' . str_replace(' ', '', $status))), 'TB', 0, 'C', '1'); } else { $pdf->Cell(100, 18, strtoupper(Lang::trans('invoices' . strtolower($status))), 'TB', 0, 'C', '1'); } $pdf->StopTransform(); $pdf->SetTextColor(0); # Company Details $pdf->SetXY(15, 42); $pdf->SetFont($pdfFont, '', 13); foreach ($companyaddress as $addressLine) { $pdf->Cell(180, 4, trim($addressLine), 0, 1, 'R'); $pdf->SetFont($pdfFont, '', 9); } if ($taxCode) { $pdf->Cell(180, 4, $taxIdLabel . ': ' . trim($taxCode), 0, 1, 'R'); } $pdf->Ln(5); # Header Bar /** * Invoice header * * You can optionally define a header/footer in a way that is repeated across page breaks. * For more information, see https://docs.whmcs.com/PDF_Invoice#Header.2FFooter */ $pdf->SetFont($pdfFont, 'B', 15); $pdf->SetFillColor(239); $pdf->Cell(0, 8, $pagetitle, 0, 1, 'L', '1'); $pdf->SetFont($pdfFont, '', 10); $pdf->Cell(0, 6, Lang::trans('invoicesdatecreated') . ': ' . $datecreated, 0, 1, 'L', '1'); $pdf->Cell(0, 6, Lang::trans('invoicesdatedue') . ': ' . $duedate, 0, 1, 'L', '1'); $pdf->Ln(10); $startpage = $pdf->GetPage(); # Clients Details $addressypos = $pdf->GetY(); $pdf->SetFont($pdfFont, 'B', 10); $pdf->Cell(0, 4, Lang::trans('invoicesinvoicedto'), 0, 1); $pdf->SetFont($pdfFont, '', 9); if ($clientsdetails["companyname"]) { $pdf->Cell(0, 4, $clientsdetails["companyname"], 0, 1, 'L'); $pdf->Cell(0, 4, Lang::trans('invoicesattn') . ': ' . $clientsdetails["firstname"] . ' ' . $clientsdetails["lastname"], 0, 1, 'L'); } else { $pdf->Cell(0, 4, $clientsdetails["firstname"] . " " . $clientsdetails["lastname"], 0, 1, 'L'); } $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'); if (array_key_exists('tax_id', $clientsdetails) && $clientsdetails['tax_id']) { $pdf->Cell(0, 4, $taxIdLabel . ': ' . $clientsdetails['tax_id'], 0, 1, 'L'); } if ($customfields) { $pdf->Ln(); foreach ($customfields as $customfield) { $pdf->Cell(0, 4, $customfield['fieldname'] . ': ' . $customfield['value'], 0, 1, 'L'); } } $pdf->Ln(10); # Bank transfer output if ($paymentmethod=="Bank Transfer") { $pdf->SetFont('$pdfFont','B',9); $pdf->Cell(180,7,"Bank Transfer",0,0,'R'); $pdf->Ln(10); $pdf->SetFont('$pdfFont','',9); $ypos = $pdf->GetY(); $pdf->SetXY(15,$ypos); $pdf->MultiCell(180,4,"Bank: [i]Bank_Name_here[/i]\nAcc. Name: [i]Account_Name_here[/i]\nSort Code: [i]12-34-56[/i]\nAccount No: [i]123456789[/i]\nRef:#$invoicenum"); $pdf->Ln(10); } # Invoice Items $tblhtml = '<table width="100%" bgcolor="#ccc" cellspacing="1" cellpadding="2" border="0"> <tr height="30" bgcolor="#efefef" style="font-weight:bold;text-align:center;"> <td width="80%">' . Lang::trans('invoicesdescription') . '</td> <td width="20%">' . Lang::trans('quotelinetotal') . '</td> </tr>'; foreach ($invoiceitems as $item) { $tblhtml .= ' <tr bgcolor="#fff"> <td align="left">' . nl2br($item['description']) . '<br /></td> <td align="center">' . $item['amount'] . '</td> </tr>'; } $tblhtml .= ' <tr height="30" bgcolor="#efefef" style="font-weight:bold;"> <td align="right">' . Lang::trans('invoicessubtotal') . '</td> <td align="center">' . $subtotal . '</td> </tr>'; if ($taxname) { $tblhtml .= ' <tr height="30" bgcolor="#efefef" style="font-weight:bold;"> <td align="right">' . $taxrate . '% ' . $taxname . '</td> <td align="center">' . $tax . '</td> </tr>'; } if ($taxname2) { $tblhtml .= ' <tr height="30" bgcolor="#efefef" style="font-weight:bold;"> <td align="right">' . $taxrate2 . '% ' . $taxname2 . '</td> <td align="center">' . $tax2 . '</td> </tr>'; } $tblhtml .= ' <tr height="30" bgcolor="#efefef" style="font-weight:bold;"> <td align="right">' . Lang::trans('invoicescredit') . '</td> <td align="center">' . $credit . '</td> </tr> <tr height="30" bgcolor="#efefef" style="font-weight:bold;"> <td align="right">' . Lang::trans('invoicestotal') . '</td> <td align="center">' . $total . '</td> </tr> </table>'; $pdf->writeHTML($tblhtml, true, false, false, false, ''); $pdf->Ln(5); # Transactions $pdf->SetFont($pdfFont, 'B', 12); $pdf->Cell(0, 4, Lang::trans('invoicestransactions'), 0, 1); $pdf->Ln(5); $pdf->SetFont($pdfFont, '', 9); $tblhtml = '<table width="100%" bgcolor="#ccc" cellspacing="1" cellpadding="2" border="0"> <tr height="30" bgcolor="#efefef" style="font-weight:bold;text-align:center;"> <td width="25%">' . Lang::trans('invoicestransdate') . '</td> <td width="25%">' . Lang::trans('invoicestransgateway') . '</td> <td width="30%">' . Lang::trans('invoicestransid') . '</td> <td width="20%">' . Lang::trans('invoicestransamount') . '</td> </tr>'; if (!count($transactions)) { $tblhtml .= ' <tr bgcolor="#fff"> <td colspan="4" align="center">' . Lang::trans('invoicestransnonefound') . '</td> </tr>'; } else { foreach ($transactions AS $trans) { $tblhtml .= ' <tr bgcolor="#fff"> <td align="center">' . $trans['date'] . '</td> <td align="center">' . $trans['gateway'] . '</td> <td align="center">' . $trans['transid'] . '</td> <td align="center">' . $trans['amount'] . '</td> </tr>'; } } $tblhtml .= ' <tr height="30" bgcolor="#efefef" style="font-weight:bold;"> <td colspan="3" align="right">' . Lang::trans('invoicesbalance') . '</td> <td align="center">' . $balance . '</td> </tr> </table>'; $pdf->writeHTML($tblhtml, true, false, false, false, ''); # Notes if ($notes) { $pdf->Ln(5); $pdf->SetFont($pdfFont, '', 8); $pdf->MultiCell(170, 5, Lang::trans('invoicesnotes') . ': ' . $notes); } # Generation Date $pdf->SetFont($pdfFont, '', 8); $pdf->Ln(5); $pdf->Cell(180, 4, Lang::trans('invoicepdfgenerated') . ' ' . getTodaysDate(1), '', '', 'C'); /** * Invoice footer */ 0 Quote Link to comment Share on other sites More sharing options...
Manchester Web Hosting Posted October 20, 2020 Share Posted October 20, 2020 SO after much faffing around trying to get this to work and look good here are the results which may help others that would like to customise and display specific payment info on there invoices: The code itself will display the output IF the bank transfer method is used. I guess you could change that for your own preferred pament method that you would like to display OR have a combination. Shouldnt be too hard I guess, just need to adjust the IF statement. For this one IF the bank transfer option is used then it will display the required details on the invoice IF its not the payment method then it wont display anything: #BANK TRANSFER PAYMENT if ($paymentmethod=="Bank Transfer") { $pdf->SetXY(15, 109); $pdf->SetFont('$pdfFont','B',10); $pdf->Cell(180,15,"Payment Due Via Bank Transfer",0,0,'R'); $pdf->Ln(10); $pdf->SetFont('$pdfFont','',9); $pdf->MultiCell(180,7,"Bank: Bank_Name_here\nAcc. Name: Account_Name_here\nSort Code: 12-34-56\nAccount No: 123456789\nRef:#$invoicenum"); $pdf->Ln(10); } ONLY issue with this is that I havent been able to figure out how to get the multicell to the right. The result of the above code looks like this: Not pretty at all 😞 After much tinkering this code (whilst not at all elegant and most probarbly could be optimised) works how we want it to show the details on the right: #BANK TRANSFER PAYMENTS if ($paymentmethod=="Bank Transfer") { $pdf->SetXY(15, 109); $pdf->SetFont('$pdfFont','B',10); $pdf->Cell(180,15,"Payment Due Via Bank Transfer",0,0,'R'); $pdf->Ln(10); $pdf->SetFont('$pdfFont','',9); $pdf->Cell(0, 4, "Bank: Bank_Name_here", 0, 1, 'R'); $pdf->Cell(0, 4, "Name: Account_Name_here", 0, 1, 'R'); $pdf->Cell(0, 4, "Sort Code: 12-34-56", 0, 1, 'R'); $pdf->Cell(0, 4, "Account No: 123456789", 0, 1, 'R'); $pdf->Cell(0, 4, "IBAN: 123456789", 0, 1, 'R'); $pdf->Cell(0, 4, "SWIFT: 123456789", 0, 1, 'R'); $pdf->Cell(0, 4, "Ref: #$invoicenum", 0, 1, 'R'); $pdf->Ln(10); } The result is: For those that want to use it dont forget to update the bank details and in your invoicepdf.tpl add the code around line 104. Hope this helps someone 🙂 0 Quote Link to comment Share on other sites More sharing options...
Hein Posted January 20, 2023 Share Posted January 20, 2023 It's perfect to add this to the new invoicepdffooter.tpl as well but it will repeat on each page (so it seems) so be aware of that and placement. (I'm checking with WHMCS right now if it is possible to only show invoicepdffooter on the first page ... will update if there is a way to do that, but I doubt it) 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.