Display Country on PDF

Hi,

I managed to restyle the PDF as I need it. What I can’t get to work right now is to get the country field under the customer adres and de shortcode of the country in front of zip (GERMANY)l.

F.e. :

Name
adres
(shortcode of country)ZIP CITY
COUNTRY

Hope somebody can help me.

Gr.

Dirk

Hi,

In Dolibarr if Source(From) country and Target(To) country is same then it will not display Country in address. If they are Diffrerent for example From->India , To->Germany then it will Display the country name. If you want to overcome from this then set $withCountry = 1 in pdf.lib.php. And for displaying shortcode of the country in front of zip , you may need to modify functions.lib.php file (dol_format_address function)

Hi.

I already set the withCountry to 1. Nothing changes.

In which file did you set it to 1 ?

in pdf.lib.php

	if ($mode == 'source')
	{
		$withCountry = 1;
		if (!empty($sourcecompany-\>country_code) && ($targetcompany-\>country_code != $sourcecompany-\>country_code)) $withCountry = 1;

		$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs-\>convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n";

You have added in Source address(i.e, From address). If you want to display Customer country then you need to add $withCountry = 1 in

if ($mode == ‘target’ || preg_match(’/targetwithdetails/’,$mode))
{

}
and you need to add $withCountry as second parameter to dol_format_address function contained inside the if block

And other easy method is to add $withCountry = 1 in dol_format_address function in functions.lib.php
This will display Country name in all Address

THx for the reply.

Hi mate,

Now I have the following Problem :

ES-35660 Corralejo / Fuerteventura
Spanien
Spanien

the Country name is shown double, also I was not able to manage the Country code ES to show automatically.

Maybe you can help me once more ?