From 8acc752195711dba1c6df6ef6aa85b4224d9698e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 19 Apr 2018 14:44:21 +0200 Subject: [PATCH] Debug ticket module --- htdocs/admin/ticketsup.php | 82 +++-- .../core/class/html.formticketsup.class.php | 12 +- ...face_50_modTicketsup_TicketEmail.class.php | 322 +++++++++--------- htdocs/public/ticketsup/create_ticket.php | 5 +- htdocs/ticketsup/new.php | 2 +- 5 files changed, 229 insertions(+), 194 deletions(-) diff --git a/htdocs/admin/ticketsup.php b/htdocs/admin/ticketsup.php index 7a3ddf7826b..4040964d2fe 100644 --- a/htdocs/admin/ticketsup.php +++ b/htdocs/admin/ticketsup.php @@ -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 ''; print ''; -// Show logo for module -print '' . $langs->trans("TicketsShowModuleLogo") . ''; -print ''; -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 '' . $langs->trans("TicketsShowModuleLogo") . ''; + print ''; + 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 ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketsShowModuleLogoHelp"), 1, 'help'); + print ''; + print ''; } -print ''; -print ''; -print $form->textwithpicto('', $langs->trans("TicketsShowModuleLogoHelp"), 1, 'help'); -print ''; -print ''; // Show logo for company print '' . $langs->trans("TicketsShowCompanyLogo") . ''; @@ -446,19 +455,22 @@ print ''; print ''; // Also send to main email address -print '' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . ''; -print ''; -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 '' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . ''; + print ''; + 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 ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); + print ''; + print ''; } -print ''; -print ''; -print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); -print ''; -print ''; // Limiter la vue des tickets à ceux assignés à l'utilisateur print '' . $langs->trans("TicketsLimitViewAssignedOnly") . ''; diff --git a/htdocs/core/class/html.formticketsup.class.php b/htdocs/core/class/html.formticketsup.class.php index 7248e2b9a8e..732d495efb2 100644 --- a/htdocs/core/class/html.formticketsup.class.php +++ b/htdocs/core/class/html.formticketsup.class.php @@ -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\n"; - print '
'; + if ($withdolfichehead) dol_fiche_head(null, 'card', '', 0, ''); + + print ''; print ''; print ''; foreach ($this->param as $key => $value) { @@ -149,7 +151,7 @@ class FormTicketsup print ''; print '
'; - print ''; + print '
'; if ($this->withref) { @@ -394,6 +396,8 @@ class FormTicketsup print '
'; print '
'; + if ($withdolfichehead) dol_fiche_end(); + print '
'; print ''; diff --git a/htdocs/core/triggers/interface_50_modTicketsup_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicketsup_TicketEmail.class.php index 96be9ba9c74..d46738d4318 100644 --- a/htdocs/core/triggers/interface_50_modTicketsup_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicketsup_TicketEmail.class.php @@ -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 = '

' . $langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname)) . "

"; - $message .= '
  • ' . $langs->trans('Title') . ' : ' . $object->subject . '
  • '; - $message .= '
  • ' . $langs->trans('Type') . ' : ' . $object->type_label . '
  • '; - $message .= '
  • ' . $langs->trans('Category') . ' : ' . $object->category_label . '
  • '; - $message .= '
  • ' . $langs->trans('Severity') . ' : ' . $object->severity_label . '
  • '; - // Extrafields - if (is_array($object->array_options) && count($object->array_options) > 0) { - foreach ($object->array_options as $key => $value) { - $message .= '
  • ' . $langs->trans($key) . ' : ' . $value . '
  • '; + 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 = '

    ' . $langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname)) . "

    "; + $message .= '
    • ' . $langs->trans('Title') . ' : ' . $object->subject . '
    • '; + $message .= '
    • ' . $langs->trans('Type') . ' : ' . $object->type_label . '
    • '; + $message .= '
    • ' . $langs->trans('Category') . ' : ' . $object->category_label . '
    • '; + $message .= '
    • ' . $langs->trans('Severity') . ' : ' . $object->severity_label . '
    • '; + // Extrafields + if (is_array($object->array_options) && count($object->array_options) > 0) { + foreach ($object->array_options as $key => $value) { + $message .= '
    • ' . $langs->trans($key) . ' : ' . $value . '
    • '; + } + } + + $message .= '
    '; + $message .= '

    ' . $langs->trans('Message') . ' :
    ' . $object->message . '

    '; + $message .= '

    ' . $langs->trans('SeeThisTicketIntomanagementInterface') . '

    '; + + $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 .= '
'; - $message .= '

' . $langs->trans('Message') . ' :
' . $object->message . '

'; - $message .= '

' . $langs->trans('SeeThisTicketIntomanagementInterface') . '

'; - - $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.='
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; - $message_admin.='
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; - $message_admin.='
  • '.$langs->trans('Category').' : '.$object->category_label.'
  • '; - $message_admin.='
  • '.$langs->trans('Severity').' : '.$object->severity_label.'
  • '; - $message_admin.='
  • '.$langs->trans('From').' : '.( $object->email_from ? $object->email_from : ( $object->fk_user_create > 0 ? $langs->trans('Internal') : '') ).'
  • '; - // Extrafields - if (is_array($object->array_options) && count($object->array_options) > 0) { - foreach ($object->array_options as $key => $value) { - $message_admin.='
  • '.$langs->trans($key).' : '.$value.'
  • '; - } - } - $message_admin.='
'; - - if ($object->fk_soc > 0) { - $object->fetch_thirdparty(); - $message_admin.='

'.$langs->trans('Company'). ' : '.$object->thirdparty->name.'

'; - } - - $message_admin.='

'.$langs->trans('Message').' :
'.$object->message.'

'; - $message_admin.='

'.$langs->trans('SeeThisTicketIntomanagementInterface').'

'; - - $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.='
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; - $message_customer.='
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; - $message_customer.='
  • '.$langs->trans('Category').' : '.$object->category_label.'
  • '; - $message_customer.='
  • '.$langs->trans('Severity').' : '.$object->severity_label.'
  • '; + 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.='
    • '.$langs->trans('Title').' : '.$object->subject.'
    • '; + $message_admin.='
    • '.$langs->trans('Type').' : '.$object->type_label.'
    • '; + $message_admin.='
    • '.$langs->trans('Category').' : '.$object->category_label.'
    • '; + $message_admin.='
    • '.$langs->trans('Severity').' : '.$object->severity_label.'
    • '; + $message_admin.='
    • '.$langs->trans('From').' : '.( $object->email_from ? $object->email_from : ( $object->fk_user_create > 0 ? $langs->trans('Internal') : '') ).'
    • '; // 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.='
    • '.$langs->trans($key).' : '.$value.'
    • '; + } + } + $message_admin.='
    '; - $qualified = true; - if (empty($enabled)) $qualified = false; - if (empty($perms)) $qualified = false; - - if ($qualified) $message_customer.='
  • '.$langs->trans($key).' : '.$value.'
  • '; + if ($object->fk_soc > 0) { + $object->fetch_thirdparty(); + $message_admin.='

    '.$langs->trans('Company'). ' : '.$object->thirdparty->name.'

    '; } - - $message_customer.='
'; - $message_customer.='

'.$langs->trans('Message').' :
'.$object->message.'

'; - $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.='

' . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : '.$url_public_ticket.'

'; - $message_customer.='

'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'

'; - + $message_admin.='

'.$langs->trans('Message').' :
'.$object->message.'

'; + $message_admin.='

'.$langs->trans('SeeThisTicketIntomanagementInterface').'

'; $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.='
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; + $message_customer.='
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; + $message_customer.='
  • '.$langs->trans('Category').' : '.$object->category_label.'
  • '; + $message_customer.='
  • '.$langs->trans('Severity').' : '.$object->severity_label.'
  • '; + + // 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.='
  • '.$langs->trans($key).' : '.$value.'
  • '; + } + + $message_customer.='
'; + $message_customer.='

'.$langs->trans('Message').' :
'.$object->message.'

'; + $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.='

' . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : '.$url_public_ticket.'

'; + $message_customer.='

'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'

'; + + $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': diff --git a/htdocs/public/ticketsup/create_ticket.php b/htdocs/public/ticketsup/create_ticket.php index 8c8a0dd2f60..7dc6da87bcc 100644 --- a/htdocs/public/ticketsup/create_ticket.php +++ b/htdocs/public/ticketsup/create_ticket.php @@ -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); diff --git a/htdocs/ticketsup/new.php b/htdocs/ticketsup/new.php index 0428f5286c2..9fe7411186a 100644 --- a/htdocs/ticketsup/new.php +++ b/htdocs/ticketsup/new.php @@ -88,7 +88,7 @@ if ($action == 'create_ticket') { $defaultref = ''; } - $formticket->showForm(); + $formticket->showForm(1); } //$somethingshown=$object->showLinkedObjectBlock();