set new outside the loop, add fetch result check
This commit is contained in:
parent
ff178667a3
commit
4ce81ee535
@ -171,6 +171,7 @@ if (empty($reshook))
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$thirdpartystatic = new Societe($db);
|
||||
// Loop on each email and send it
|
||||
$i = 0;
|
||||
|
||||
@ -202,11 +203,12 @@ 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") {
|
||||
$thirdpartystatic = new Societe($db);
|
||||
$thirdpartystatic->fetch($obj->source_id);
|
||||
$result = $thirdpartystatic->fetch($obj->source_id);
|
||||
|
||||
$substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client;
|
||||
$substitutionarray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = substr($thirdpartystatic->code_client, 1);
|
||||
if ($result > 0) {
|
||||
$substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client;
|
||||
$substitutionarray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = substr($thirdpartystatic->code_client, 1);
|
||||
}
|
||||
}
|
||||
$substitutionarray['__EMAIL__'] = $obj->email;
|
||||
$substitutionarray['__LASTNAME__'] = $obj->lastname;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user