From 0787eee9b8d3e927e6808a74fef98efd3e07e8bc Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Sat, 18 May 2019 18:42:46 +0200 Subject: [PATCH] fix :email collector for event creation --- htdocs/contact/class/contact.class.php | 4 ++-- htdocs/emailcollector/class/emailcollector.class.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index d350c8b3ff3..dfefb8060fe 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -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; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index e52b1bf156e..f60051df970 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -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)