|
|
|
|
@ -133,71 +133,21 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
|
|
|
|
|
|
|
|
|
$langs->load('ticket');
|
|
|
|
|
|
|
|
|
|
$subject_admin = 'TicketNewEmailSubjectAdmin';
|
|
|
|
|
$body_admin = 'TicketNewEmailBodyAdmin';
|
|
|
|
|
$subject_customer = 'TicketNewEmailSubjectCustomer';
|
|
|
|
|
$body_customer = 'TicketNewEmailBodyCustomer';
|
|
|
|
|
$see_ticket_customer = 'TicketNewEmailBodyInfosTrackUrlCustomer';
|
|
|
|
|
|
|
|
|
|
// Send email to notification email
|
|
|
|
|
if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && empty($object->context['disableticketemail'])) {
|
|
|
|
|
$sendto = empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) ? '' : $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
|
|
|
|
|
|
|
|
|
|
if ($sendto) {
|
|
|
|
|
// Init to avoid errors
|
|
|
|
|
$filepath = array();
|
|
|
|
|
$filename = array();
|
|
|
|
|
$mimetype = array();
|
|
|
|
|
|
|
|
|
|
/* Send email to admin */
|
|
|
|
|
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin');
|
|
|
|
|
$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').' : '.$langs->getLabelFromKey($this->db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code).'</li>';
|
|
|
|
|
$message_admin .= '<li>'.$langs->trans('Category').' : '.$langs->getLabelFromKey($this->db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code).'</li>';
|
|
|
|
|
$message_admin .= '<li>'.$langs->trans('Severity').' : '.$langs->getLabelFromKey($this->db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code).'</li>';
|
|
|
|
|
$message_admin .= '<li>'.$langs->trans('From').' : '.($object->email_from ? $object->email_from : ($object->fk_user_create > 0 ? $langs->trans('Internal') : '')).'</li>';
|
|
|
|
|
// Extrafields
|
|
|
|
|
$extraFields = new ExtraFields($this->db);
|
|
|
|
|
$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, '', $object->table_element).'</li>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$message_admin .= '</ul>';
|
|
|
|
|
|
|
|
|
|
if ($object->fk_soc > 0) {
|
|
|
|
|
$object->fetch_thirdparty();
|
|
|
|
|
$message_admin .= '<p>'.$langs->trans('Company').' : '.$object->thirdparty->name.'</p>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$message = $object->message;
|
|
|
|
|
if (!dol_textishtml($message)) {
|
|
|
|
|
$message = dol_nl2br($message);
|
|
|
|
|
}
|
|
|
|
|
$message_admin .= '<p>'.$langs->trans('Message').' : <br>'.$message.'</p>';
|
|
|
|
|
$message_admin .= '<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
|
|
|
|
|
|
|
|
|
|
$from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
|
|
|
|
|
$replyto = $from;
|
|
|
|
|
|
|
|
|
|
$trackid = 'tic'.$object->id;
|
|
|
|
|
|
|
|
|
|
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, '', '', 0, -1, '', '', $trackid, '', 'ticket');
|
|
|
|
|
if ($mailfile->error) {
|
|
|
|
|
dol_syslog($mailfile->error, LOG_DEBUG);
|
|
|
|
|
} else {
|
|
|
|
|
$result = $mailfile->sendfile();
|
|
|
|
|
}
|
|
|
|
|
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
|
|
|
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
|
|
|
|
}
|
|
|
|
|
$this->composeAndSendAdminMessage($sendto, $subject_admin, $body_admin, $object, $langs, $conf);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send email to customer
|
|
|
|
|
|
|
|
|
|
if (empty($conf->global->TICKET_DISABLE_CUSTOMER_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) {
|
|
|
|
|
$sendto = '';
|
|
|
|
|
|
|
|
|
|
@ -218,77 +168,7 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($sendto) {
|
|
|
|
|
// Init to avoid errors
|
|
|
|
|
$filepath = array();
|
|
|
|
|
$filename = array();
|
|
|
|
|
$mimetype = array();
|
|
|
|
|
|
|
|
|
|
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer');
|
|
|
|
|
$message_customer = $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id).'<br><br>';
|
|
|
|
|
$message_customer .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
|
|
|
|
|
$message_customer .= '<li>'.$langs->trans('Type').' : '.$langs->getLabelFromKey($this->db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code).'</li>';
|
|
|
|
|
$message_customer .= '<li>'.$langs->trans('Category').' : '.$langs->getLabelFromKey($this->db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code).'</li>';
|
|
|
|
|
$message_customer .= '<li>'.$langs->trans('Severity').' : '.$langs->getLabelFromKey($this->db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code).'</li>';
|
|
|
|
|
|
|
|
|
|
// Extrafields
|
|
|
|
|
foreach ($this->attributes[$object->table_element]['label'] as $key => $value) {
|
|
|
|
|
$enabled = 1;
|
|
|
|
|
if ($enabled && isset($this->attributes[$object->table_element]['list'][$key])) {
|
|
|
|
|
$enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1);
|
|
|
|
|
}
|
|
|
|
|
$perms = 1;
|
|
|
|
|
if ($perms && isset($this->attributes[$object->table_element]['perms'][$key])) {
|
|
|
|
|
$perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$qualified = true;
|
|
|
|
|
if (empty($enabled)) {
|
|
|
|
|
$qualified = false;
|
|
|
|
|
}
|
|
|
|
|
if (empty($perms)) {
|
|
|
|
|
$qualified = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($qualified) {
|
|
|
|
|
$message_customer .= '<li>'.$langs->trans($key).' : '.$value.'</li>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$message_customer .= '</ul>';
|
|
|
|
|
|
|
|
|
|
$message = $object->message;
|
|
|
|
|
if (!dol_textishtml($message)) {
|
|
|
|
|
$message = dol_nl2br($message);
|
|
|
|
|
}
|
|
|
|
|
$message_customer .= '<p>'.$langs->trans('Message').' : <br>'.$message.'</p>';
|
|
|
|
|
$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;
|
|
|
|
|
$message_customer .= '<p>'.$langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer').' : <a href="'.$url_public_ticket.'">'.$url_public_ticket.'</a></p>';
|
|
|
|
|
$message_customer .= '<p>'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'</p>';
|
|
|
|
|
|
|
|
|
|
$from = (empty($conf->global->MAIN_INFO_SOCIETE_NOM) ? '' : $conf->global->MAIN_INFO_SOCIETE_NOM.' ').'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
|
|
|
|
|
$replyto = $from;
|
|
|
|
|
|
|
|
|
|
$trackid = 'tic'.$object->id;
|
|
|
|
|
|
|
|
|
|
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_customer, $filepath, $mimetype, $filename, '', '', 0, -1, '', '', $trackid, '', 'ticket');
|
|
|
|
|
if ($mailfile->error) {
|
|
|
|
|
dol_syslog($mailfile->error, LOG_DEBUG);
|
|
|
|
|
} else {
|
|
|
|
|
$result = $mailfile->sendfile();
|
|
|
|
|
if ($result) {
|
|
|
|
|
// update last_msg_sent date
|
|
|
|
|
$object->date_last_msg_sent = dol_now();
|
|
|
|
|
$object->update($user);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
|
|
|
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
|
|
|
|
}
|
|
|
|
|
$this->composeAndSendCustomerMessage($sendto, $subject_customer, $body_customer, $see_ticket_customer, $object, $langs, $conf);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -305,10 +185,223 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
|
|
|
|
|
|
|
|
|
case 'TICKET_CLOSE':
|
|
|
|
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
|
|
|
|
$langs->load('ticket');
|
|
|
|
|
|
|
|
|
|
$subject_admin = 'TicketCloseEmailSubjectAdmin';
|
|
|
|
|
$body_admin = 'TicketCloseEmailBodyAdmin';
|
|
|
|
|
$subject_customer = 'TicketCloseEmailSubjectCustomer';
|
|
|
|
|
$body_customer = 'TicketCloseEmailBodyCustomer';
|
|
|
|
|
$see_ticket_customer = 'TicketCloseEmailBodyInfosTrackUrlCustomer';
|
|
|
|
|
|
|
|
|
|
// Send email to notification email
|
|
|
|
|
if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && empty($object->context['disableticketemail'])) {
|
|
|
|
|
$sendto = empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) ? '' : $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
|
|
|
|
|
if ($sendto) {
|
|
|
|
|
$this->composeAndSendAdminMessage($sendto, $subject_admin, $body_admin, $object, $langs, $conf);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send email to customer.
|
|
|
|
|
if (empty($conf->global->TICKET_DISABLE_CUSTOMER_MAILS) && empty($object->context['disableticketemail'])) {
|
|
|
|
|
$linked_contacts = $object->listeContact(-1, 'thirdparty');
|
|
|
|
|
$linked_contacts = array_merge($linked_contacts, $object->listeContact(-1, 'internal'));
|
|
|
|
|
if (empty($linked_contacts) && !empty($conf->global->TICKET_NOTIFY_AT_CLOSING) && !empty($object->fk_soc)) {
|
|
|
|
|
$object->fetch_thirdparty();
|
|
|
|
|
$linked_contacts[] = $object->thirdparty->email;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$contactid = GETPOST('contactid', 'int');
|
|
|
|
|
if ($contactid > 0) {
|
|
|
|
|
$contact = new Contact($this->db);
|
|
|
|
|
$res = $contact->fetch($contactid);
|
|
|
|
|
if (! in_array($contact, $linked_contacts)) {
|
|
|
|
|
$error_msg = $langs->trans('Error'). ': ';
|
|
|
|
|
$error_msg .= $langs->transnoentities('TicketWrongContact');
|
|
|
|
|
setEventMessages($error_msg, [], 'errors');
|
|
|
|
|
$ok = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$sendto = '';
|
|
|
|
|
if ($res > 0 && !empty($contact->email) && !empty($contact->statut)) {
|
|
|
|
|
$sendto = $contact->email;
|
|
|
|
|
} elseif ( !empty($linked_contacts) && ($contactid == -2 || (GETPOST('massaction', 'alpha') == 'close' && GETPOST('confirm', 'alpha') == 'yes'))) {
|
|
|
|
|
// if sending to all contacts or sending to contacts while mass closing
|
|
|
|
|
$temp_emails = [];
|
|
|
|
|
foreach ($linked_contacts as $contact) {
|
|
|
|
|
$temp_emails[] = $contact['email'];
|
|
|
|
|
}
|
|
|
|
|
$sendto = implode(", ", $temp_emails);
|
|
|
|
|
unset($temp_emails);
|
|
|
|
|
unset($linked_contacts);
|
|
|
|
|
}
|
|
|
|
|
if ($sendto) {
|
|
|
|
|
$this->composeAndSendCustomerMessage($sendto, $subject_customer, $body_customer, $see_ticket_customer, $object, $langs, $conf);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$ok = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Composes and sends a message concerning a ticket, to be sent to admin address.
|
|
|
|
|
* @param string $sendto Addresses to send the mail, format "first@address.net, second@address.net," etc.
|
|
|
|
|
* @param string $base_subject email subject. Non-translated string.
|
|
|
|
|
* @param string $body email body (first line). Non-translated string.
|
|
|
|
|
* @param Ticket $object the ticket thet the email refers to
|
|
|
|
|
* @param Translate $langs the translation object
|
|
|
|
|
* @param conf $conf Object conf
|
|
|
|
|
*
|
|
|
|
|
* @return none
|
|
|
|
|
*/
|
|
|
|
|
private function composeAndSendAdminMessage($sendto, $base_subject, $body, Ticket $object, Translate $langs, $conf)
|
|
|
|
|
{
|
|
|
|
|
// Init to avoid errors
|
|
|
|
|
$filepath = array();
|
|
|
|
|
$filename = array();
|
|
|
|
|
$mimetype = array();
|
|
|
|
|
|
|
|
|
|
/* Send email to admin */
|
|
|
|
|
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities($base_subject, $object->ref, $object->track_id);
|
|
|
|
|
$message_admin = $langs->transnoentities($body, $object->track_id).'<br>';
|
|
|
|
|
$message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
|
|
|
|
|
$message_admin .= '<li>'.$langs->trans('Type').' : '.$langs->getLabelFromKey($this->db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code).'</li>';
|
|
|
|
|
$message_admin .= '<li>'.$langs->trans('Category').' : '.$langs->getLabelFromKey($this->db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code).'</li>';
|
|
|
|
|
$message_admin .= '<li>'.$langs->trans('Severity').' : '.$langs->getLabelFromKey($this->db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code).'</li>';
|
|
|
|
|
$message_admin .= '<li>'.$langs->trans('From').' : '.($object->email_from ? $object->email_from : ($object->fk_user_create > 0 ? $langs->trans('Internal') : '')).'</li>';
|
|
|
|
|
// Extrafields
|
|
|
|
|
$extraFields = new ExtraFields($this->db);
|
|
|
|
|
$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, '', $object->table_element).'</li>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($object->fk_soc > 0) {
|
|
|
|
|
$object->fetch_thirdparty();
|
|
|
|
|
$message_admin .= '<li>'.$langs->trans('Company').' : '.$object->thirdparty->name.'</li>';
|
|
|
|
|
}
|
|
|
|
|
$message_admin .= '</ul>';
|
|
|
|
|
|
|
|
|
|
$message = $object->message;
|
|
|
|
|
if (!dol_textishtml($message)) {
|
|
|
|
|
$message = dol_nl2br($message);
|
|
|
|
|
}
|
|
|
|
|
$message_admin .= '<p>'.$langs->trans('Message').' : <br><br>'.$message.'</p><br>';
|
|
|
|
|
$message_admin .= '<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
|
|
|
|
|
|
|
|
|
|
$from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
|
|
|
|
|
|
|
|
|
|
$trackid = 'tic'.$object->id;
|
|
|
|
|
|
|
|
|
|
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, '', '', 0, -1, '', '', $trackid, '', 'ticket');
|
|
|
|
|
if ($mailfile->error) {
|
|
|
|
|
dol_syslog($mailfile->error, LOG_DEBUG);
|
|
|
|
|
} else {
|
|
|
|
|
$result = $mailfile->sendfile();
|
|
|
|
|
}
|
|
|
|
|
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
|
|
|
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Composes and sends a message concerning a ticket, to be sent to customer addresses.
|
|
|
|
|
* @param string $sendto Addresses to send the mail, format "first@address.net, second@address.net, " etc.
|
|
|
|
|
* @param string $base_subject email subject. Non-translated string.
|
|
|
|
|
* @param string $body email body (first line). Non-translated string.
|
|
|
|
|
* @param string $see_ticket string indicating the ticket public address
|
|
|
|
|
* @param Ticket $object the ticket thet the email refers to
|
|
|
|
|
* @param Translate $langs the translation object
|
|
|
|
|
* @param conf $conf Object conf
|
|
|
|
|
*
|
|
|
|
|
* @return none
|
|
|
|
|
*/
|
|
|
|
|
private function composeAndSendCustomerMessage($sendto, $base_subject, $body, $see_ticket, Ticket $object, Translate $langs, $conf)
|
|
|
|
|
{
|
|
|
|
|
// Init to avoid errors
|
|
|
|
|
$filepath = array();
|
|
|
|
|
$filename = array();
|
|
|
|
|
$mimetype = array();
|
|
|
|
|
|
|
|
|
|
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities($base_subject);
|
|
|
|
|
$message_customer = $langs->transnoentities($body, $object->track_id).'<br>';
|
|
|
|
|
$message_customer .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
|
|
|
|
|
$message_customer .= '<li>'.$langs->trans('Type').' : '.$langs->getLabelFromKey($this->db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code).'</li>';
|
|
|
|
|
$message_customer .= '<li>'.$langs->trans('Category').' : '.$langs->getLabelFromKey($this->db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code).'</li>';
|
|
|
|
|
$message_customer .= '<li>'.$langs->trans('Severity').' : '.$langs->getLabelFromKey($this->db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code).'</li>';
|
|
|
|
|
|
|
|
|
|
// Extrafields
|
|
|
|
|
if (is_array($this->attributes[$object->table_element]['label'])) {
|
|
|
|
|
foreach ($this->attributes[$object->table_element]['label'] as $key => $value) {
|
|
|
|
|
$enabled = 1;
|
|
|
|
|
if ($enabled && isset($this->attributes[$object->table_element]['list'][$key])) {
|
|
|
|
|
$enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1);
|
|
|
|
|
}
|
|
|
|
|
$perms = 1;
|
|
|
|
|
if ($perms && isset($this->attributes[$object->table_element]['perms'][$key])) {
|
|
|
|
|
$perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$qualified = true;
|
|
|
|
|
if (empty($enabled)) {
|
|
|
|
|
$qualified = false;
|
|
|
|
|
}
|
|
|
|
|
if (empty($perms)) {
|
|
|
|
|
$qualified = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($qualified) {
|
|
|
|
|
$message_customer .= '<li>' . $langs->trans($key) . ' : ' . $value . '</li>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$message_customer .= '</ul>';
|
|
|
|
|
|
|
|
|
|
$message = $object->message;
|
|
|
|
|
if (!dol_textishtml($message)) {
|
|
|
|
|
$message = dol_nl2br($message);
|
|
|
|
|
}
|
|
|
|
|
$message_customer .= '<p>'.$langs->trans('Message').' : <br><br>'.$message.'</p><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;
|
|
|
|
|
$message_customer .= '<p>'.$langs->trans($see_ticket).' : <a href="'.$url_public_ticket.'">'.$url_public_ticket.'</a></p>';
|
|
|
|
|
$message_customer .= '<p>'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'</p>';
|
|
|
|
|
|
|
|
|
|
$from = (empty($conf->global->MAIN_INFO_SOCIETE_NOM) ? '' : $conf->global->MAIN_INFO_SOCIETE_NOM.' ').'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
|
|
|
|
|
|
|
|
|
|
$trackid = 'tic'.$object->id;
|
|
|
|
|
|
|
|
|
|
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_customer, $filepath, $mimetype, $filename, '', '', 0, -1, '', '', $trackid, '', 'ticket');
|
|
|
|
|
if ($mailfile->error) {
|
|
|
|
|
dol_syslog($mailfile->error, LOG_DEBUG);
|
|
|
|
|
} else {
|
|
|
|
|
$result = $mailfile->sendfile();
|
|
|
|
|
if ($result) {
|
|
|
|
|
// update last_msg_sent date
|
|
|
|
|
$object->fetch($object->id);
|
|
|
|
|
$object->date_last_msg_sent = dol_now();
|
|
|
|
|
$object->update($user);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
|
|
|
|
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|