Merge pull request #14638 from OPEN-DSI/new-ticket-public-mail-format

NEW format tickets sent by mail in public interface
This commit is contained in:
Laurent Destailleur 2020-09-04 22:37:18 +02:00 committed by GitHub
commit 7cc1e30748
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -208,14 +208,14 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) {
// Send email to customer
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubject', $object->ref, $object->track_id);
$message .= ($conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->transnoentities('TicketNewEmailBody'))."\n\n";
$message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket')."\n";
$message = ($conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->transnoentities('TicketNewEmailBody')) . '<br><br>';
$message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket') . '<br>';
$url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/' : dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id;
$infos_new_ticket = $langs->transnoentities('TicketNewEmailBodyInfosTrackId', '<a href="'.$url_public_ticket.'">'.$object->track_id.'</a>')."\n";
$infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl')."\n\n";
$infos_new_ticket = $langs->transnoentities('TicketNewEmailBodyInfosTrackId', '<a href="'.$url_public_ticket.'">'.$object->track_id.'</a>') . '<br>';
$infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl') . '<br><br>';
$message .= dol_nl2br($infos_new_ticket);
$message .= $infos_new_ticket;
$message .= $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->transnoentities('TicketMessageMailSignatureText');
$sendto = GETPOST('email', 'alpha');
@ -225,14 +225,12 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) {
$sendtocc = '';
$deliveryreceipt = 0;
$message = dol_nl2br($message);
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket');
if ($mailfile->error || $mailfile->errors) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
} else {
@ -247,34 +245,21 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) {
if ($sendto)
{
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin', $object->ref, $object->track_id);
$message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
$message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id) . '<br><br>';
$message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
$message_admin .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
$message_admin .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
$message_admin .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
$message_admin .= '<li>'.$langs->trans('From').' : '.$object->origin_email.'</li>';
if (is_array($extrafields->attributes[$object->table_element]['label']))
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
$enabled = 1;
if ($qualified && isset($extrafields->attributes[$object->table_element]['list'][$key]))
{
$enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1);
}
$perms = 1;
if ($perms && isset($extrafields->attributes[$object->table_element]['perms'][$key]))
{
$perms = dol_eval($extrafields->attributes[$object->table_element]['perms'][$key], 1);
}
$qualified = true;
if (empty($enabled) || $enabled == 2) $qualified = false;
if (empty($perms)) $qualified = false;
if ($qualified) $message_admin .= '<li>'.$langs->trans($key).' : '.$value.'</li>';
// Extrafields
$extrafields->fetch_name_optionals_label($object->table_element);
if (is_array($object->array_options) && count($object->array_options) > 0) {
foreach ($object->array_options as $key => $value) {
$key = substr($key, 8); // remove "options_"
$message_admin .= '<li>' . $langs->trans($extrafields->attributes[$object->element]['label'][$key]) . ' : ' . $extrafields->showOutputField($key, $value) . '</li>';
}
}
$message_admin .= '</ul>';
$message_admin .= '</ul>';
$message_admin .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
@ -283,14 +268,12 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) {
$from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
$replyto = $from;
$message_admin = dol_nl2br($message_admin);
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
$mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket');
if ($mailfile->error || $mailfile->errors) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
} else {