Fix avoid duplicate event recorded from email collector
This commit is contained in:
parent
2abdfe08d7
commit
0309510ab8
@ -1782,7 +1782,7 @@ if ($id > 0)
|
||||
}
|
||||
|
||||
// Description
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3" class="wordbreak">';
|
||||
print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
@ -666,12 +666,13 @@ class ActionComm extends CommonObject
|
||||
/**
|
||||
* Load object from database
|
||||
*
|
||||
* @param int $id Id of action to get
|
||||
* @param string $ref Ref of action to get
|
||||
* @param string $ref_ext Ref ext to get
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param int $id Id of action to get
|
||||
* @param string $ref Ref of action to get
|
||||
* @param string $ref_ext Ref ext to get
|
||||
* @param string $email_msgid Email msgid
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetch($id, $ref = '', $ref_ext = '')
|
||||
public function fetch($id, $ref = '', $ref_ext = '', $email_msgid = '')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
@ -692,6 +693,7 @@ class ActionComm extends CommonObject
|
||||
$sql .= " a.fk_contact, a.percent as percentage,";
|
||||
$sql .= " a.fk_element as elementid, a.elementtype,";
|
||||
$sql .= " a.priority, a.fulldayevent, a.location, a.transparency,";
|
||||
$sql .= " a.email_msgid, a.email_subject, a.email_from, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to,";
|
||||
$sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,";
|
||||
$sql .= " s.nom as socname,";
|
||||
$sql .= " u.firstname, u.lastname as lastname";
|
||||
@ -700,9 +702,10 @@ class ActionComm extends CommonObject
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc";
|
||||
$sql .= " WHERE ";
|
||||
if ($ref) $sql .= " a.id=".$ref; // No field ref, we use id
|
||||
elseif ($ref_ext) $sql .= " a.ref_ext='".$this->db->escape($ref_ext)."'";
|
||||
else $sql .= " a.id=".$id;
|
||||
if ($ref) $sql .= " a.id = ".((int) $ref); // No field ref, we use id
|
||||
elseif ($ref_ext) $sql .= " a.ref_ext = '".$this->db->escape($ref_ext)."'";
|
||||
elseif ($email_msgid) $sql .= " a.email_msgid = '".$this->db->escape($email_msgid)."'";
|
||||
else $sql .= " a.id = ".((int) $id);
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@ -1643,10 +1643,10 @@ class EmailCollector extends CommonObject
|
||||
// Create event
|
||||
elseif ($operation['type'] == 'recordevent')
|
||||
{
|
||||
$alreadycreated = 0;
|
||||
// TODO Check if $msgid already in database for $conf->entity
|
||||
$actioncomm = new ActionComm($this->db);
|
||||
|
||||
if (!$alreadycreated)
|
||||
$alreadycreated = $actioncomm->fetch(0, '', '', $msgid);
|
||||
if ($alreadycreated == 0)
|
||||
{
|
||||
if ($projectstatic->id > 0)
|
||||
{
|
||||
@ -1672,7 +1672,6 @@ class EmailCollector extends CommonObject
|
||||
$descriptionfull = dol_concatdesc($descriptionfull, $header);
|
||||
|
||||
// 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;
|
||||
@ -1736,7 +1735,7 @@ class EmailCollector extends CommonObject
|
||||
{
|
||||
$projecttocreate = new Project($this->db);
|
||||
|
||||
$alreadycreated = $projecttocreate->fetch(0, '', $msgid);
|
||||
$alreadycreated = $projecttocreate->fetch(0, '', '', $msgid);
|
||||
if ($alreadycreated == 0)
|
||||
{
|
||||
if ($thirdpartystatic->id > 0)
|
||||
|
||||
@ -471,10 +471,11 @@ class Project extends CommonObject
|
||||
*
|
||||
* @param int $id Id of object to load
|
||||
* @param string $ref Ref of project
|
||||
* @param string $ref_ext Ref ext of project
|
||||
* @param string $email_msgid Email msgid
|
||||
* @return int >0 if OK, 0 if not found, <0 if KO
|
||||
*/
|
||||
public function fetch($id, $ref = '', $email_msgid = '')
|
||||
public function fetch($id, $ref = '', $ref_ext = '', $email_msgid = '')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -491,6 +492,8 @@ class Project extends CommonObject
|
||||
$sql .= " WHERE entity IN (".getEntity('project').")";
|
||||
if (! empty($ref)) {
|
||||
$sql .= " AND ref = '".$this->db->escape($ref)."'";
|
||||
} elseif (! empty($ref_ext)) {
|
||||
$sql .= " AND ref_ext = '".$this->db->escape($ref_ext)."'";
|
||||
} else {
|
||||
$sql .= " AND email_msgid = '".$this->db->escape($email_msgid)."'";
|
||||
}
|
||||
|
||||
@ -3321,7 +3321,9 @@ table.hidepaginationprevious .paginationprevious {
|
||||
table.hidepaginationnext .paginationnext {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tabBar .arearef .pagination.paginationref {
|
||||
max-width: calc(30%);
|
||||
}
|
||||
|
||||
|
||||
/* Set the color for hover lines */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user