Merge pull request #7577 from OPEN-DSI/fix_0001

Fix carriage return when get full address formated for output on documents
This commit is contained in:
Laurent Destailleur 2017-10-09 10:48:26 +02:00 committed by GitHub
commit 245c048b40

View File

@ -431,16 +431,16 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs,1)); $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs,1));
if (!empty($targetcontact->address)) { if (!empty($targetcontact->address)) {
$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcontact))."\n"; $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcontact));
}else { }else {
$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n"; $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany));
} }
// Country // Country
if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) { if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
$stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code))."\n"; $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code));
} }
else if (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) { else if (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
$stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n"; $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code));
} }
if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/',$mode)) if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/',$mode))
@ -472,9 +472,9 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
} }
else else
{ {
$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n"; $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany));
// Country // Country
if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n"; if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code));
if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/',$mode)) if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/',$mode))
{ {
@ -507,7 +507,7 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
// Intra VAT // Intra VAT
if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS))
{ {
if ($targetcompany->tva_intra) $stringaddress.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); if ($targetcompany->tva_intra) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
} }
// Professionnal Ids // Professionnal Ids
@ -515,37 +515,37 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
{ {
$tmp=$outputlangs->transcountrynoentities("ProfId1",$targetcompany->country_code); $tmp=$outputlangs->transcountrynoentities("ProfId1",$targetcompany->country_code);
if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
$stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1); $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1);
} }
if (! empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && ! empty($targetcompany->idprof2)) if (! empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && ! empty($targetcompany->idprof2))
{ {
$tmp=$outputlangs->transcountrynoentities("ProfId2",$targetcompany->country_code); $tmp=$outputlangs->transcountrynoentities("ProfId2",$targetcompany->country_code);
if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
$stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2); $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2);
} }
if (! empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && ! empty($targetcompany->idprof3)) if (! empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && ! empty($targetcompany->idprof3))
{ {
$tmp=$outputlangs->transcountrynoentities("ProfId3",$targetcompany->country_code); $tmp=$outputlangs->transcountrynoentities("ProfId3",$targetcompany->country_code);
if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
$stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3); $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3);
} }
if (! empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && ! empty($targetcompany->idprof4)) if (! empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && ! empty($targetcompany->idprof4))
{ {
$tmp=$outputlangs->transcountrynoentities("ProfId4",$targetcompany->country_code); $tmp=$outputlangs->transcountrynoentities("ProfId4",$targetcompany->country_code);
if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
$stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4); $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4);
} }
if (! empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && ! empty($targetcompany->idprof5)) if (! empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && ! empty($targetcompany->idprof5))
{ {
$tmp=$outputlangs->transcountrynoentities("ProfId5",$targetcompany->country_code); $tmp=$outputlangs->transcountrynoentities("ProfId5",$targetcompany->country_code);
if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
$stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5); $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5);
} }
if (! empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && ! empty($targetcompany->idprof6)) if (! empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && ! empty($targetcompany->idprof6))
{ {
$tmp=$outputlangs->transcountrynoentities("ProfId6",$targetcompany->country_code); $tmp=$outputlangs->transcountrynoentities("ProfId6",$targetcompany->country_code);
if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
$stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6); $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6);
} }
// Public note // Public note
@ -553,11 +553,11 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
{ {
if ($mode == 'source' && ! empty($sourcecompany->note_public)) if ($mode == 'source' && ! empty($sourcecompany->note_public))
{ {
$stringaddress.="\n".dol_string_nohtmltag($sourcecompany->note_public); $stringaddress.=($stringaddress ? "\n" : '' ).dol_string_nohtmltag($sourcecompany->note_public);
} }
if (($mode == 'target' || preg_match('/targetwithdetails/',$mode)) && ! empty($targetcompany->note_public)) if (($mode == 'target' || preg_match('/targetwithdetails/',$mode)) && ! empty($targetcompany->note_public))
{ {
$stringaddress.="\n".dol_string_nohtmltag($targetcompany->note_public); $stringaddress.=($stringaddress ? "\n" : '' ).dol_string_nohtmltag($targetcompany->note_public);
} }
} }
} }