Jump to content

Bank details not showing in pdf invoice


Recommended Posts

I have bank transfer as payment method.

When viewing invoice (as customer) with bank transfer as method the bank details show at the top under due date.

When the invoice is printed or saved as pdf the bank details disappear.

I have searched on this community and found a thread dealing with this but could not understand the solution.

Any help will be appreciated.

 

 

Link to comment
Share on other sites

Hi Danny,

19 hours ago, Danny Turner said:

I have searched on this community and found a thread dealing with this but could not understand the solution.

which thread was it? the one below ??

it was probably one of mine! 🙂

19 hours ago, Danny Turner said:

When the invoice is printed or saved as pdf the bank details disappear.

the HTML and PDF versions of the invoices are two separate templates - to show bank details in the PDF version, you will have to edit the invoicepdf.tpl template... either by hard coding the bank details into the template, or pulling the details from the database (which is what the HTML version does).

Link to comment
Share on other sites

On 13/04/2021 at 12:24 PM, brian! said:

the HTML and PDF versions of the invoices are two separate templates - to show bank details in the PDF version, you will have to edit the invoicepdf.tpl template... either by hard coding the bank details into the template, or pulling the details from the database (which is what the HTML version does).

Brian, I have my EFT details hard coded into the template file just below the notes. However, I would also like to add a link to a merchant account that doesn't have an integration for WHMCS with a text instruction to enter the amount manually once on the landing page for the merchant. Is it possible to put a hyperlink into the PDF using some kind of Smarty tag? I see there are HTML tables, so there must be a way to put in a simple hyperlink. TIA.

Link to comment
Share on other sites

2 hours ago, Cowboy said:

Is it possible to put a hyperlink into the PDF using some kind of Smarty tag?

not using Smarty - you have two options, HTML or use specific TCPDF code.

i'm assuming the EFT details are coded in an HTML table (doesn't matter if they're not) - but you could reproduce the same code again...

$pdf->Ln(5);
$tblhtml = '<table width="100%" cellspacing="1" cellpadding="2" border="0">
    <tr height="30" style="font-weight:bold;">
        <td align="center">Click <a href="https://www.google.com">here</a> to go to Google</td>
    </tr>
</table>';
$pdf->writeHTML($tblhtml, true, false, false, false, '');

c2Gl9QK.png

obviously, styling & content can be changed in the HTML code - which I assume you'll be more familiar with than TCPDF. 🙂

Link to comment
Share on other sites

Ah, thanks! I just put an additional line just below my EFT deets with the merchant URL and it actually converted it to an active URL without any other code needed. Obviously I would prefer to neaten this up, so I will definitely give your idea a whirl. :) 

Edited by Cowboy
Link to comment
Share on other sites

Thanks for the response. I'm sorry but I still don't understand exactly what I should do

ie  in what file (and where in the file) do I add the code

$pdf->Ln(5);
$tblhtml = '<table width="100%" cellspacing="1" cellpadding="2" border="0">
    <tr height="30" style="font-weight:bold;">
        <td align="center">Click <a href="https://www.google.com">here</a> to go to Google</td>
    </tr>
</table>';
$pdf->writeHTML($tblhtml, true, false, false, false, '');

 

On 4/29/2021 at 8:37 PM, brian! said:

$pdf->Ln(5); $tblhtml = '<table width="100%" cellspacing="1" cellpadding="2 border="0"> <tr height="30" style="font-weight:bold;"> <td align="center">Click <a href="https://www.google.com">here</a> to go to Google</td> </tr> </table>'; $pdf->writeHTML($tblhtml, true, false, false, false, '');

 

Link to comment
Share on other sites

  • 2 weeks later...

Unfortunately no.

I am using ver7.1

 I inserted code below in invoice pdf.tpl on line 73 

use WHMCS\Database\Capsule;
$banktransfer = Capsule::table('tblpaymentgateways')->where('gateway','banktransfer')->where('setting','instructions')->value('value');

this made no changes to the saved or printed pdf

Link to comment
Share on other sites

After the code you've already added, which fetches the bank payment instructions, you also need to add the below to display the information on the invoice pdf:

Quote

$paymenthtml = '<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="33%" bgcolor="#efefef" style="text-align:center;"><strong>Bank Transfer</strong></td>
        <td width="67%" bgcolor="#ffffff" style="text-align:center;">'.nl2br($banktransfer).'</td>
    </tr>
	</table>';

$pdf->writeHTML($paymenthtml, true, false, false, false, '');
	

 

as per the other thread at

 

 

Link to comment
Share on other sites

I updated to ver 8

added code as per above

still no joy

my invoice pdf.tpl has had the code added as such: after line 73

$pdf->Ln(10);

use WHMCS\Database\Capsule;
$banktransfer = Capsule::table('tblpaymentgateways')->where('gateway','banktransfer')->where('setting','instructions')->value('value');

$paymenthtml = '<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="33%" bgcolor="#efefef" style="text-align:center;"><strong>Bank Transfer</strong></td>
        <td width="67%" bgcolor="#ffffff" style="text-align:center;">'.nl2br($banktransfer).'</td>
    </tr>
    </table>';

$pdf->writeHTML($paymenthtml, true, false, false, false, '');
    
$startpage = $pdf->GetPage();

 

Link to comment
Share on other sites

Sorry, I'd based my reply on your saying you were using v7.

As per the other thread, in v8 the bank details are encoded, so  you need to change to:

(Remove the space in the word require in the first line)

r equire_once ROOTDIR . '/includes/gatewayfunctions.php';
$banktransfer = getGatewayVariables('banktransfer');
$paymenthtml = '<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="33%" bgcolor="#efefef" style="text-align:center;"><strong>Bank Transfer</strong></td>
        <td width="67%" bgcolor="#ffffff" style="text-align:center;">'.nl2br($banktransfer['instructions']).'</td>
    </tr>
	</table>';

$pdf->writeHTML($paymenthtml, true, false, false, false, '');

I would expect that with the previous code you would be having something appearing on the pdf, but the payment instructions would be obfuscated. Are you seeing that or nothing at all added?

Edited by steph.hope
Link to comment
Share on other sites

no changes on the pdf - even after changing code

my invoice pdf.tpl now has had the code added as such: after line 73

$pdf->Ln(10);

use WHMCS\Database\Capsule;
$banktransfer = getGatewayVariables('banktransfer');
$paymenthtml = '<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="33%" bgcolor="#efefef" style="text-align:center;"><strong>Bank Transfer</strong></td>
        <td width="67%" bgcolor="#ffffff" style="text-align:center;">'.nl2br($banktransfer['instructions']).'</td>
    </tr>
    </table>';

$pdf->writeHTML($paymenthtml, true, false, false, false, '');
    
$startpage = $pdf->GetPage();

 

Link to comment
Share on other sites

the line in your above code:

use WHMCS\Database\Capsule;

needs to be changed as per the post above yours (my posts don't go through when I include that line in them - the one beginning with 'require')

With that line changed and using v8.1.3, it's working for me. I'm not sure what else could be causing it to not work.

 

Link to comment
Share on other sites

21 version of invoicepdf.tpl from v8.1.3 - this works for me...

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

require_once ROOTDIR . '/includes/gatewayfunctions.php';
$banktransfer = getGatewayVariables('banktransfer');
$paymenthtml = '<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="33%" bgcolor="#efefef" style="text-align:center;"><strong>Bank Transfer</strong></td>
        <td width="67%" bgcolor="#ffffff" style="text-align:center;">'.nl2br($banktransfer['instructions']).'</td>
    </tr>
	</table>';
$pdf->writeHTML($paymenthtml, true, false, false, false, '');

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

# 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
 */

how are you testing this? I assume you're either in the admin area downloading the PDFs (preferred option) again, or in the client area.. ??

Link to comment
Share on other sites

"how are you testing this? I assume you're either in the admin area downloading the PDFs (preferred option) again, or in the client area.. ?? "

ahhh spot on - in admin area >unpaid invoice > view as client.- two options at bottom of invoice - print and download - I have been selecting print ... and the bank details disappear - so assumed the script wasn't working

When downloaded the pdf invoice do carry the bank details ,

thanks as that's the most important  thing.

Link to comment
Share on other sites

6 hours ago, Danny Turner said:

ahhh spot on - in admin area >unpaid invoice > view as client.- two options at bottom of invoice - print and download - I have been selecting print ... and the bank details disappear - so assumed the script wasn't working

ahhh I thought you might be doing something like this.... the print option just prints the HTML version (viewinvoice.tpl), whereas download will use the PDF template, invoicepdf.tpl.

Link to comment
Share on other sites

On 29/05/2021 at 05:25, Danny Turner said:

and I guess that  requires another edit...

where ? to do what ?

On 29/05/2021 at 05:25, Danny Turner said:

I would think that this should be part of the original code

you can say that about a lot of good ideas - easy for them to implement, but they never will.... their get out is that the user can do this themselves.

On 29/05/2021 at 05:25, Danny Turner said:

and I guess this needs to be redone after every update?

if you haven't renamed your theme, or made a child of it, then just keep a duplicate of the invoicepdf file in the folder and check it after each update.

Link to comment
Share on other sites

  • 1 year later...

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