Fix emailcollector

This commit is contained in:
Laurent Destailleur 2019-04-29 16:38:56 +02:00
parent 483d017fc5
commit d0eecf9be5

View File

@ -1685,6 +1685,14 @@ class EmailCollector extends CommonObject
$tickettocreate->entity = $conf->entity; $tickettocreate->entity = $conf->entity;
//$tickettocreate->fk_contact = $contactstatic->id; //$tickettocreate->fk_contact = $contactstatic->id;
// Overwrite values with values extracted from source email.
// This may overwrite any $projecttocreate->xxx properties.
$savesocid = $tickettocreate->socid;
$errorforthisaction = $this->overwritePropertiesOfObject($tickettocreate, $operation['actionparam'], $messagetext, $subject, $header);
// Set ticket ref if not yet defined
if (empty($tickettocreate->ref))
{
// Get next project Ref // Get next project Ref
$defaultref=''; $defaultref='';
$modele = empty($conf->global->TICKET_ADDON)?'mod_ticket_simple':$conf->global->TICKET_ADDON; $modele = empty($conf->global->TICKET_ADDON)?'mod_ticket_simple':$conf->global->TICKET_ADDON;
@ -1706,15 +1714,27 @@ class EmailCollector extends CommonObject
if ($filefound) if ($filefound)
{ {
$result=dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); $result=dol_include_once($reldir."core/modules/ticket/".$modele.'.php');
$modTicket = new $classname; $modProject = new $classname;
$defaultref = $modTicket->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate); if ($savesocid > 0)
{
if ($savesocid != $tickettocreate->socid)
{
$errorforactions++;
setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$tickettocreate->socid.') by setting socid in operation with a different value');
}
}
else {
if ($tickettocreate->socid > 0)
{
$thirdpartystatic->fetch($tickettocreate->socid);
}
} }
$defaultref = $modTicket->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $projecttocreate);
}
$tickettocreate->ref = $defaultref; $tickettocreate->ref = $defaultref;
}
// Overwrite values with values extracted from source email
$errorforthisaction = $this->overwritePropertiesOfObject($tickettocreate, $operation['actionparam'], $messagetext, $subject, $header);
if ($errorforthisaction) if ($errorforthisaction)
{ {