voskan
December 22, 2020, 9:21am
1
Hi guys,
I’m having trouble with showing the both Company and Client name on my PDF invoices.
After trying a couple of hours, I found this post, where a solution is given to the file source, where the changes can be done, but as I don’t have enough PHP knowlegde, I can’t make the proper changes to achieve the result I’d like to.
Can anyone help me with this?
https://community2.invoiceplane.com/t/topic/8678
Thanks in advance,
Voskan
Hi @voskan ,
For showing it in PDF invoices, you can achieve this by editing the invoice template under application/views/invoice_templates/pdf/InvoicePlane.php
You can keep the existing client name as company name.
Add custom fields in client table for customer name.
Insert the created custom field code in the PDF template.
if ($custom_fields[‘client’][‘Customer Name’]) {
echo '<div>' . htmlsc($custom_fields['client']['Customer Name']) . '</div>';
}
voskan
January 4, 2021, 8:37am
3
Hi Subash,
Thanks a lot for your answer!
I added this code, as I assume there should be a beginning and end to php, but het an error on PDF export page (An uncaught Exception was encountered). What am I doing wrong?
<?php if ($custom_fields[‘client’][‘Customer Name’]) {
echo '<div>' . htmlsc($custom_fields['client']['Customer Name']) . '</div>';
}
?>
Thanks in advance!
Voskan
Hi Voskan,
You can just insert the code above “client_vat_id” in <div id="client">
element.
Without php tags, as it is already present. like this:
<div id="client">
<div>
<b><?php _htmlsc(format_client($invoice)); ?></b>
</div>
<?php if ($custom_fields['client']['Customer Name']) {
echo '<div>' . htmlsc($custom_fields['client']['Customer Name']) . '</div>';
}
if ($invoice->client_vat_id) {
echo '<div>' . trans('vat_id_short') . ': ' . $invoice->client_vat_id . '</div>';
}
.
…
.
} ?>
voskan
January 5, 2021, 3:06pm
5
I did exactly what you told me, but I get the following error in PDF file now:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: Bedrijfsnaam
Filename: pdf/InvoicePlane.php
Line Number: 22
Backtrace:
File:
/home/voskanbg/domains/brage.nl/public_html/invoic
eplane/application/views/invoice_templates/pdf/Invoic
ePlane.php
Line: 22
Function: _error_handler
File:
/home/voskanbg/domains/brage.nl/public_html/invoic
eplane/application/third_party/MX/Loader.php
Line: 464
Function: include
File:
/home/voskanbg/domains/brage.nl/public_html/invoic
eplane/application/third_party/MX/Loader.php
Line: 415
Function: _ci_load
File:
/home/voskanbg/domains/brage.nl/public_html/invoic
eplane/application/helpers/pdf_helper.php
Line: 102
Function: view
File:
/home/voskanbg/domains/brage.nl/public_html/invoic
eplane/application/modules/invoices/controllers/Invoi
ces.php
Line: 272
Function: generate_invoice_pdf
File:
/home/voskanbg/domains/brage.nl/public_html/invoic
eplane/index.php
Line: 325
Function: require_once
Make sure the newly created custom field has data in it and try saving the client record again, hopefully it should work.
1 Like
voskan
January 5, 2021, 4:24pm
7
Yes Yes Yes!!!
It works! Thank you very much Subash! My year can’t go wrong anymore)))
1 Like
system
Closed
January 19, 2021, 4:24pm
8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.