Browse Source

Merge pull request #17577 from OGPayet/feature/addThirdpartyCustomerCodeToEmailingSubstitutionArray

add thirdparty customer code to substitutionarray
Laurent Destailleur 3 years ago
parent
commit
8e2f76ca66
2 changed files with 11 additions and 0 deletions
  1. 10 0
      htdocs/comm/mailing/card.php
  2. 1 0
      htdocs/core/class/html.formmail.class.php

+ 10 - 0
htdocs/comm/mailing/card.php

@@ -171,6 +171,7 @@ if (empty($reshook)) {
 						dol_print_error($db);
 					}
 
+					$thirdpartystatic = new Societe($db);
 					// Loop on each email and send it
 					$i = 0;
 
@@ -200,6 +201,15 @@ if (empty($reshook)) {
 
 						// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
 						$substitutionarray['__ID__'] = $obj->source_id;
+						if ($obj->source_type == "thirdparty") {
+							$result = $thirdpartystatic->fetch($obj->source_id);
+
+							if ($result > 0) {
+								$substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client;
+							} else {
+								$substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = '';
+							}
+						}
 						$substitutionarray['__EMAIL__'] = $obj->email;
 						$substitutionarray['__LASTNAME__'] = $obj->lastname;
 						$substitutionarray['__FIRSTNAME__'] = $obj->firstname;

+ 1 - 0
htdocs/core/class/html.formmail.class.php

@@ -1569,6 +1569,7 @@ class FormMail extends Form
 
 			// For mass emailing, we have different keys
 			$tmparray['__ID__'] = 'IdRecord';
+			$tmparray['__THIRDPARTY_CUSTOMER_CODE__'] = 'CustomerCode';
 			$tmparray['__EMAIL__'] = 'EMailRecipient';
 			$tmparray['__LASTNAME__'] = 'Lastname';
 			$tmparray['__FIRSTNAME__'] = 'Firstname';