fix search socid

This commit is contained in:
Eric Seigne 2024-02-27 20:39:33 +01:00
parent 737407c953
commit c34dbebcc5

View file

@ -2357,10 +2357,26 @@ class EmailCollector extends CommonObject
if ($operation['type'] == 'loadthirdparty') {
dol_syslog("Third party with id=".$idtouseforthirdparty." email=".$emailtouseforthirdparty." name=".$nametouseforthirdparty." name_alias=".$namealiastouseforthirdparty." was not found");
$errorforactions++;
$langs->load("errors");
$this->error = $langs->trans('ErrorFailedToLoadThirdParty', $idtouseforthirdparty, $emailtouseforthirdparty, $nametouseforthirdparty, $namealiastouseforthirdparty);
$this->errors[] = $this->error;
//TODO search into contacts of thirdparty
$resultContact = $contactstatic->fetch('','','',$emailtouseforthirdparty);
if($resultContact > 0) {
$idtouseforthirdparty = $contactstatic->socid;
$result = $thirdpartystatic->fetch($idtouseforthirdparty);
if($result > 0) {
dol_syslog("Third party with id=".$idtouseforthirdparty." email=".$emailtouseforthirdparty." name=".$nametouseforthirdparty." name_alias=".$namealiastouseforthirdparty." was found thanks to linked contact search");
} else {
$errorforactions++;
$langs->load("errors");
$this->error = $langs->trans('ErrorFailedToLoadThirdParty', $idtouseforthirdparty, $emailtouseforthirdparty, $nametouseforthirdparty, $namealiastouseforthirdparty);
$this->errors[] = $this->error;
}
} else {
$errorforactions++;
$langs->load("errors");
$this->error = $langs->trans('ErrorFailedToLoadThirdParty', $idtouseforthirdparty, $emailtouseforthirdparty, $nametouseforthirdparty, $namealiastouseforthirdparty);
$this->errors[] = $this->error;
}
} elseif ($operation['type'] == 'loadandcreatethirdparty') {
dol_syslog("Third party with id=".$idtouseforthirdparty." email=".$emailtouseforthirdparty." name=".$nametouseforthirdparty." name_alias=".$namealiastouseforthirdparty." was not found. We try to create it.");