Fix emailcollector from tickets

This commit is contained in:
Laurent Destailleur
2024-08-27 22:20:51 +02:00
parent 7e60db00b7
commit 367cdd7ccc
3 changed files with 15 additions and 5 deletions

View File

@@ -1406,14 +1406,14 @@ class EmailCollector extends CommonObject
}
}
if (empty($targetdir)) { // Use last date as filter if there is no targetdir defined.
if (empty($targetdir) || !getDolGlobalString('EMAILCOLLECTOR_NO_FILTER_ON_DATE_IF_THERE_IS_A_TARGETDIR')) { // Use last date as filter if there is no targetdir defined.
$fromdate = 0;
if ($this->datelastok) {
$fromdate = $this->datelastok;
}
if ($fromdate > 0) {
// $search .= ($search ? ' ' : '').'SINCE '.date('j-M-Y', $fromdate - 1); // SENTSINCE not supported. Date must be X-Abc-9999 (X on 1 digit if < 10)
array_push($criteria, array("SINCE" => date('j-M-Y', $fromdate - 1)));
array_push($criteria, array("SINCE" => date('j-M-Y', $fromdate - 1))); // -1 is to add a security to no forgot some email
}
//$search.=($search?' ':'').'SINCE 8-Apr-2022';
}

View File

@@ -190,7 +190,7 @@ NoMoreRecipientToSendTo=No more recipient to send the email to
EmailOptedOut=Email owner has requested to not contact him with this email anymore
EvenUnsubscribe=Include opt-out emails
EvenUnsubscribeDesc=Include opt-out emails when you select emails as targets. Useful for mandatory service emails for example.
XEmailsDoneYActionsDone=%s emails pre-qualified, %s emails successfully processed (for %s record/actions done)
XEmailsDoneYActionsDone=%s emails pre-qualified, %s emails successfully processed (for %s operations done)
YouCanMakeSomeInstructionForEmail=You can make some instructions for your Email (Example: generate image in email template...)
ModelTemplate=Email template
YouCanChooseAModelForYouMailContent= You can choose one of template models or generate one with AI

View File

@@ -897,15 +897,25 @@ if ($action == 'create' || $action == 'presend') {
$createdbyshown++;
}
$createdfrompublicticket = 0;
$createdfromemailcollector = 0;
if (!empty($object->origin_email) && (empty($object->email_msgid) || preg_match('/dolibarr\-tic\d+/', $object->email_msgid))) {
// If ticket create from public interface - TODO Add a more robust test to know if created by public interface
$createdfrompublicticket = 1;
} elseif (!empty($object->email_msgid)) {
// If ticket create by emailcollector - TODO Add a more robust test to know if created by email collector (using import ky ?)
$createdfromemailcollector = 1;
}
//var_dump($object);
if (!empty($object->origin_email)) { // If ticket create from public interface - TODO Add a more robust test to know if created by pubic interface
if ($createdfrompublicticket) {
$htmltooptip = $langs->trans("OriginEmail").': '.$object->origin_email;
$htmltooptip .= '<br>'.$langs->trans("IP").': '.$object->ip;
$morehtmlref .= ($createdbyshown ? ' - ' : '<br>');
$morehtmlref .= ($createdbyshown ? '' : $langs->trans("CreatedBy").' : ');
$morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
$morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">- '.$form->textwithpicto($langs->trans("CreatedByPublicPortal"), $htmltooptip, 1, 'help', '', 0, 3, 'tooltip').'</small>';
} elseif (!empty($object->email_msgid)) { // If ticket create by emailcollector - TODO Add a more robust test to know if created by email collector (using import ky ?)
} elseif ($createdfromemailcollector) {
$langs->load("mails");
$htmltooltip = $langs->trans("EmailMsgID").': '.$object->email_msgid;
$htmltooltip .= '<br>'.$langs->trans("EmailDate").': '.dol_print_date($object->email_date, 'dayhour');