How to modify dolibarr invoice

Recently had to make amendments in dolibarr CRM Invoice design & text.

 

At first galance it seems that it is going to be too hard for me to manage this.

 

After some research on internet I came to know that there are 2 ways to change Invoice.

 

First option - Changing Odt file.
Second option - Changing the php code directly.

 

Being a PHP Professional I have chosen php way.  

 

I have learnt a lot of things that can be modified easyly so I thought to inform others who are willing to change the dolibarr invoice too. You may follow below steps to edit invoice.

 

All you need to make changes in 1 php file by going to:

/public_html/db/core/modules/facture/doc/pdf_crabe.modules.php

--------------------------------------------------------------------------------

 

 

How to change date format in dolibarr invoice

 

First change that I made is changed the Date format of Invoice from MM/DD/YYYY to DD/MM/YYYY

 

To do so I have defined my own function

 

function _changeDateFormat($str)
{
    $str=explode("/", $str);
    $str2=$str[1]."/".$str[0]."/".$str[2];
    return $str2;
}

 

Then I have replaced below line & added my defined function with date output:

 

$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateInvoice")." : " . $this->_changeDateFormat(dol_print_date($object->date,"day",false,$outputlangs)), '', 'R');


----------------------------------------------------------------------------------

 

 

How to change a particular text in dolibarr invoice?

 

Anything written between transnoentities "$outputlangs->transnoentities" is the output that is going to print.  
You can identify the correct text & replace that.


----------------------------------------------------------------------------------

 

 

How to insert new text in dolibarr invoice?

 

You can use below method to insert any text.

 

$pdf->MultiCell($widthrecbox, 5, "Your Text Here",0,'L');

----------------------------------------------------------------------------------

 

 

How to set font size in dolibarr invoice?

 

To change the font size of text in dolibarr invoice you can use setFont methode

 

$pdf->SetFont('','', $default_font_size - 1);

 

You can plus & minus the number above as per your desired size.

---------------------------------------------------------------

 

 

How to draw rectangle in dolibarr Invoice?

 

You can also draw rectange in dolibarr invoice using below.

 

$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);

 

First parameter is x cordinates
Second parameter is y cordinates
Third parameter is rectange width
Fourth parameter is rectange height

---------------------------------------------------------------

 

How to set postion in dolibarr invoice?

 

$pdf->SetXY($posx+2,$posy-5);

---------------------------------------------------------------

 

 

How to fill color in particular area of dolibarr invoice?

 

$pdf->SetFillColor(224,224,224);

 

Value is in RGB format.

---------------------------------------------------------------

 

 

How you can set text color in dolibarr invoice?

 

$pdf->SetTextColor(0,0,60);

 

Value is in RGB format.

---------------------------------------------------------------

 

 

Comments

Thank your for this code to customize invoice. How I can change the size of colums in the invoice Thank you in advance
sebti
You can create the Rectangular & set its height & width. Example given above.
Ram
Thank you Ram,what I need is to change width of colonne priceU.HT and colonne of description.Thank you in advance
sebti
Please share your views with us
Check if you want to display your email-id.
Enter the sum of digits
1+3 =