mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-08 00:52:01 +01:00
NEW Add the SMTP header References on ticket email created by email
This commit is contained in:
@@ -2192,6 +2192,7 @@ ShowProjectLabel=Project Label
|
||||
PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME=Include alias in thirdparty name
|
||||
THIRDPARTY_ALIAS=Name thirdparty - Alias thirdparty
|
||||
ALIAS_THIRDPARTY=Alias thirdparty - Name thirdparty
|
||||
PDFIn2Languages=Show labels into PDF in 2 different languages
|
||||
PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some texts in your PDF duplicated in 2 different languages in the same generated PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF.
|
||||
PDF_USE_A=Gererate PDF documents with format PDF/A instead of defaut format PDF
|
||||
FafaIconSocialNetworksDesc=Enter here the code of a FontAwesome icon. If you don't know what is FontAwesome, you can use the generic value fa-address-book.
|
||||
|
||||
@@ -439,10 +439,10 @@ if (empty($reshook)) {
|
||||
$action = 'view';
|
||||
}
|
||||
|
||||
// Action to add an action (not a message).
|
||||
// Action to add a message (private or not, with email or not).
|
||||
// This may also send an email (concatenated with email_intro and email footer if checkbox was selected)
|
||||
if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $user->rights->ticket->read) {
|
||||
$ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0));
|
||||
$ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0), 0);
|
||||
|
||||
if ($ret > 0) {
|
||||
if (!empty($backtopage)) {
|
||||
@@ -1405,12 +1405,12 @@ if ($action == 'create' || $action == 'presend') {
|
||||
if (empty($reshook)) {
|
||||
// Email
|
||||
if (isset($object->status) && $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage") {
|
||||
print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?action=presend_addmessage&send_email=1&private_message=0&mode=init&token='.newToken().'&track_id='.$object->track_id, '');
|
||||
print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?action=presend_addmessage&send_email=1&private_message=0&mode=init&token='.newToken().'&track_id='.$object->track_id.'#formmailbeforetitle', '');
|
||||
}
|
||||
|
||||
// Show link to add a message (if read and not closed)
|
||||
if (isset($object->status) && $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage") {
|
||||
print dolGetButtonAction('', $langs->trans('TicketAddMessage'), 'default', $_SERVER["PHP_SELF"].'?action=presend_addmessage&mode=init&token='.newToken().'&track_id='.$object->track_id, '');
|
||||
print dolGetButtonAction('', $langs->trans('TicketAddMessage'), 'default', $_SERVER["PHP_SELF"].'?action=presend_addmessage&mode=init&token='.newToken().'&track_id='.$object->track_id.'#formmailbeforetitle', '');
|
||||
}
|
||||
|
||||
// Link to create an intervention
|
||||
|
||||
@@ -2421,7 +2421,7 @@ class Ticket extends CommonObject
|
||||
|
||||
if (!empty($public_area)) {
|
||||
/*
|
||||
* Message created fromthe Public interface
|
||||
* Message created from the Public interface
|
||||
*
|
||||
* Send emails to assigned users (public area notification)
|
||||
*/
|
||||
@@ -2491,9 +2491,9 @@ class Ticket extends CommonObject
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Send from Backoffice / Private area
|
||||
* Message send from the Backoffice / Private area
|
||||
*
|
||||
* Send emails to internal users (linked contacts)
|
||||
* Send emails to internal users (linked contacts) then, if private is not set, to external users (linked contacts or thirdparty email if no contact set)
|
||||
*/
|
||||
if ($send_email > 0) {
|
||||
// Retrieve internal contact datas
|
||||
@@ -2501,9 +2501,10 @@ class Ticket extends CommonObject
|
||||
|
||||
$sendto = array();
|
||||
if (is_array($internal_contacts) && count($internal_contacts) > 0) {
|
||||
// altairis: set default subject
|
||||
// Set default subject
|
||||
$label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE;
|
||||
$subject = GETPOST('subject', 'alphanohtml') ? GETPOST('subject', 'alphanohtml') : '['.$label_title.'- ticket #'.$object->track_id.'] '.$langs->trans('TicketNewMessage');
|
||||
$appli = $label_title;
|
||||
$subject = GETPOST('subject', 'alphanohtml') ? GETPOST('subject', 'alphanohtml') : '['.$appli.' - '.$langs->trans("Ticket").' #'.$object->track_id.'] '.$langs->trans('TicketNewMessage');
|
||||
|
||||
$message_intro = $langs->trans('TicketNotificationEmailBody', "#".$object->id);
|
||||
$message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE');
|
||||
@@ -2516,7 +2517,7 @@ class Ticket extends CommonObject
|
||||
}
|
||||
$message .= $messagePost;
|
||||
|
||||
// Coordonnées client
|
||||
// Data about customer
|
||||
$message .= '<br><br>';
|
||||
$message .= "==============================================<br>";
|
||||
$message .= !empty($object->thirdparty->name) ? $langs->trans('Thirdparty')." : ".$object->thirdparty->name : '';
|
||||
@@ -2525,7 +2526,7 @@ class Ticket extends CommonObject
|
||||
|
||||
// Build array to display recipient list
|
||||
foreach ($internal_contacts as $key => $info_sendto) {
|
||||
// altairis: avoid duplicate notifications
|
||||
// Avoid duplicate notifications
|
||||
if ($info_sendto['id'] == $user->id) {
|
||||
continue;
|
||||
}
|
||||
@@ -2535,7 +2536,7 @@ class Ticket extends CommonObject
|
||||
$sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">";
|
||||
}
|
||||
|
||||
//Contact type
|
||||
// Contact type
|
||||
$recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')';
|
||||
$message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient').' : '.$recipient.'<br>' : '');
|
||||
}
|
||||
@@ -2544,7 +2545,7 @@ class Ticket extends CommonObject
|
||||
// URL ticket
|
||||
$url_internal_ticket = dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id;
|
||||
|
||||
// add html link on url
|
||||
// Add html link on url
|
||||
$message .= '<br>'.$langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal').' : <a href="'.$url_internal_ticket.'">'.$object->track_id.'</a><br>';
|
||||
|
||||
// Add global email address recipient
|
||||
@@ -2581,9 +2582,10 @@ class Ticket extends CommonObject
|
||||
|
||||
$sendto = array();
|
||||
if (is_array($external_contacts) && count($external_contacts) > 0) {
|
||||
// altairis: get default subject for email to external contacts
|
||||
// Get default subject for email to external contacts
|
||||
$label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE;
|
||||
$subject = GETPOST('subject') ? GETPOST('subject') : '['.$label_title.'- ticket #'.$object->track_id.'] '.$langs->trans('TicketNewMessage');
|
||||
$appli = $mysoc->name;
|
||||
$subject = GETPOST('subject') ? GETPOST('subject') : '['.$appli.' - '.$langs->trans("Ticket").' #'.$object->track_id.'] '.$langs->trans('TicketNewMessage');
|
||||
|
||||
$message_intro = GETPOST('mail_intro') ? GETPOST('mail_intro', 'restricthtml') : getDolGlobalString('TICKET_MESSAGE_MAIL_INTRO');
|
||||
$message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature', 'restricthtml') : getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE');
|
||||
@@ -2641,20 +2643,20 @@ class Ticket extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
// altairis: Add global email address reciepient
|
||||
// Add global email address recipient
|
||||
if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) {
|
||||
if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) {
|
||||
$sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
|
||||
}
|
||||
}
|
||||
|
||||
// altairis: dont try to send email when no recipient
|
||||
// Dont try to send email when no recipient
|
||||
if (!empty($sendto)) {
|
||||
$result = $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
|
||||
if ($result) {
|
||||
// update last_msg_sent date
|
||||
// update last_msg_sent date (for last message sent to external users)
|
||||
$this->date_last_msg_sent = dol_now();
|
||||
$this->update($user, 1); // disable trigger when updatin date_last_msg_sent. sendTicketMessageByEmail already create an event in actioncomm table.
|
||||
$this->update($user, 1); // disable trigger when updating date_last_msg_sent. sendTicketMessageByEmail already create an event in actioncomm table.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2735,7 +2737,13 @@ class Ticket extends CommonObject
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||
$trackid = "tic".$this->id;
|
||||
$mailfile = new CMailFile($subject, $receiver, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid, '', 'ticket', '', $upload_dir_tmp);
|
||||
|
||||
$moreinheader = 'X-Dolibarr-Info: sendTicketMessageByEmail'."\r\n";
|
||||
if (!empty($this->email_msgid)) {
|
||||
$moreinheader .= 'References <'.$this->email_msgid.'>'."\r\n";
|
||||
}
|
||||
|
||||
$mailfile = new CMailFile($subject, $receiver, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid, $moreinheader, 'ticket', '', $upload_dir_tmp);
|
||||
if ($mailfile->error) {
|
||||
setEventMessages($mailfile->error, null, 'errors');
|
||||
} else {
|
||||
@@ -2762,6 +2770,7 @@ class Ticket extends CommonObject
|
||||
$langs->load("other");
|
||||
setEventMessages($langs->trans('ErrorMailRecipientIsEmptyForSendTicketMessage'), null, 'warnings');
|
||||
}
|
||||
|
||||
return $is_sent;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user