Merge pull request #11137 from OPEN-DSI/fix-card-presend-shipment

Fix contact address substitution before sending by mail in shipment card
This commit is contained in:
Laurent Destailleur 2019-05-08 02:06:36 +02:00 committed by GitHub
commit eb9b9e44d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -210,10 +210,55 @@ if ($action == 'presend')
);
complete_substitutions_array($substitutionarray, $outputlangs, $object, $parameters);
// Find the good contact adress
// Find the good contact address
$tmpobject = $object;
if (($object->element == 'shipping'|| $object->element == 'reception')) {
$origin = $object->origin;
$origin_id = $object->origin_id;
if (!empty($origin) && !empty($origin_id)) {
$element = $subelement = $origin;
if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
$element = $regs[1];
$subelement = $regs[2];
}
// For compatibility
if ($element == 'order') {
$element = $subelement = 'commande';
}
if ($element == 'propal') {
$element = 'comm/propal';
$subelement = 'propal';
}
if ($element == 'contract') {
$element = $subelement = 'contrat';
}
if ($element == 'inter') {
$element = $subelement = 'ficheinter';
}
if ($element == 'shipping') {
$element = $subelement = 'expedition';
}
if ($element == 'order_supplier') {
$element = 'fourn';
$subelement = 'fournisseur.commande';
}
if ($element == 'project') {
$element = 'projet';
}
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
$classname = ucfirst($origin);
$objectsrc = new $classname($db);
$objectsrc->fetch($origin_id);
$tmpobject = $objectsrc;
}
}
$custcontact = '';
$contactarr = array();
$contactarr = $object->liste_contact(- 1, 'external');
$contactarr = $tmpobject->liste_contact(- 1, 'external');
if (is_array($contactarr) && count($contactarr) > 0) {
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';