rahulkg Posted August 5, 2019 Share Posted August 5, 2019 Hi, In whmcs when we view an invoice as a client from admin side, it shows all the details of bank transfer , but if you download the invoice , it wont show all the bank details in pdf; so how can we modify the download pdf of invoice and incorporate all bank details same as that invoice shown when view as client . Please let me know how to do this? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 5, 2019 Share Posted August 5, 2019 that was only from a year ago, so should still work - and before you ask, hooks are not an option because the invoicePDF template file can't use them... and is effectively a .php file anyway. 0 Quote Link to comment Share on other sites More sharing options...
rahulkg Posted August 7, 2019 Author Share Posted August 7, 2019 Hi Brian, But in the link , https://whmcs.community/topic/291657-edit-pdf-adjust-logo-add-bank-details/ you manually input the bank acc no: but what I actually need is the bank address, bank axccount no, IBAN etc should come automatically in every invoice pdf just as view invoice page viewinvoice.php?id=xxxx&view_as_client=xxx what should be the code for that and how to modify invoicepdf.php file to add bank details. please give me a solution. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 7, 2019 Share Posted August 7, 2019 36 minutes ago, rahulkg said: But in the link , https://whmcs.community/topic/291657-edit-pdf-adjust-logo-add-bank-details/ you manually input the bank acc no: but what I actually need is the bank address, bank axccount no, IBAN etc should come automatically in every invoice pdf just as view invoice page viewinvoice.php?id=xxxx&view_as_client=xxx what should be the code for that and how to modify invoicepdf.php file to add bank details. please give me a solution. well that thread was originally used to add details for various payment methods - not just the details used in the "Pay To" text area from the General Settings -> General page. however, if all you want to do is use those details, then just add the variable $payto in your template layout and that will output the details from the above textarea. 0 Quote Link to comment Share on other sites More sharing options...
rahulkg Posted August 7, 2019 Author Share Posted August 7, 2019 (edited) Not understand fully, you mean add bank details in payto textarea in whmcs General settings->General tab. So it will display in invoicepdf if and only if the clients payment gateway is banktransfer ? or to achieve this (to show bank details if the client's payment gateway is banktransfer and otherwise not just as in viewinvoice) any condition to be written in invoicepdf file. please clarify this also. Currently what I added is $pdf->writeHTML($payto, true, false, false, false, ''); in our invoicepdf file but it outputs our address instead of bankransfer. Edited August 7, 2019 by rahulkg 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 7, 2019 Share Posted August 7, 2019 1 hour ago, rahulkg said: Not understand fully, you mean add bank details in payto textarea in whmcs General settings->General tab. sorry no - I was distracted and ended up pointing you in the wrong direction! 🙄 to get the bank transfer information you want, you'd have to pull it from the database... use WHMCS\Database\Capsule; $banktransfer = Capsule::table('tblpaymentgateways')->where('gateway','banktransfer')->where('setting','instructions')->value('value'); that above code can go anywhere in the invoicepdf.tpl file after <?php and before the place you need to output it. taking the code from the previous thread... if ($status!="Unpaid") { # 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, ''); } elseif ($paymentmethod=="Bank Transfer") { // The "visible name" of the payment method #Payment Method $pdf->SetFont($pdfFont,'B',12); $pdf->Cell(0,4,"Payment",0,1); $pdf->Ln(5); $pdf->SetFont($pdfFont,'',8); $paymethhtml = '<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($paymethhtml, true, false, false, false, ''); } so if an invoice is not unpaid, it displays the transactions table.... if the invoice is currently unpaid, and the gateway is Bank Transfer, then it will display the table that shows the payto methods for the Bank Transfer method pulled from the database (which is what you enter into the instructions textarea in the payment gateways setting for that gateway. 2 Quote Link to comment Share on other sites More sharing options...
rahulkg Posted September 18, 2019 Author Share Posted September 18, 2019 Its working and thank you. 0 Quote Link to comment Share on other sites More sharing options...
rahulkg Posted September 25, 2019 Author Share Posted September 25, 2019 Hi Brian , But the code breaks when whmcs upgraded to 7.8.3. even after adding use WHMCS\Database\Capsule; $banktransfer = Capsule::table('tblpaymentgateways')->where('gateway','banktransfer')->where('setting','instructions')->value('value'); line after php opening tag it says "OOPS error message". Could you please check and update me. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 26, 2019 Share Posted September 26, 2019 18 hours ago, rahulkg said: line after php opening tag it says "OOPS error message". when that happens, you need to enable Display Errors in setup -> general settings -> other and it will tell you what and where the error is... that is useful info for me to know so that I can debug it. I don't think there is anything wrong with the actual code - try the attached file in your v7.8.3 install. invoicepdf.tpl 1 Quote Link to comment Share on other sites More sharing options...
rahulkg Posted September 26, 2019 Author Share Posted September 26, 2019 ok its a useful information . Its working fine, Thank you very much. 0 Quote Link to comment Share on other sites More sharing options...
Phasma Posted January 29, 2021 Share Posted January 29, 2021 On 8/7/2019 at 2:02 PM, brian! said: sorry no - I was distracted and ended up pointing you in the wrong direction! 🙄 to get the bank transfer information you want, you'd have to pull it from the database... use WHMCS\Database\Capsule; $banktransfer = Capsule::table('tblpaymentgateways')->where('gateway','banktransfer')->where('setting','instructions')->value('value'); that above code can go anywhere in the invoicepdf.tpl file after <?php and before the place you need to output it. taking the code from the previous thread... if ($status!="Unpaid") { # 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, ''); } elseif ($paymentmethod=="Bank Transfer") { // The "visible name" of the payment method #Payment Method $pdf->SetFont($pdfFont,'B',12); $pdf->Cell(0,4,"Payment",0,1); $pdf->Ln(5); $pdf->SetFont($pdfFont,'',8); $paymethhtml = '<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($paymethhtml, true, false, false, false, ''); } so if an invoice is not unpaid, it displays the transactions table.... if the invoice is currently unpaid, and the gateway is Bank Transfer, then it will display the table that shows the payto methods for the Bank Transfer method pulled from the database (which is what you enter into the instructions textarea in the payment gateways setting for that gateway. Brian, how to use this in whmcs 8 ? tblpaymentgateways/banktransfer/instructions is obfuscated ... tnx 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 31, 2021 Share Posted January 31, 2021 On 29/01/2021 at 23:42, Phasma said: Brian, how to use this in whmcs 8 ? tblpaymentgateways/banktransfer/instructions is obfuscated ... tnx instead of using capsule... use WHMCS\Database\Capsule; $banktransfer = Capsule::table('tblpaymentgateways')->where('gateway','banktransfer')->where('setting','instructions')->value('value'); in v8, you could use this... require_once ROOTDIR . '/includes/gatewayfunctions.php'; $banktransfer = getGatewayVariables('banktransfer'); ... and then where you previously had... <td width="67%" bgcolor="#ffffff" style="text-align:center;">'.nl2br($banktransfer).'</td> you change it to... <td width="67%" bgcolor="#ffffff" style="text-align:center;">'.nl2br($banktransfer['instructions']).'</td> 1 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.