diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 750f1a7ab39..b5e1fc80a1d 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -294,10 +294,11 @@ class doc_generic_bom_odt extends ModelePDFBom if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $socobject = $object->contact; + } else { $socobject = $object->thirdparty; - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + // if we have a CUSTOMER contact and we dont use as recipient we store the contact object for later use $contactobject = $object->contact; } } else { diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index eb2c8121397..3165760b541 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -305,11 +305,11 @@ class doc_generic_order_odt extends ModelePDFCommandes $contactobject = null; if (!empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $socobject = $object->contact; + } else { $socobject = $object->thirdparty; - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + // if we have a CUSTOMER contact and we dont use as recipient we store the contact object for later use $contactobject = $object->contact; } } else { diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 3536daab5eb..5a0bbc30327 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1446,9 +1446,8 @@ class pdf_einstein extends ModelePDFCommandes $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // On peut utiliser le nom de la societe du contact - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 7fda31f4c71..97354c5c266 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1628,8 +1628,7 @@ class pdf_eratosthene extends ModelePDFCommandes } //Recipient name - // On peut utiliser le nom de la societe du contact - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 7a0b1f91109..edad675857f 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -291,12 +291,11 @@ class doc_generic_contract_odt extends ModelePDFContract // Recipient name $contactobject = null; if (!empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $socobject = $object->contact; } else { $socobject = $object->thirdparty; - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + // if we have a CUSTOMER contact and we dont use as recipient we store the contact object for later use $contactobject = $object->contact; } } else { diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 08fefaf5634..e28cd62efae 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -711,9 +711,8 @@ class pdf_strato extends ModelePDFContract $this->recipient = $object->thirdparty; - //Recipient name - // You can use the name of the contact company - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index e6da731fb21..d6376e6cd17 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -860,9 +860,8 @@ class pdf_storm extends ModelePDFDeliveryOrder $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // On peut utiliser le nom de la societe du contact - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index 8b7c899af91..3b8baa107ad 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -850,9 +850,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // On peut utiliser le nom de la societe du contact - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 039ef128cd7..254bb5bf377 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -304,12 +304,11 @@ class doc_generic_shipment_odt extends ModelePdfExpedition // Recipient name $contactobject = null; if (!empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $socobject = $object->contact; - else { + } else { $socobject = $object->thirdparty; - // if we have a SHIIPPING contact and we dont use it as recipient we store the contact object for later use + // if we have a SHIPPING contact and we dont use as recipient we store the contact object for later use $contactobject = $object->contact; } } else { diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index a48e28ecef6..5cdeaa693a7 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -1020,9 +1020,8 @@ class pdf_espadon extends ModelePdfExpedition $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // You can use the name of the contact company - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index be163ea4c18..f530121ec08 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -678,8 +678,7 @@ class pdf_merou extends ModelePdfExpedition } // Recipient name - // You can use the name of the contact company - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 8b0dd134d65..a43c6aba352 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -1054,9 +1054,8 @@ class pdf_rouget extends ModelePdfExpedition $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // On peut utiliser le nom de la societe du contact - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; 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 1d4b65fdb32..f2f4ee31823 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 @@ -305,10 +305,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures // Recipient name $contactobject = null; if (!empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $socobject = $object->contact; - else { + } else { $socobject = $object->thirdparty; // if we have a BILLING contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 32c58f21eac..f1c90305bef 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1842,9 +1842,8 @@ class pdf_crabe extends ModelePDFFactures $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // On peut utiliser le nom de la societe du contact - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 66035df58db..4087e3db098 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2108,9 +2108,8 @@ class pdf_sponge extends ModelePDFFactures $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // On peut utiliser le nom de la societe du contact - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index c79b2ac4137..622cd0b2250 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -665,9 +665,8 @@ class pdf_soleil extends ModelePDFFicheinter $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // On peut utiliser le nom de la societe du contact - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php index 6d2f2772610..be91acd7a3f 100644 --- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php +++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php @@ -280,8 +280,7 @@ class doc_generic_member_odt extends ModelePDFMember // Recipient name if (!empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $socobject = $object->contact; } else { $socobject = $object->thirdparty; diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index 84f225dfb6e..eeaeb2c8e54 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -298,11 +298,10 @@ class doc_generic_mo_odt extends ModelePDFMo // Recipient name $contactobject = null; - if (!empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { + if (!empty($usecontact)) { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $socobject = $object->contact; + } else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index d017a559b37..ef5e97997f9 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -315,10 +315,8 @@ class doc_generic_product_odt extends ModelePDFProduct // Recipient name $contactobject = null; - if (!empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + if (!empty($usecontact)) { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $socobject = $object->contact; } else { $socobject = $object->thirdparty; 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 59df720269b..b27e94b46b7 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 @@ -334,9 +334,9 @@ class doc_generic_proposal_odt extends ModelePDFPropales $contactobject = null; if (!empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $socobject = $object->contact; + } else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index a5a6b850f7f..a889dec7815 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1618,9 +1618,8 @@ class pdf_azur extends ModelePDFPropales $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // On peut utiliser le nom de la societe du contact - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 1baf9712cdb..119932949b2 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1729,9 +1729,8 @@ class pdf_cyan extends ModelePDFPropales $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // On peut utiliser le nom de la societe du contact - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 45bfabe4b62..1105a5f6d4c 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -294,11 +294,14 @@ class doc_generic_reception_odt extends ModelePdfReception } // Recipient name - if (!empty($usecontact)) - { - // 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->thirdparty; + if (!empty($usecontact)) { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $socobject = $object->contact; + } else { + $socobject = $object->thirdparty; + // 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 { $socobject = $object->thirdparty; } diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 446b03daf0a..8043f9f9ba6 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -944,9 +944,8 @@ class pdf_squille extends ModelePdfReception $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // On peut utiliser le nom de la societe du contact - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index 89a5ea9d784..1b3053aaaaf 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -306,8 +306,7 @@ class doc_generic_stock_odt extends ModelePDFStock $contactobject = null; if (!empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $socobject = $object->contact; } else { $socobject = $object->thirdparty; diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 5e2e4380a0b..7a3ecf88e19 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -1209,9 +1209,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // We can use the name of the contact's company - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $mysoc; diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index 37f773783cc..18c3a9a3574 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -295,9 +295,9 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders $contactobject = null; if (!empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $socobject = $object->contact; + } else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 0d66fe5b83b..3a4bc56f64a 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -1371,9 +1371,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // On peut utiliser le nom de la societe du contact - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index bc91d690f36..c8edef0679c 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -1283,9 +1283,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // On peut utiliser le nom de la societe du contact - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index b5efe6801ff..918f5fd9215 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -330,15 +330,12 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal // Recipient name $contactobject = null; - if (!empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) - { + if (!empty($usecontact)) { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $socobject = $object->contact; } else { $socobject = $object->thirdparty; - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + // 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 { diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 3aafb09aa86..8c82198999a 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -1417,14 +1417,17 @@ class pdf_aurore extends ModelePDFSupplierProposal // Recipient name if (!empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; - else $socname = $object->thirdparty->name; - $carac_client_name = $outputlangs->convToOutputCharset($socname); + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $socname = $object->contact->socname; + } else { + $socname = $object->thirdparty->name; + } } else { - $carac_client_name = $outputlangs->convToOutputCharset($object->thirdparty->name); + $socname = $object->thirdparty->name; } + $carac_client_name = pdfBuildThirdpartyName($socname, $outputlangs); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index 771231e6041..2a326282fa0 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -323,9 +323,9 @@ class doc_generic_user_odt extends ModelePDFUser // Recipient name if (!empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $socobject = $object->contact; + } else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 3cbce44511f..6fcc6160a97 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -314,9 +314,9 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup // Recipient name if (!empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $socobject = $object->contact; + } else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index 80b4f4ecb5a..d6cb191a405 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -299,9 +299,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $contactobject = null; if (!empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $socobject = $object->contact; + } else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index e8e39ec2adb..fbab4d53b0f 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -1091,7 +1091,7 @@ class pdf_standard_myobject extends ModelePDFMyObject } // Recipient name - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index 6e9788c2e9f..be36b96682c 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -299,9 +299,9 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi $contactobject = null; if (!empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $socobject = $object->contact; + } else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index af62344296b..cad6888f7c5 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -1002,7 +1002,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio } // Recipient name - /*if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + /*if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty;