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:
commit
eb9b9e44d8
@ -210,10 +210,55 @@ if ($action == 'presend')
|
|||||||
);
|
);
|
||||||
complete_substitutions_array($substitutionarray, $outputlangs, $object, $parameters);
|
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 = '';
|
$custcontact = '';
|
||||||
$contactarr = array();
|
$contactarr = array();
|
||||||
$contactarr = $object->liste_contact(- 1, 'external');
|
$contactarr = $tmpobject->liste_contact(- 1, 'external');
|
||||||
|
|
||||||
if (is_array($contactarr) && count($contactarr) > 0) {
|
if (is_array($contactarr) && count($contactarr) > 0) {
|
||||||
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user