From 170a668b2bdf15f232c60a1d3c3f6a01a1236e32 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Fri, 13 Jul 2018 11:09:56 +0200 Subject: [PATCH 1/3] FIX : Set contactCivName substitution key --- htdocs/core/tpl/card_presend.tpl.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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; From de8fd3d12c75ed44889c5656fd00a4b365de6691 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Mon, 16 Jul 2018 09:33:14 +0200 Subject: [PATCH 2/3] 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; + } } } From 3c5998e697f214224da97fb9b2a63d883c4d303c Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Mon, 16 Jul 2018 11:16:55 +0200 Subject: [PATCH 3/3] FIX : Refactoring --- htdocs/core/tpl/card_presend.tpl.php | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 63b1cbab28d..34f46a7ab92 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -177,24 +177,8 @@ if ($action == 'presend') $contactstatic = new Contact($db); foreach ($contactarr as $contact) { - 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; - } + $contactstatic->fetch($contact['id']); + $substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($langs, 1); } }