Skip to content

Commit

Permalink
Fix: Show sender Country on PDF docs
Browse files Browse the repository at this point in the history
Show sender Country on PDF docs when sender Country != receiver Country
  • Loading branch information
fappels committed Nov 25, 2014
1 parent 1dbb19e commit 18406fc
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -14,6 +14,7 @@ English Dolibarr ChangeLog
- Fix: Chars - is no more allowed into value for code for extra fields.
- Fix: [ bug #1622 ] Requesting holiday than spans across two years cause high CPU usage by Apache
- Fix: [ bug #1595 ] Selected boolean extrafield in intervention creation page, does not save state
- Fix: Show sender Country on PDF docs when sender Country <> receiver Country

***** ChangeLog for 3.6.1 compared to 3.6.* *****
For users:
Expand Down
9 changes: 5 additions & 4 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -719,11 +719,12 @@ function dol_bc($var,$moreclass='')
* @param Object $object A company or contact object
* @param int $withcountry 1=Add country into address string
* @param string $sep Separator to use to build string
* @param Tranlsate $outputlangs Object lang that contains language for text translation.
* @return string Formated string
*/
function dol_format_address($object,$withcountry=0,$sep="\n")
function dol_format_address($object,$withcountry=0,$sep="\n",$outputlangs='')
{
global $conf;
global $conf,$langs;

$ret='';
$countriesusingstate=array('AU','US','IN','GB','ES','UK','TR');
Expand Down Expand Up @@ -768,8 +769,8 @@ function dol_format_address($object,$withcountry=0,$sep="\n")
$ret.=", ".$object->state;
}
}

if ($withcountry) $ret.=($object->country?$sep.$object->country:'');
if (! is_object($outputlangs)) $outputlangs=$langs;
if ($withcountry) $ret.=($object->country_code?$sep.$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)):'');

return $ret;
}
Expand Down
5 changes: 4 additions & 1 deletion htdocs/core/lib/pdf.lib.php
Expand Up @@ -309,7 +309,10 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target

if ($mode == 'source')
{
$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($sourcecompany))."\n";
$withCountry = 0;
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";

if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS))
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/commande/doc/pdf_einstein.modules.php
Expand Up @@ -1177,7 +1177,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
if ($showaddress)
{
// Sender properties
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);

// Show sender
$posy=42;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/commande/doc/pdf_proforma.modules.php
Expand Up @@ -1134,7 +1134,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
if ($showaddress)
{
// Sender properties
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);

// Show sender
$posy=42;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/contract/doc/pdf_strato.modules.php
Expand Up @@ -520,7 +520,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
}

$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client);

// Show sender
$posy=42;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/expedition/doc/pdf_merou.modules.php
Expand Up @@ -516,7 +516,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
$pdf->SetTextColor(0,0,0);

// Sender properties
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);

$pdf->SetFont('','', $default_font_size - 3);
$pdf->SetXY($blSocX,$blSocY+4);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
Expand Up @@ -564,7 +564,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
}

$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client);

// Show sender
$posx=$this->marge_gauche;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/facture/doc/pdf_crabe.modules.php
Expand Up @@ -1363,7 +1363,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
if ($showaddress)
{
// Sender properties
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);

// Show sender
$posy=42;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
Expand Up @@ -505,7 +505,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
}

$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client);

// Show sender
$posy=42;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
Expand Up @@ -749,7 +749,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
if ($showaddress)
{
// Sender properties
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);

// Show sender
$posy=42;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/propale/doc/pdf_azur.modules.php
Expand Up @@ -1269,7 +1269,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
}

$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client);

// Show sender
$posy=42;
Expand Down
Expand Up @@ -961,7 +961,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
if ($showaddress)
{
// Sender properties
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);

// Show sender
$posy=42;
Expand Down
Expand Up @@ -1005,7 +1005,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
if ($showaddress)
{
// Sender properties
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);

// Show sender
$posy=42;
Expand Down

0 comments on commit 18406fc

Please sign in to comment.