Invoice Layout Changes to PHP

Good Morning Everyone

I am starting to use dolibarr for the first time and its great, I want to make changes to the invoice layout but cannot find anywhere how to do it, I have looked at the Dolibarr wiki but it doesn’t really make sense to me.
I dont want to use the ODT format because I would like to send the invoice directly from Dolibar as PDF not ODT.

I would like to make it look like my Old Microsoft Accounts Invoice Layout.

I think I have found the right file to change ? pdf_crabe.modules.php ?

- I would like to Make the Logo bigger on the top left of the invoice
- Move My Address from the top left corner to the bottom of the invoice.
- I would like to add the uk £ sign to the amounts figures.
- I would like to add a box around the total at the bottom

Thank you all for your Help it is very much apreciated

Thanks
Rob

There’s instructions here http://wiki.dolibarr.org/index.php/Create_a_PDF_document_template.

Frankly, if you are not programming savvy, this method is hugely complicated. I myself find that using odt and convert PDF (although multiple steps), beats messing with the codes.

Thanks for your message. I have been getting to grips with the php and it isn’t too bad to make changes.

For anyone else that wants to change your invoice layout and still get a pdf file the file you need to change is

\core\modules\facture\doc\pdf_crabe.modules.php

In here the invoice file is created and if it is a simple move around you can then change the X & Y co-ordinates of the layout of the file, I wanted to make my logo larger too which I have also completed.

// Logo
$logo=$conf->mycompany->dir_output.’/logos/’.$this->emetteur->logo;
if ($this->emetteur->logo)
{
if (is_readable($logo))
{
$height=pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, 50); // width=0 (auto) // CCS Change for Logo size on invoice to make the size of logo larger change the last number to a higher number and then this will change in the layout.

Also I wanted the Invoice Header to be larger.
$pdf->SetFont(’’,‘B’, $default_font_size + 18); // This Makes the Invoice Text Larger

you need to be careful because of the changes that you make might have implecations as you go further down the screen.

I have made the text to change bold so you can search through the file and find your parts to change

I am now trying to put a Currency Symbol in the Numbers instead of just text.
I have found a function that already exists but I’m not sure How to use it.
If anyone can help I would be very grateful.

I tried to add a £ to the Multicell Function but I cant get it to work.

Multicell is where you can make changes to the Entry’s on the Layout.

I know this isn’t 100% the correct way Dolibarr wants you to change the layout they suggest that you make another template and then make your changes But I wasn’t sure How to do this.
Keep in Mind that if you upgrade then the files would be overwritten and they changes might not work.

But this is a good quick way to change Dolibarr without too much issues.

Thanks Rob

		}

Hi,
I know this question is one year old but it might be useful for someone.
This hack is for Dolibarr 3.6.1.
In order to add currency symbol to you PDF invoice you’ll need to modify your Invoice PDF template which by default is “Crabe”

But I would suggest to create a copy of this file and rename it to something like

then edit it and rename

class pdf_crabe
to

class pdf_mystyle
and replace

$this->name = "crabe";
with

$this->name = "mystyle";
(And don’t forget to activate your “Invoice documents model” in /admin/facture.php when you’re done)

To add currency symbol you need to modify all calls to function price() and add extra parameters to it which are

1, -1, -1, $conf->currency
So for example this line

$pdf->MultiCell(20, 3, price($obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
should be changed to

$pdf->MultiCell(20, 3, price($obj->amount_ttc, 0, $outputlangs, 1, -1, -1, $conf->currency), 0, 'L', 0);
You can do it manually by finding " price(" function which is boring or you can use regular expression replacement using this pattern

(price\(.*outputlangs)\)
and replacement

$1, 1, -1, -1, \$conf->currency)
And everything will be updated in one go.

If you what your currency symbol to be added before the amount like for EUR (€), GBP (£) and etc you will need to edit this file

and add you currency ISO code to this array

$listofcurrenciesbefore=array('USD');
so it will look like

$listofcurrenciesbefore=array('USD','GBP','EUR');
You can add here as many currencies as you need.

Which is a really dirty hack and this should have been implemented in the configuration.

2 Likes

If you just want the unicode symbol not the full cuurency name, you can use:

[code]
$langs->getCurrencySymbol($conf->currency)[/code

I am using v11.03 & have checked the code mentioned above as I too, would like to add the Australian currency symbol ($) prefixing the totals on the invoice. The array already contains ÁUD’.
I see on screen, in the expense module that the $ is on screen, but does not appear on any pdf copies of invoice, expenses etc.
Is there any other instructions as to how I can get the $ prefixed on pdf’s - without purchasing ultimatepdf?

1 Like