Debug ticket module
This commit is contained in:
parent
8aab183567
commit
8acc752195
@ -71,7 +71,7 @@ if ($action == 'updateMask') {
|
||||
if (!empty($notification_email)) {
|
||||
$res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity);
|
||||
} else {
|
||||
$res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_FROM', '000000', 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
if (!$res > 0) {
|
||||
$error++;
|
||||
@ -82,7 +82,7 @@ if ($action == 'updateMask') {
|
||||
if (!empty($notification_email_to)) {
|
||||
$res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity);
|
||||
} else {
|
||||
$res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_TO', '000000', 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
if (!$res > 0) {
|
||||
$error++;
|
||||
@ -184,16 +184,22 @@ if ($action == 'setvarother') {
|
||||
$error++;
|
||||
}
|
||||
|
||||
$param_show_module_logo = GETPOST('TICKETS_SHOW_MODULE_LOGO', 'alpha');
|
||||
$res = dolibarr_set_const($db, 'TICKETS_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity);
|
||||
if (!$res > 0) {
|
||||
$error++;
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
||||
{
|
||||
$param_show_module_logo = GETPOST('TICKETS_SHOW_MODULE_LOGO', 'alpha');
|
||||
$res = dolibarr_set_const($db, 'TICKETS_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity);
|
||||
if (!$res > 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
$param_notification_also_main_addressemail = GETPOST('TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha');
|
||||
$res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity);
|
||||
if (!$res > 0) {
|
||||
$error++;
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
||||
{
|
||||
$param_notification_also_main_addressemail = GETPOST('TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha');
|
||||
$res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity);
|
||||
if (!$res > 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
$param_limit_view = GETPOST('TICKETS_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha');
|
||||
@ -380,20 +386,23 @@ print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'h
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Show logo for module
|
||||
print '<tr class="pair"><td width="70%">' . $langs->trans("TicketsShowModuleLogo") . '</td>';
|
||||
print '<td align="left">';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print ajax_constantonoff('TICKETS_SHOW_MODULE_LOGO');
|
||||
} else {
|
||||
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
|
||||
print $form->selectarray("TICKETS_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKETS_SHOW_MODULE_LOGO);
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
||||
{
|
||||
// Show logo for module
|
||||
print '<tr class="pair"><td width="70%">' . $langs->trans("TicketsShowModuleLogo") . '</td>';
|
||||
print '<td align="left">';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print ajax_constantonoff('TICKETS_SHOW_MODULE_LOGO');
|
||||
} else {
|
||||
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
|
||||
print $form->selectarray("TICKETS_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKETS_SHOW_MODULE_LOGO);
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('', $langs->trans("TicketsShowModuleLogoHelp"), 1, 'help');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('', $langs->trans("TicketsShowModuleLogoHelp"), 1, 'help');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Show logo for company
|
||||
print '<tr class="pair"><td width="70%">' . $langs->trans("TicketsShowCompanyLogo") . '</td>';
|
||||
@ -446,19 +455,22 @@ print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Also send to main email address
|
||||
print '<tr class="pair"><td width="70%">' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . '</td>';
|
||||
print '<td align="left">';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print ajax_constantonoff('TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS');
|
||||
} else {
|
||||
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
|
||||
print $form->selectarray("TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS);
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
||||
{
|
||||
print '<tr class="pair"><td width="70%">' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . '</td>';
|
||||
print '<td align="left">';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print ajax_constantonoff('TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS');
|
||||
} else {
|
||||
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
|
||||
print $form->selectarray("TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS);
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Limiter la vue des tickets à ceux assignés à l'utilisateur
|
||||
print '<tr class="pair"><td width="70%">' . $langs->trans("TicketsLimitViewAssignedOnly") . '</td>';
|
||||
|
||||
@ -113,10 +113,10 @@ class FormTicketsup
|
||||
/**
|
||||
* Show the form to input ticket
|
||||
*
|
||||
* @param string $width Width of form
|
||||
* @param int $withdolfichehead With dol_fiche_head
|
||||
* @return void
|
||||
*/
|
||||
public function showForm($width = '100%')
|
||||
public function showForm($withdolfichehead=0)
|
||||
{
|
||||
global $conf, $langs, $user, $hookmanager;
|
||||
|
||||
@ -140,7 +140,9 @@ class FormTicketsup
|
||||
|
||||
print "\n<!-- Begin form TICKETSUP -->\n";
|
||||
|
||||
print '<form method="POST" style="margin-bottom: 30px;" name="ticketsup" id="form_create_ticket" enctype="multipart/form-data" action="' . $this->param["returnurl"] . '">';
|
||||
if ($withdolfichehead) dol_fiche_head(null, 'card', '', 0, '');
|
||||
|
||||
print '<form method="POST" '.($withdolfichehead?'':'style="margin-bottom: 30px;" ').'name="ticketsup" id="form_create_ticket" enctype="multipart/form-data" action="' . $this->param["returnurl"] . '">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<input type="hidden" name="action" value="' . $this->action . '">';
|
||||
foreach ($this->param as $key => $value) {
|
||||
@ -149,7 +151,7 @@ class FormTicketsup
|
||||
print '<input type="hidden" name="fk_user_create" value="' . $this->fk_user_create . '">';
|
||||
|
||||
print '<div class="">';
|
||||
print '<table class="tableticket" width="' . $width . '">';
|
||||
print '<table class="tableticket centpercent">';
|
||||
|
||||
|
||||
if ($this->withref) {
|
||||
@ -394,6 +396,8 @@ class FormTicketsup
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
if ($withdolfichehead) dol_fiche_end();
|
||||
|
||||
print '<center>';
|
||||
print '<input class="button" type="submit" name="add_ticket" value="' . $langs->trans(($this->withthreadid > 0 ? "SendResponse" : "NewTicket")) . '" />';
|
||||
|
||||
|
||||
@ -110,189 +110,205 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
||||
case 'TICKET_ASSIGNED':
|
||||
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 && $object->fk_user_assign != $user->id)
|
||||
{
|
||||
$userstat = new User($this->db);
|
||||
$res = $userstat->fetch($object->fk_user_assign);
|
||||
if ($res) {
|
||||
// Send email to assigned user
|
||||
$subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketAssignedToYou');
|
||||
$message = '<p>' . $langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname)) . "</p>";
|
||||
$message .= '<ul><li>' . $langs->trans('Title') . ' : ' . $object->subject . '</li>';
|
||||
$message .= '<li>' . $langs->trans('Type') . ' : ' . $object->type_label . '</li>';
|
||||
$message .= '<li>' . $langs->trans('Category') . ' : ' . $object->category_label . '</li>';
|
||||
$message .= '<li>' . $langs->trans('Severity') . ' : ' . $object->severity_label . '</li>';
|
||||
// Extrafields
|
||||
if (is_array($object->array_options) && count($object->array_options) > 0) {
|
||||
foreach ($object->array_options as $key => $value) {
|
||||
$message .= '<li>' . $langs->trans($key) . ' : ' . $value . '</li>';
|
||||
if ($res > 0)
|
||||
{
|
||||
if (empty($conf->global->TICKETS_DISABLE_ALL_MAILS))
|
||||
{
|
||||
// Init to avoid errors
|
||||
$filepath = array();
|
||||
$filename = array();
|
||||
$mimetype = array();
|
||||
|
||||
// Send email to assigned user
|
||||
$subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketAssignedToYou');
|
||||
$message = '<p>' . $langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname)) . "</p>";
|
||||
$message .= '<ul><li>' . $langs->trans('Title') . ' : ' . $object->subject . '</li>';
|
||||
$message .= '<li>' . $langs->trans('Type') . ' : ' . $object->type_label . '</li>';
|
||||
$message .= '<li>' . $langs->trans('Category') . ' : ' . $object->category_label . '</li>';
|
||||
$message .= '<li>' . $langs->trans('Severity') . ' : ' . $object->severity_label . '</li>';
|
||||
// Extrafields
|
||||
if (is_array($object->array_options) && count($object->array_options) > 0) {
|
||||
foreach ($object->array_options as $key => $value) {
|
||||
$message .= '<li>' . $langs->trans($key) . ' : ' . $value . '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
$message .= '</ul>';
|
||||
$message .= '<p>' . $langs->trans('Message') . ' : <br>' . $object->message . '</p>';
|
||||
$message .= '<p><a href="' . dol_buildpath('/ticketsup/card.php', 2) . '?track_id=' . $object->track_id . '">' . $langs->trans('SeeThisTicketIntomanagementInterface') . '</a></p>';
|
||||
|
||||
$sendto = $userstat->email;
|
||||
$from = dolGetFirstLastname($user->firstname, $user->lastname) . '<' . $user->email . '>';
|
||||
|
||||
$message = dol_nl2br($message);
|
||||
|
||||
if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
|
||||
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
|
||||
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
|
||||
}
|
||||
}
|
||||
|
||||
$message .= '</ul>';
|
||||
$message .= '<p>' . $langs->trans('Message') . ' : <br>' . $object->message . '</p>';
|
||||
$message .= '<p><a href="' . dol_buildpath('/ticketsup/card.php', 2) . '?track_id=' . $object->track_id . '">' . $langs->trans('SeeThisTicketIntomanagementInterface') . '</a></p>';
|
||||
|
||||
$sendto = $userstat->email;
|
||||
$from = dolGetFirstLastname($user->firstname, $user->lastname) . '<' . $user->email . '>';
|
||||
|
||||
// Init to avoid errors
|
||||
$filepath = array();
|
||||
$filename = array();
|
||||
$mimetype = array();
|
||||
|
||||
$message = dol_nl2br($message);
|
||||
|
||||
if (!empty($conf->global->TICKETS_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, '', '', 0, -1);
|
||||
if ($mailfile->error) {
|
||||
setEventMessage($mailfile->error, 'errors');
|
||||
} else {
|
||||
$result = $mailfile->sendfile();
|
||||
}
|
||||
if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
|
||||
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
||||
}
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
|
||||
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1);
|
||||
if ($mailfile->error) {
|
||||
setEventMessage($mailfile->error, 'errors');
|
||||
} else {
|
||||
$result = $mailfile->sendfile();
|
||||
}
|
||||
if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
|
||||
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
||||
}
|
||||
}
|
||||
|
||||
$ok = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $userstat->error;
|
||||
$this->errors = $userstat->errors;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'TICKET_CREATE':
|
||||
dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
||||
|
||||
// Init to avoid errors
|
||||
$filepath = array();
|
||||
$filename = array();
|
||||
$mimetype = array();
|
||||
|
||||
$langs->load('ticketsup');
|
||||
|
||||
$object->fetch('', $object->track_id);
|
||||
$object->fetch('', $object->track_id); // Should be useless
|
||||
|
||||
|
||||
// Send email to notification email
|
||||
|
||||
/* Send email to admin */
|
||||
$sendto = $conf->global->TICKETS_NOTIFICATION_EMAIL_TO;
|
||||
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin');
|
||||
$message_admin= $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
|
||||
$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->email_from ? $object->email_from : ( $object->fk_user_create > 0 ? $langs->trans('Internal') : '') ).'</li>';
|
||||
// Extrafields
|
||||
if (is_array($object->array_options) && count($object->array_options) > 0) {
|
||||
foreach ($object->array_options as $key => $value) {
|
||||
$message_admin.='<li>'.$langs->trans($key).' : '.$value.'</li>';
|
||||
}
|
||||
}
|
||||
$message_admin.='</ul>';
|
||||
|
||||
if ($object->fk_soc > 0) {
|
||||
$object->fetch_thirdparty();
|
||||
$message_admin.='<p>'.$langs->trans('Company'). ' : '.$object->thirdparty->name.'</p>';
|
||||
}
|
||||
|
||||
$message_admin.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
|
||||
$message_admin.='<p><a href="'.dol_buildpath('/ticketsup/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
|
||||
|
||||
$from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKETS_NOTIFICATION_EMAIL_FROM.'>';
|
||||
$replyto = $from;
|
||||
|
||||
$message_admin = dol_nl2br($message_admin);
|
||||
|
||||
if (!empty($conf->global->TICKETS_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);
|
||||
if ($mailfile->error) {
|
||||
dol_syslog($mailfile->error, LOG_DEBUG);
|
||||
} else {
|
||||
$result=$mailfile->sendfile();
|
||||
}
|
||||
if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
|
||||
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
||||
}
|
||||
|
||||
/* Send email to customer */
|
||||
$sendto = '';
|
||||
if (empty($user->socid) && empty($user->email)) {
|
||||
$object->fetch_thirdparty();
|
||||
$sendto = $object->thirdparty->email;
|
||||
} else {
|
||||
$sendto = $user->email;
|
||||
}
|
||||
|
||||
if ($sendto && $object->notify_tiers_at_create) {
|
||||
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer');
|
||||
$message_customer= $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id)."\n\n";
|
||||
$message_customer.='<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
|
||||
$message_customer.='<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
|
||||
$message_customer.='<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
|
||||
$message_customer.='<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
|
||||
if (empty($conf->global->TICKETS_DISABLE_ALL_MAILS) && $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)."\n\n";
|
||||
$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->email_from ? $object->email_from : ( $object->fk_user_create > 0 ? $langs->trans('Internal') : '') ).'</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);
|
||||
}
|
||||
if (is_array($object->array_options) && count($object->array_options) > 0) {
|
||||
foreach ($object->array_options as $key => $value) {
|
||||
$message_admin.='<li>'.$langs->trans($key).' : '.$value.'</li>';
|
||||
}
|
||||
}
|
||||
$message_admin.='</ul>';
|
||||
|
||||
$qualified = true;
|
||||
if (empty($enabled)) $qualified = false;
|
||||
if (empty($perms)) $qualified = false;
|
||||
|
||||
if ($qualified) $message_customer.='<li>'.$langs->trans($key).' : '.$value.'</li>';
|
||||
if ($object->fk_soc > 0) {
|
||||
$object->fetch_thirdparty();
|
||||
$message_admin.='<p>'.$langs->trans('Company'). ' : '.$object->thirdparty->name.'</p>';
|
||||
}
|
||||
|
||||
|
||||
$message_customer.='</ul>';
|
||||
$message_customer.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
|
||||
$url_public_ticket = ($conf->global->TICKETS_URL_PUBLIC_INTERFACE?$conf->global->TICKETS_URL_PUBLIC_INTERFACE.'/':dol_buildpath('/ticketsup/public/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>';
|
||||
|
||||
$message_admin.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
|
||||
$message_admin.='<p><a href="'.dol_buildpath('/ticketsup/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
|
||||
|
||||
$from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKETS_NOTIFICATION_EMAIL_FROM.'>';
|
||||
$replyto = $from;
|
||||
|
||||
// Init to avoid errors
|
||||
$filepath = array();
|
||||
$filename = array();
|
||||
$mimetype = array();
|
||||
$message_admin = dol_nl2br($message_admin);
|
||||
|
||||
$message_customer = dol_nl2br($message_customer);
|
||||
|
||||
if (!empty($conf->global->TICKETS_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, $sendtocc, '', $deliveryreceipt, -1);
|
||||
if (!empty($conf->global->TICKETS_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);
|
||||
if ($mailfile->error) {
|
||||
dol_syslog($mailfile->error, LOG_DEBUG);
|
||||
dol_syslog($mailfile->error, LOG_DEBUG);
|
||||
} else {
|
||||
$result=$mailfile->sendfile();
|
||||
$result=$mailfile->sendfile();
|
||||
}
|
||||
if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
|
||||
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
||||
}
|
||||
}
|
||||
$ok = 1;
|
||||
if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
|
||||
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
||||
}
|
||||
}
|
||||
|
||||
// Send email to customer
|
||||
|
||||
if (empty($conf->global->TICKETS_DISABLE_ALL_MAILS) && empty($object->context['disableemailtothirdparty']) && $object->notify_tiers_at_create)
|
||||
{
|
||||
$sendto = '';
|
||||
if (empty($user->socid) && empty($user->email)) {
|
||||
$object->fetch_thirdparty();
|
||||
$sendto = $object->thirdparty->email;
|
||||
} else {
|
||||
$sendto = $user->email;
|
||||
}
|
||||
|
||||
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)."\n\n";
|
||||
$message_customer.='<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
|
||||
$message_customer.='<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
|
||||
$message_customer.='<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
|
||||
$message_customer.='<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</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_customer.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
|
||||
$url_public_ticket = ($conf->global->TICKETS_URL_PUBLIC_INTERFACE?$conf->global->TICKETS_URL_PUBLIC_INTERFACE.'/':dol_buildpath('/ticketsup/public/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 = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKETS_NOTIFICATION_EMAIL_FROM.'>';
|
||||
$replyto = $from;
|
||||
|
||||
$message_customer = dol_nl2br($message_customer);
|
||||
|
||||
if (!empty($conf->global->TICKETS_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, $sendtocc, '', $deliveryreceipt, -1);
|
||||
if ($mailfile->error) {
|
||||
dol_syslog($mailfile->error, LOG_DEBUG);
|
||||
} else {
|
||||
$result=$mailfile->sendfile();
|
||||
}
|
||||
if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
|
||||
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
||||
}
|
||||
}
|
||||
}
|
||||
$ok = 1;
|
||||
break;
|
||||
|
||||
case 'TICKET_DELETE':
|
||||
|
||||
@ -175,7 +175,10 @@ if ($action == 'create_ticket' && GETPOST('add_ticket')) {
|
||||
if (!is_object($user)) {
|
||||
$user = new User($db);
|
||||
}
|
||||
$id = $object->create($user, 1); // Disable trigger for email (send by this page)
|
||||
|
||||
$object->context['disableemailtothirdparty']=1; // Disable email sent by ticketsup trigger when creation is done from this page
|
||||
|
||||
$id = $object->create($user);
|
||||
if ($id <= 0) {
|
||||
$error++;
|
||||
$errors = ($object->error ? array($object->error) : $object->errors);
|
||||
|
||||
@ -88,7 +88,7 @@ if ($action == 'create_ticket') {
|
||||
$defaultref = '';
|
||||
}
|
||||
|
||||
$formticket->showForm();
|
||||
$formticket->showForm(1);
|
||||
}
|
||||
|
||||
//$somethingshown=$object->showLinkedObjectBlock();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user