diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 12ea7aa7b082d667fa3745f6e3ffe83dcc5e2f0f..542f53c24b7958ef1bb13073672474c94e83df4a 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -270,7 +270,11 @@ class doc_generic_invoice_odt extends ModelePDFFactures { // On peut utiliser le nom de la societe du contact if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else $socobject = $object->client; + else { + $socobject = $object->client; + // if we have a BILLING contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } } else { @@ -344,8 +348,12 @@ class doc_generic_invoice_odt extends ModelePDFFactures $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_propal=is_object($propal_object)?$this->get_substitutionarray_object($propal_object,$outputlangs,'propal'):array(); $array_other=$this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in invoice as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact) + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); - $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other); + $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 80ec0ba6fe0a47e08ef5f75b6033e476f2598065..d6773eb2c80aa567462c4159bba6e869e6722e80 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -288,9 +288,9 @@ class doc_generic_proposal_odt extends ModelePDFPropales dol_mkdir($conf->propal->dir_temp); - // If BILLING contact defined on invoice, we use it + // If CUSTOMER contact defined on proposal, we use it $usecontact=false; - $arrayidcontact=$object->getIdContact('external','BILLING'); + $arrayidcontact=$object->getIdContact('external','CUSTOMER'); if (count($arrayidcontact) > 0) { $usecontact=true; @@ -302,13 +302,16 @@ class doc_generic_proposal_odt extends ModelePDFPropales { // On peut utiliser le nom de la societe du contact if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else $socobject = $object->client; + else { + $socobject = $object->client; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } } else { $socobject=$object->client; } - // Make substitution $substitutionarray=array( '__FROM_NAME__' => $this->emetteur->name, @@ -369,8 +372,12 @@ class doc_generic_proposal_odt extends ModelePDFPropales $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in proposal as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact) + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); - $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other); + $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);