From de8fd3d12c75ed44889c5656fd00a4b365de6691 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Mon, 16 Jul 2018 09:33:14 +0200 Subject: [PATCH] NEW : Contact substitutions keys --- htdocs/core/tpl/card_presend.tpl.php | 32 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index b5d342d3e0a..63b1cbab28d 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -173,18 +173,28 @@ if ($action == 'presend') $contactarr = $object->liste_contact(- 1, 'external'); if (is_array($contactarr) && count($contactarr) > 0) { + require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; + $contactstatic = new Contact($db); + 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; + switch($contact['code']) { + case 'BILLING': + $contactstatic->fetch($contact['id']); + $substitutionarray['__CONTACT_NAME_BILLING__'] = $contactstatic->getFullName($langs, 1); + break; + case 'CUSTOMER': + $contactstatic->fetch($contact['id']); + $substitutionarray['__CONTACT_NAME_CUSTOMER__'] = $contactstatic->getFullName($langs, 1); + break; + case 'SHIPPING': + $contactstatic->fetch($contact['id']); + $substitutionarray['__CONTACT_NAME_SHIPPING__'] = $contactstatic->getFullName($langs, 1); + break; + case 'SERVICE': + $contactstatic->fetch($contact['id']); + $substitutionarray['__CONTACT_NAME_SERVICE__'] = $contactstatic->getFullName($langs, 1); + break; + } } }