Merge pull request #24443 from altairis-benjamin/ticketAssignNotification
NEW Send a notification email when ticket assigned
This commit is contained in:
commit
1c3264ee0a
@ -2,6 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014-2016 Jean-François Ferry <hello@librethic.io>
|
* Copyright (C) 2014-2016 Jean-François Ferry <hello@librethic.io>
|
||||||
* 2016 Christophe Battarel <christophe@altairis.fr>
|
* 2016 Christophe Battarel <christophe@altairis.fr>
|
||||||
|
* Copyright (C) 2023 Benjamin Falière <benjamin.faliere@altairis.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -69,12 +70,12 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
|||||||
case 'TICKET_ASSIGNED':
|
case 'TICKET_ASSIGNED':
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|
||||||
if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id) {
|
if ($object->fk_user_assign > 0) {
|
||||||
|
if ($object->fk_user_assign != $user->id) {
|
||||||
$userstat = new User($this->db);
|
$userstat = new User($this->db);
|
||||||
$res = $userstat->fetch($object->fk_user_assign);
|
$res = $userstat->fetch($object->fk_user_assign);
|
||||||
if ($res > 0) {
|
if ($res > 0) {
|
||||||
// Send email to notification email
|
// Send email to notification email
|
||||||
|
|
||||||
if (empty($conf->global->TICKET_DISABLE_ALL_MAILS)) {
|
if (empty($conf->global->TICKET_DISABLE_ALL_MAILS)) {
|
||||||
// Init to avoid errors
|
// Init to avoid errors
|
||||||
$filepath = array();
|
$filepath = array();
|
||||||
@ -119,13 +120,50 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
|||||||
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ok = 1;
|
|
||||||
} else {
|
} else {
|
||||||
$this->error = $userstat->error;
|
$this->error = $userstat->error;
|
||||||
$this->errors = $userstat->errors;
|
$this->errors = $userstat->errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send an email to the Customer to inform him that his ticket has been taken in charge.
|
||||||
|
if (!empty($conf->global->TICKET_NOTIFY_CUSTOMER_TICKET_ASSIGNED) && empty($object->oldcopy->fk_user_assign)) {
|
||||||
|
$langs->load('ticket');
|
||||||
|
|
||||||
|
$subject_customer = 'TicketAssignedCustomerEmail';
|
||||||
|
$body_customer = 'TicketAssignedCustomerBody';
|
||||||
|
$see_ticket_customer = 'TicketNewEmailBodyInfosTrackUrlCustomer';
|
||||||
|
|
||||||
|
// Get all external contacts linked to the ticket
|
||||||
|
$linked_contacts = $object->listeContact(-1, 'thirdparty');
|
||||||
|
|
||||||
|
// Initialize and fill recipient addresses at least with origin_email
|
||||||
|
$sendto = '';
|
||||||
|
$temp_emails = [];
|
||||||
|
if ($object->origin_email) {
|
||||||
|
$temp_emails[] = $object->origin_email;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($linked_contacts)) {
|
||||||
|
foreach ($linked_contacts as $contact) {
|
||||||
|
// Avoid the email from being sent twice in case of duplicated contact
|
||||||
|
if (!in_array($contact['email'], $temp_emails)) {
|
||||||
|
$temp_emails[] = $contact['email'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sendto = implode(", ", $temp_emails);
|
||||||
|
unset($temp_emails);
|
||||||
|
unset($linked_contacts);
|
||||||
|
|
||||||
|
// If recipients, we send the email
|
||||||
|
if ($sendto) {
|
||||||
|
$this->composeAndSendCustomerMessage($sendto, $subject_customer, $body_customer, $see_ticket_customer, $object, $langs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$ok = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'TICKET_CREATE':
|
case 'TICKET_CREATE':
|
||||||
|
|||||||
@ -246,6 +246,8 @@ ConfirmReOpenTicket=Confirm reopen this ticket ?
|
|||||||
TicketMessageMailIntroAutoNewPublicMessage=A new message was posted on the ticket with the subject %s:
|
TicketMessageMailIntroAutoNewPublicMessage=A new message was posted on the ticket with the subject %s:
|
||||||
TicketAssignedToYou=Ticket assigned
|
TicketAssignedToYou=Ticket assigned
|
||||||
TicketAssignedEmailBody=You have been assigned the ticket #%s by %s
|
TicketAssignedEmailBody=You have been assigned the ticket #%s by %s
|
||||||
|
TicketAssignedCustomerEmail=Your ticket has been taken in charge
|
||||||
|
TicketAssignedCustomerBody=This is an automatic email to confirm your ticket has been taken in charge.
|
||||||
MarkMessageAsPrivate=Mark message as private
|
MarkMessageAsPrivate=Mark message as private
|
||||||
TicketMessageSendEmailHelp=An email will be sent to all assigned contact (internal contacts, but also external contacts except if the option "%s" is checked)
|
TicketMessageSendEmailHelp=An email will be sent to all assigned contact (internal contacts, but also external contacts except if the option "%s" is checked)
|
||||||
TicketMessagePrivateHelp=This message will not display to external users
|
TicketMessagePrivateHelp=This message will not display to external users
|
||||||
|
|||||||
@ -244,6 +244,8 @@ ConfirmReOpenTicket=Voulez-vous ré-ouvrir ce ticket ?
|
|||||||
TicketMessageMailIntroAutoNewPublicMessage=Un nouveau message a été posté sur le ticket avec le sujet %s:
|
TicketMessageMailIntroAutoNewPublicMessage=Un nouveau message a été posté sur le ticket avec le sujet %s:
|
||||||
TicketAssignedToYou=Ticket attribué
|
TicketAssignedToYou=Ticket attribué
|
||||||
TicketAssignedEmailBody=Vous avez été assigné au ticket #%s par %s
|
TicketAssignedEmailBody=Vous avez été assigné au ticket #%s par %s
|
||||||
|
TicketAssignedCustomerEmail=Votre ticket a été pris en charge
|
||||||
|
TicketAssignedCustomerBody=Ceci est un email automatique pour confirmer que votre ticket a été pris en charge.
|
||||||
MarkMessageAsPrivate=Marquer message comme privé
|
MarkMessageAsPrivate=Marquer message comme privé
|
||||||
TicketMessageSendEmailHelp=Un email sera envoyé à tous les contacts assignés (contacts internes, mais aussi contacts externes sauf si l'option "%s" est cochée)
|
TicketMessageSendEmailHelp=Un email sera envoyé à tous les contacts assignés (contacts internes, mais aussi contacts externes sauf si l'option "%s" est cochée)
|
||||||
TicketMessagePrivateHelp=Ce message ne s'affichera pas pour les utilisateurs externes
|
TicketMessagePrivateHelp=Ce message ne s'affichera pas pour les utilisateurs externes
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user