Jump to content

add custom field to invoices


Recommended Posts

if you add a client custom field, you will be able to show it on the invoice...

 

http://docs.whmcs.com/PDF_Invoice_Customisation#Displaying_Custom_Fields

 

As of version 4.5 custom fields can be displayed on the printable and PDF invoices by ticking the Setup > Custom Client Fields > Show on Invoice option.

 

the code to show them is already in the invoicepdf.tpl templates - they appear below the clients address...

 

if ($customfields) {
   $pdf->Ln();
   foreach ($customfields AS $customfield) {
       $pdf->Cell(0,4,$customfield['fieldname'].': '.$customfield['value'],0,1,'L');
   }
}

Link to comment
Share on other sites

Thank you for your answer.

 

The problem is that this value will not be the same in all invoices. I need to insert a specific value in each invoice.

 

- - - Updated - - -

 

Maybe I did not explain it clear in my last post.

 

I need to insert in every invoice a value / variable like the invoice id, which can not be the same for all the invoices.

Link to comment
Share on other sites

the value shown in the invoice will be whatever you have entered in the client's profile for that particular field - it will not show the same value, it will take the value from the field in the profile.

 

perhaps if you could tell us what the value will be, we might understand better.

Edited by brian!
Link to comment
Share on other sites

In Greece, when an invoice's subtotal is bigger than 300 euros, the client has to prepay a tax. The prepaid tax has to be printed in the invoice, f.e. if the amount is 500 euros I print in the invoice "Prepaid tax 100 euros".

 

In the invoicepdf.tpl I have added a script that does the above (when the subtotal is bigger than 300 euros it counts and prints the tax).

 

In some cases this is not required.

 

So, I would like to add a select box (Auto or Default / Yes / No) in every invoice.

 

When the select box is set to auto, the script in invoicepdf.tpl will count the prepaid tax.

If it is set to No it will not print anything.

If it is set to Yes it will count the tax for every amount.

 

The problem is that in case I add a profile custom field, it will have the same value for all the client's invoices, and I need to change this value in each invoice. For example, in the same client, in one invoice the select box value can be Yes and in another can be No.

Link to comment
Share on other sites

The problem is that in case I add a profile custom field, it will have the same value for all the client's invoices, and I need to change this value in each invoice. For example, in the same client, in one invoice the select box value can be Yes and in another can be No.

ok, I can now see why this is difficult!

 

unfortunately, you can't tweak the admin side as you can with the client side because of the encrypted files - so you may need to get someone to write an addon module to add the option you describe.

 

although such a button/box/dropdown would only affect invoices that you create - what happens when a customer orders online and receives their invoice automatically?

 

when you say, "In some cases this is not required" - is this based on whether a particular product is in the invoice... if product X has been ordered and subtotal > 300 then print prepaid tax message ?

 

if there is some rule as to which invoices need this and which don't, then you may be able to modify your script to check and display the prepaid tax message only when it's appropriate... perhaps if custom clients fields are too general, you could use product custom fields instead.

 

however, if you are manually preparing all your invoices, perhaps a simpler solution would be to "Notes" tab in invoices... this is just a text box where you can some additional text to your invoice - perhaps in your case, you can use it to add "Prepaid tax x euros" to those invoices that this applies to ?

 

by default, Notes are shown towards the bottom of the invoice pdf - but if you need to, it should be simple to move them to somewhere else on the invoice.

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