[NEW] Ticket message notifications from public interface
Can send an email when a new message is added from public interface close issue #12181
This commit is contained in:
parent
e308170ed8
commit
fe8eddac5e
@ -106,6 +106,12 @@ if ($action == 'setvar') {
|
||||
if (!$res > 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
$param_public_notification_new_message_default_email = GETPOST('TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL', 'alpha');
|
||||
$res = dolibarr_set_const($db, 'TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL', $param_public_notification_new_message_default_email, 'chaine', 0, '', $conf->entity);
|
||||
if (!$res > 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setvarother') {
|
||||
@ -377,7 +383,31 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
|
||||
print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help');
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
// Activate email notification when a new message is added
|
||||
print '<tr class="pair"><td>' . $langs->trans("TicketsPublicNotificationNewMessage") . '</td>';
|
||||
print '<td class="left">';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print ajax_constantonoff('TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED');
|
||||
} else {
|
||||
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
|
||||
print $form->selectarray("TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED", $arrval, $conf->global->TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED);
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('', $langs->trans("TicketsPublicNotificationNewMessageHelp"), 1, 'help');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Send notification when a new message is added to a email if a user is not assigned to the ticket
|
||||
print '<tr><td>' . $langs->trans("TicketPublicNotificationNewMessageDefaultEmail") . '</label>';
|
||||
print '</td><td>';
|
||||
print '<input type="text" name="TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL" value="' . $conf->global->TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL . '" size="40" ></td>';
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('', $langs->trans("TicketPublicNotificationNewMessageDefaultEmailHelp"), 1, 'help');
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
|
||||
|
||||
@ -130,6 +130,10 @@ TicketNumberingModules=Tickets numbering module
|
||||
TicketNotifyTiersAtCreation=Notify third party at creation
|
||||
TicketGroup=Group
|
||||
TicketsDisableCustomerEmail=Always disable emails when a ticket is created from public interface
|
||||
TicketsPublicNotificationNewMessage=Send email(s) when a new message is added
|
||||
TicketsPublicNotificationNewMessageHelp=Send email(s) when a new message is added from public interface (to assigned user or the notifications email to (update) and/or the notifications email to)
|
||||
TicketPublicNotificationNewMessageDefaultEmail=Notifications email to (update)
|
||||
TicketPublicNotificationNewMessageDefaultEmailHelp=Send email new message notifications to this address if the ticket don't have a user assigned or the user don't have a email.
|
||||
#
|
||||
# Index & list page
|
||||
#
|
||||
|
||||
@ -130,6 +130,10 @@ TicketNumberingModules=Module de numérotation des tickets
|
||||
TicketNotifyTiersAtCreation=Notifier le tiers à la création
|
||||
TicketGroup=Groupe
|
||||
TicketsDisableCustomerEmail=Toujours désactiver les courriels lorsqu'un ticket est créé depuis l'interface publique
|
||||
TicketsPublicNotificationNewMessage=Envoi d'e-mails lorsqu'un nouveau message est ajouté
|
||||
TicketsPublicNotificationNewMessageHelp=Envoi d'e-mails lorsqu'un nouveau message est ajouté depuis l'interface public (à l'utilisateur assigné ou à l'e-mail de notification à (nouveaux message) et/ou l'e-mail de notification à)
|
||||
TicketPublicNotificationNewMessageDefaultEmail=E-mail de notification à (nouveaux message)
|
||||
TicketPublicNotificationNewMessageDefaultEmailHelp=Envoyer des notifications de nouveaux message par e-mail à cette adresse si aucun utilisateur n'a été affecté au ticket ou qu'il n'a pas d'e-mail.
|
||||
#
|
||||
# Index & list page
|
||||
#
|
||||
|
||||
@ -171,7 +171,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a
|
||||
if (!$error && $action == "add_message" && $display_ticket && GETPOSTISSET('btn_add_message'))
|
||||
{
|
||||
// TODO Add message...
|
||||
$ret = $object->dao->newMessage($user, $action, 0);
|
||||
$ret = $object->dao->newMessage($user, $action, 0, 1);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -2391,14 +2391,15 @@ class Ticket extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* Add new message on a ticket (private area). Can also send it be email if GETPOST('send_email', 'int') is set.
|
||||
* Add new message on a ticket (private/public area). Can also send it be email if GETPOST('send_email', 'int') is set.
|
||||
*
|
||||
* @param User $user User for action
|
||||
* @param string $action Action string
|
||||
* @param int $private 1=Message is private. TODO Implement this. What does this means ?
|
||||
* @param int $public_area 1=Is the public area
|
||||
* @return int
|
||||
*/
|
||||
public function newMessage($user, &$action, $private = 1)
|
||||
public function newMessage($user, &$action, $private = 1, $public_area = 0)
|
||||
{
|
||||
global $mysoc, $conf, $langs;
|
||||
|
||||
@ -2451,142 +2452,215 @@ class Ticket extends CommonObject
|
||||
//var_dump($_SESSION); var_dump($listofpaths);exit;
|
||||
|
||||
/*
|
||||
* Send emails to internal users (linked contacts)
|
||||
*/
|
||||
if ($send_email > 0) {
|
||||
// Retrieve internal contact datas
|
||||
$internal_contacts = $object->getInfosTicketInternalContact();
|
||||
|
||||
$sendto = array();
|
||||
if (is_array($internal_contacts) && count($internal_contacts) > 0) {
|
||||
// altairis: set default subject
|
||||
$label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE;
|
||||
$subject = GETPOST('subject', 'nohtml') ? GETPOST('subject', 'nohtml') : '['.$label_title.'- ticket #'.$object->track_id.'] '.$langs->trans('TicketNewMessage');
|
||||
|
||||
$message_intro = $langs->trans('TicketNotificationEmailBody', "#".$object->id);
|
||||
$message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE;
|
||||
|
||||
$message = $langs->trans('TicketMessageMailIntroText');
|
||||
$message .= "\n\n";
|
||||
$message .= GETPOST('message', 'restricthtml');
|
||||
|
||||
// Coordonnées client
|
||||
$message .= "\n\n";
|
||||
$message .= "==============================================\n";
|
||||
$message .= !empty($object->thirdparty->name) ? $langs->trans('Thirdparty')." : ".$object->thirdparty->name : '';
|
||||
$message .= !empty($object->thirdparty->town) ? "\n".$langs->trans('Town')." : ".$object->thirdparty->town : '';
|
||||
$message .= !empty($object->thirdparty->phone) ? "\n".$langs->trans('Phone')." : ".$object->thirdparty->phone : '';
|
||||
|
||||
// Build array to display recipient list
|
||||
foreach ($internal_contacts as $key => $info_sendto) {
|
||||
// altairis: avoid duplicate notifications
|
||||
if ($info_sendto['id'] == $user->id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($info_sendto['email'] != '') {
|
||||
if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">";
|
||||
|
||||
//Contact type
|
||||
$recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')';
|
||||
$message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient').' : '.$recipient."\n" : '');
|
||||
* Public area
|
||||
*/
|
||||
if (!empty($public_area)) {
|
||||
/*
|
||||
* Send emails to assigned users (public area notification)
|
||||
*/
|
||||
if (!empty($conf->global->TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED)) {
|
||||
$assigned_user_dont_have_email = '';
|
||||
$sendto = array();
|
||||
if ($this->fk_user_assign > 0) {
|
||||
$assigned_user = new User($this->db);
|
||||
$assigned_user->fetch($this->fk_user_assign);
|
||||
if (!empty($assigned_user->email)) {
|
||||
$sendto[] = $assigned_user->getFullName($langs) . " <" . $assigned_user->email . ">";
|
||||
} else {
|
||||
$assigned_user_dont_have_email = $assigned_user->getFullName($langs);
|
||||
}
|
||||
}
|
||||
if (empty($sendto)) {
|
||||
if (!empty($conf->global->TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL)) {
|
||||
$sendto[] = $conf->global->TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL;
|
||||
} elseif (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) {
|
||||
$sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
|
||||
}
|
||||
}
|
||||
$message .= "\n";
|
||||
// URL ticket
|
||||
$url_internal_ticket = dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id;
|
||||
|
||||
// altairis: make html link on url
|
||||
$message .= "\n".$langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal').' : <a href="'.$url_internal_ticket.'">'.$object->track_id.'</a>'."\n";
|
||||
|
||||
// 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;
|
||||
if (!empty($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS) &&
|
||||
!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)
|
||||
) {
|
||||
$sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
|
||||
}
|
||||
|
||||
// altairis: dont try to send email if no recipient
|
||||
if (!empty($sendto)) {
|
||||
$label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE;
|
||||
$subject = '[' . $label_title . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage');
|
||||
|
||||
// Message send
|
||||
$message = $langs->trans('TicketMessageMailIntroText');
|
||||
$message .= "\n\n";
|
||||
$message .= GETPOST('message', 'restricthtml');
|
||||
|
||||
// Customer company infos
|
||||
$message .= "\n\n";
|
||||
$message .= "==============================================";
|
||||
$message .= !empty($object->thirdparty->name) ? "\n" . $langs->trans('Thirdparty') . " : " . $object->thirdparty->name : '';
|
||||
$message .= !empty($object->thirdparty->town) ? "\n" . $langs->trans('Town') . " : " . $object->thirdparty->town : '';
|
||||
$message .= !empty($object->thirdparty->phone) ? "\n" . $langs->trans('Phone') . " : " . $object->thirdparty->phone : '';
|
||||
|
||||
// Email send to
|
||||
$message .= "\n\n";
|
||||
if (!empty($assigned_user_dont_have_email)) {
|
||||
$message .= "\n" . $langs->trans('NoEMail') . ' : ' . $assigned_user_dont_have_email;
|
||||
}
|
||||
foreach ($sendto as $val) {
|
||||
$message .= "\n" . $langs->trans('TicketNotificationRecipient') . ' : ' . $val;
|
||||
}
|
||||
|
||||
// URL ticket
|
||||
$url_internal_ticket = dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id;
|
||||
$message .= "\n\n";
|
||||
$message .= $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . '<a href="' . $url_internal_ticket . '">' . $object->track_id . '</a>';
|
||||
|
||||
$this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Private area
|
||||
*/
|
||||
else {
|
||||
/*
|
||||
* Send emails for externals users if not private (linked contacts)
|
||||
*/
|
||||
if (empty($object->private)) {
|
||||
// Retrieve email of all contacts (external)
|
||||
$external_contacts = $object->getInfosTicketExternalContact();
|
||||
|
||||
// If no contact, get email from thirdparty
|
||||
if (is_array($external_contacts) && count($external_contacts) === 0) {
|
||||
if (!empty($object->fk_soc)) {
|
||||
$object->fetch_thirdparty($object->fk_soc);
|
||||
$array_company = array(array('firstname' => '', 'lastname' => $object->thirdparty->name, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id));
|
||||
$external_contacts = array_merge($external_contacts, $array_company);
|
||||
} elseif (empty($object->fk_soc) && !empty($object->origin_email)) {
|
||||
$array_external = array(array('firstname' => '', 'lastname' => $object->origin_email, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id));
|
||||
$external_contacts = array_merge($external_contacts, $array_external);
|
||||
}
|
||||
}
|
||||
* Send emails to internal users (linked contacts)
|
||||
*/
|
||||
if ($send_email > 0) {
|
||||
// Retrieve internal contact datas
|
||||
$internal_contacts = $object->getInfosTicketInternalContact();
|
||||
|
||||
$sendto = array();
|
||||
if (is_array($external_contacts) && count($external_contacts) > 0) {
|
||||
// altairis: get default subject for email to external contacts
|
||||
if (is_array($internal_contacts) && count($internal_contacts) > 0) {
|
||||
// altairis: set default subject
|
||||
$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');
|
||||
$subject = GETPOST('subject', 'nohtml') ? GETPOST('subject', 'nohtml') : '[' . $label_title . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage');
|
||||
|
||||
$message_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO;
|
||||
$message_intro = $langs->trans('TicketNotificationEmailBody', "#" . $object->id);
|
||||
$message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE;
|
||||
|
||||
// We put intro after
|
||||
$message = GETPOST('message');
|
||||
$message = $langs->trans('TicketMessageMailIntroText');
|
||||
$message .= "\n\n";
|
||||
$message .= GETPOST('message', 'restricthtml');
|
||||
|
||||
foreach ($external_contacts as $key => $info_sendto) {
|
||||
// altairis: avoid duplicate emails to external contacts
|
||||
if ($info_sendto['id'] == $user->contactid) {
|
||||
// Coordonnées client
|
||||
$message .= "\n\n";
|
||||
$message .= "==============================================\n";
|
||||
$message .= !empty($object->thirdparty->name) ? $langs->trans('Thirdparty') . " : " . $object->thirdparty->name : '';
|
||||
$message .= !empty($object->thirdparty->town) ? "\n" . $langs->trans('Town') . " : " . $object->thirdparty->town : '';
|
||||
$message .= !empty($object->thirdparty->phone) ? "\n" . $langs->trans('Phone') . " : " . $object->thirdparty->phone : '';
|
||||
|
||||
// Build array to display recipient list
|
||||
foreach ($internal_contacts as $key => $info_sendto) {
|
||||
// altairis: avoid duplicate notifications
|
||||
if ($info_sendto['id'] == $user->id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($info_sendto['email'] != '' && $info_sendto['email'] != $object->origin_email) {
|
||||
if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">";
|
||||
if ($info_sendto['email'] != '') {
|
||||
if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">";
|
||||
|
||||
$recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')';
|
||||
$message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient').' : '.$recipient."\n" : '');
|
||||
//Contact type
|
||||
$recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')';
|
||||
$message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . "\n" : '');
|
||||
}
|
||||
}
|
||||
$message .= "\n";
|
||||
// URL ticket
|
||||
$url_internal_ticket = dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id;
|
||||
|
||||
// If public interface is not enable, use link to internal page into mail
|
||||
$url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ?
|
||||
(!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/view.php' : dol_buildpath('/public/ticket/view.php', 2)) : dol_buildpath('/ticket/card.php', 2)).'?track_id='.$object->track_id;
|
||||
$message .= "\n".$langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer').' : <a href="'.$url_public_ticket.'">'.$object->track_id.'</a>'."\n";
|
||||
// altairis: make html link on url
|
||||
$message .= "\n" . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : <a href="' . $url_internal_ticket . '">' . $object->track_id . '</a>' . "\n";
|
||||
|
||||
// Build final message
|
||||
$message = $message_intro.$message;
|
||||
|
||||
// Add signature
|
||||
$message .= '<br>'.$message_signature;
|
||||
|
||||
if (!empty($object->origin_email)) {
|
||||
$sendto[] = $object->origin_email;
|
||||
}
|
||||
|
||||
if ($object->fk_soc > 0 && !in_array($object->origin_email, $sendto)) {
|
||||
$object->socid = $object->fk_soc;
|
||||
$object->fetch_thirdparty();
|
||||
if (!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email;
|
||||
}
|
||||
|
||||
// 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
|
||||
// altairis: dont try to send email if no recipient
|
||||
if (!empty($sendto)) {
|
||||
$this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Send emails for externals users if not private (linked contacts)
|
||||
*/
|
||||
if (empty($object->private)) {
|
||||
// Retrieve email of all contacts (external)
|
||||
$external_contacts = $object->getInfosTicketExternalContact();
|
||||
|
||||
// If no contact, get email from thirdparty
|
||||
if (is_array($external_contacts) && count($external_contacts) === 0) {
|
||||
if (!empty($object->fk_soc)) {
|
||||
$object->fetch_thirdparty($object->fk_soc);
|
||||
$array_company = array(array('firstname' => '', 'lastname' => $object->thirdparty->name, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id));
|
||||
$external_contacts = array_merge($external_contacts, $array_company);
|
||||
} elseif (empty($object->fk_soc) && !empty($object->origin_email)) {
|
||||
$array_external = array(array('firstname' => '', 'lastname' => $object->origin_email, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id));
|
||||
$external_contacts = array_merge($external_contacts, $array_external);
|
||||
}
|
||||
}
|
||||
|
||||
$sendto = array();
|
||||
if (is_array($external_contacts) && count($external_contacts) > 0) {
|
||||
// altairis: 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');
|
||||
|
||||
$message_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO;
|
||||
$message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE;
|
||||
|
||||
// We put intro after
|
||||
$message = GETPOST('message');
|
||||
$message .= "\n\n";
|
||||
|
||||
foreach ($external_contacts as $key => $info_sendto) {
|
||||
// altairis: avoid duplicate emails to external contacts
|
||||
if ($info_sendto['id'] == $user->contactid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($info_sendto['email'] != '' && $info_sendto['email'] != $object->origin_email) {
|
||||
if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">";
|
||||
|
||||
$recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')';
|
||||
$message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . "\n" : '');
|
||||
}
|
||||
}
|
||||
|
||||
// If public interface is not enable, use link to internal page into mail
|
||||
$url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ?
|
||||
(!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : dol_buildpath('/public/ticket/view.php', 2)) : dol_buildpath('/ticket/card.php', 2)) . '?track_id=' . $object->track_id;
|
||||
$message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : <a href="' . $url_public_ticket . '">' . $object->track_id . '</a>' . "\n";
|
||||
|
||||
// Build final message
|
||||
$message = $message_intro . $message;
|
||||
|
||||
// Add signature
|
||||
$message .= '<br>' . $message_signature;
|
||||
|
||||
if (!empty($object->origin_email)) {
|
||||
$sendto[] = $object->origin_email;
|
||||
}
|
||||
|
||||
if ($object->fk_soc > 0 && !in_array($object->origin_email, $sendto)) {
|
||||
$object->socid = $object->fk_soc;
|
||||
$object->fetch_thirdparty();
|
||||
if (!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email;
|
||||
}
|
||||
|
||||
// altairis: Add global email address reciepient
|
||||
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
|
||||
if (!empty($sendto)) {
|
||||
$this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user