diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index b446f989724..9775ebc758b 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2679,6 +2679,7 @@ class EmailCollector extends CommonObject // Search into contacts of thirdparties to try to guess the thirdparty to use $resultContact = $contactstatic->findNearest(0, '', '', '', $emailtouseforthirdparty, '', 0); if ($resultContact > 0) { + $contactstatic->fetch($resultContact); $idtouseforthirdparty = $contactstatic->socid; $result = $thirdpartystatic->fetch($idtouseforthirdparty); if ($result > 0) { diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index 15523dca6c3..7fa4f672175 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -788,8 +788,8 @@ if ($object->id > 0 || !empty($object->ref)) { $sql .= ", eb.batch, eb.eatby, eb.sellby"; $sql .= " FROM ".$db->prefix()."expeditiondet as ed"; $sql .= " LEFT JOIN ".$db->prefix()."expeditiondet_batch as eb on ed.rowid = eb.fk_expeditiondet"; - $sql .= " INNER JOIN ".$db->prefix()."commandedet as cd on ed.fk_origin_line = cd.rowid"; - $sql .= " WHERE ed.fk_origin_line = ".(int) $objp->rowid; + $sql .= " INNER JOIN ".$db->prefix()."commandedet as cd on ed.fk_elementdet = cd.rowid"; + $sql .= " WHERE ed.fk_elementdet = ".(int) $objp->rowid; $sql .= " AND ed.fk_expedition = ".(int) $object->id; $sql .= " ORDER BY ed.rowid, ed.fk_elementdet"; @@ -946,6 +946,10 @@ if ($object->id > 0 || !empty($object->ref)) { $numline++; } $suffix = "_".$j."_".$i; + } else { + $errorMsg = 'Shipment dispatch SQL error : '.$db->lasterror(); + setEventMessage($errorMsg, 'errors'); + dol_syslog($errorMsg, LOG_ERR); } if ($j == 0) {