diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 43cacab0e1c..b5d342d3e0a 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -167,6 +167,27 @@ if ($action == 'presend') ); complete_substitutions_array($substitutionarray, $outputlangs, $object, $parameters); + // Find the good contact adress + $custcontact = ''; + $contactarr = array(); + $contactarr = $object->liste_contact(- 1, 'external'); + + if (is_array($contactarr) && count($contactarr) > 0) { + foreach ($contactarr as $contact) { + if (in_array($contact['code'], array('BILLING'))) { + require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; + + $contactstatic = new Contact($db); + $contactstatic->fetch($contact['id']); + $custcontact = $contactstatic->getFullName($langs, 1); + } + } + + if (! empty($custcontact)) { + $substitutionarray['__CONTACTCIVNAME__'] = $custcontact; + } + } + // Tableau des substitutions $formmail->substit = $substitutionarray;