fix :email collector for event creation

This commit is contained in:
florian HENRY 2019-05-18 18:42:46 +02:00
parent ebe37df9db
commit 0787eee9b8
2 changed files with 6 additions and 6 deletions

View File

@ -698,9 +698,9 @@ class Contact extends CommonObject
$langs->load("dict");
dol_syslog(get_class($this)."::fetch id=".$id, LOG_DEBUG);
dol_syslog(get_class($this) . "::fetch id=" . $id . " ref_ext=" . $ref_ext . " email=" . $email, LOG_DEBUG);
if (empty($id) && empty($ref_ext))
if (empty($id) && empty($ref_ext) && empty($email))
{
$this->error='BadParameter';
return -1;

View File

@ -1287,13 +1287,14 @@ class EmailCollector extends CommonObject
if (empty($contactid)) // Try to find contact using email
{
$result = $contactstatic->fetch(0, null, '', $from);
if ($result > 0)
{
$contactid = $contactstatic->id;
$contactfoundby = 'email of contact ('.$from.')';
if ($contactstatic->fk_soc > 0)
if ($contactstatic->socid > 0)
{
$result = $thirdpartystatic->fetch($contactstatic->fk_soc);
$result = $thirdpartystatic->fetch($contactstatic->socid);
if ($result > 0)
{
$thirdpartyid = $thirdpartystatic->id;
@ -1309,7 +1310,6 @@ class EmailCollector extends CommonObject
if ($result > 0) $thirdpartyfoundby = 'email ('.$from.')';
}
// Do operations
foreach($this->actions as $operation)
{
@ -1492,7 +1492,6 @@ class EmailCollector extends CommonObject
// Insert record of emails sent
$actioncomm = new ActionComm($this->db);
$actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
$actioncomm->code = 'AC_'.$actioncode;
$actioncomm->label = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from;
@ -1503,6 +1502,7 @@ class EmailCollector extends CommonObject
$actioncomm->percentage = -1; // Not applicable
$actioncomm->socid = $thirdpartystatic->id;
$actioncomm->contactid = $contactstatic->id;
$actioncomm->socpeopleassigned = (!empty($contactstatic->id) ? array($contactstatic->id => '') : array());
$actioncomm->authorid = $user->id; // User saving action
$actioncomm->userownerid = $user->id; // Owner of action
// Fields when action is an email (content should be added into note)