|
@@ -527,102 +527,100 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t
|
|
|
|
|
|
if ($mode == 'target' || preg_match('/targetwithdetails/', $mode)) {
|
|
|
if ($usecontact) {
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1));
|
|
|
+ if (is_object($targetcontact)) {
|
|
|
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1));
|
|
|
|
|
|
- if (!empty($targetcontact->address)) {
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcontact));
|
|
|
- } else {
|
|
|
- $companytouseforaddress = $targetcompany;
|
|
|
+ if (!empty($targetcontact->address)) {
|
|
|
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcontact));
|
|
|
+ } else {
|
|
|
+ $companytouseforaddress = $targetcompany;
|
|
|
|
|
|
- // Contact on a thirdparty that is a different thirdparty than the thirdparty of object
|
|
|
- if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) {
|
|
|
- $targetcontact->fetch_thirdparty();
|
|
|
- $companytouseforaddress = $targetcontact->thirdparty;
|
|
|
- }
|
|
|
+ // Contact on a thirdparty that is a different thirdparty than the thirdparty of object
|
|
|
+ if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) {
|
|
|
+ $targetcontact->fetch_thirdparty();
|
|
|
+ $companytouseforaddress = $targetcontact->thirdparty;
|
|
|
+ }
|
|
|
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress));
|
|
|
- }
|
|
|
- // Country
|
|
|
- if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code));
|
|
|
- } elseif (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code));
|
|
|
- }
|
|
|
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress));
|
|
|
+ }
|
|
|
+ // Country
|
|
|
+ if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
|
|
|
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code));
|
|
|
+ } elseif (empty($targetcontact->country_code) && !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)) {
|
|
|
- // Phone
|
|
|
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) {
|
|
|
- if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) {
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
|
|
|
- }
|
|
|
- if (!empty($targetcontact->phone_pro)) {
|
|
|
- $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
|
|
|
- }
|
|
|
- if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) {
|
|
|
- $stringaddress .= " / ";
|
|
|
- }
|
|
|
- if (!empty($targetcontact->phone_mobile)) {
|
|
|
- $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
|
|
|
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) {
|
|
|
+ // Phone
|
|
|
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) {
|
|
|
+ if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) {
|
|
|
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
|
|
|
+ }
|
|
|
+ if (!empty($targetcontact->phone_pro)) {
|
|
|
+ $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
|
|
|
+ }
|
|
|
+ if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) {
|
|
|
+ $stringaddress .= " / ";
|
|
|
+ }
|
|
|
+ if (!empty($targetcontact->phone_mobile)) {
|
|
|
+ $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- // Fax
|
|
|
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) {
|
|
|
- if ($targetcontact->fax) {
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax);
|
|
|
+ // Fax
|
|
|
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) {
|
|
|
+ if ($targetcontact->fax) {
|
|
|
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- // EMail
|
|
|
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) {
|
|
|
- if ($targetcontact->email) {
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email);
|
|
|
+ // EMail
|
|
|
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) {
|
|
|
+ if ($targetcontact->email) {
|
|
|
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- // Web
|
|
|
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) {
|
|
|
- if ($targetcontact->url) {
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url);
|
|
|
+ // Web
|
|
|
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) {
|
|
|
+ if ($targetcontact->url) {
|
|
|
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcompany));
|
|
|
- // Country
|
|
|
- if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) {
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code));
|
|
|
- }
|
|
|
+ if (is_object($targetcompany)) {
|
|
|
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcompany));
|
|
|
+ // Country
|
|
|
+ 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)) {
|
|
|
- // Phone
|
|
|
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) {
|
|
|
- if (!empty($targetcompany->phone) || !empty($targetcompany->phone_mobile)) {
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
|
|
|
- }
|
|
|
- if (!empty($targetcompany->phone)) {
|
|
|
- $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
|
|
|
- }
|
|
|
- if (!empty($targetcompany->phone) && !empty($targetcompany->phone_mobile)) {
|
|
|
- $stringaddress .= " / ";
|
|
|
- }
|
|
|
- if (!empty($targetcompany->phone_mobile)) {
|
|
|
- $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
|
|
|
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) {
|
|
|
+ // Phone
|
|
|
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) {
|
|
|
+ if (!empty($targetcompany->phone)) {
|
|
|
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
|
|
|
+ }
|
|
|
+ if (!empty($targetcompany->phone)) {
|
|
|
+ $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- // Fax
|
|
|
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) {
|
|
|
- if ($targetcompany->fax) {
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax);
|
|
|
+ // Fax
|
|
|
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) {
|
|
|
+ if ($targetcompany->fax) {
|
|
|
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- // EMail
|
|
|
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) {
|
|
|
- if ($targetcompany->email) {
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email);
|
|
|
+ // EMail
|
|
|
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) {
|
|
|
+ if ($targetcompany->email) {
|
|
|
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- // Web
|
|
|
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) {
|
|
|
- if ($targetcompany->url) {
|
|
|
- $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url);
|
|
|
+ // Web
|
|
|
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) {
|
|
|
+ if ($targetcompany->url) {
|
|
|
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|