Skip to content

Commit

Permalink
FIX Debug option not working replaced by the one that works.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Nov 21, 2024
1 parent 4c95fa2 commit 9a5aea0
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 55 deletions.
31 changes: 28 additions & 3 deletions htdocs/admin/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@

include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';

if (GETPOSTISSET('TICKET_CHECK_NOTIFY_THIRDPARTY_AT_CREATION')) { // only for no js case
$param_disable_email = GETPOST('TICKET_CHECK_NOTIFY_THIRDPARTY_AT_CREATION', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_CHECK_NOTIFY_THIRDPARTY_AT_CREATION', $param_disable_email, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
}
}

if ($action == 'updateMask') {
$maskconstticket = GETPOST('maskconstticket', 'aZ09');
$maskticket = GETPOST('maskticket', 'alpha');
Expand Down Expand Up @@ -595,13 +604,14 @@

print '</form>';

print '<br>';

/*
* Notification
* Emails
*/

// Admin var of module
print load_fiche_titre($langs->trans("Notification"), '', '');
print load_fiche_titre($langs->trans("Emails"), '', '');

print '<table class="noborder centpercent">';

Expand Down Expand Up @@ -636,12 +646,27 @@
// Email for notification of TICKET_CREATE
print '<tr class="oddeven"><td>'.$langs->trans("TicketEmailNotificationTo").'</td>';
print '<td class="left">';
print '<input type="text" class="minwidth200" name="TICKET_NOTIFICATION_EMAIL_TO" value="'.(getDolGlobalString('TICKET_NOTIFICATION_EMAIL_TO') ? $conf->global->TICKET_NOTIFICATION_EMAIL_TO : '').'"></td>';
print '<input type="text" class="minwidth200" name="TICKET_NOTIFICATION_EMAIL_TO" value="'.getDolGlobalString('TICKET_NOTIFICATION_EMAIL_TO').'"></td>';
print '<td class="center">';
print $formcategory->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help');
print '</td>';
print '</tr>';

// Disable email to customers
print '<tr class="pair"><td>';
print $form->textwithpicto($langs->trans("TicketsNotifyThirdPartyFromBackOfficeByDefault"), $langs->trans("TicketsNotifyThirdPartyFromBackOfficeByDefaultHelp"), 1, 'help');
print '</td>';
print '<td class="left">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_CHECK_NOTIFY_THIRDPARTY_AT_CREATION');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_CHECK_NOTIFY_THIRDPARTY_AT_CREATION", $arrval, getDolGlobalInt('TICKET_CHECK_NOTIFY_THIRDPARTY_AT_CREATION'));
}
print '</td>';
print '<td></td>';
print '</tr>';

// Message header
$mail_intro = getDolGlobalString('TICKET_MESSAGE_MAIL_INTRO', '');
print '<tr class="oddeven"><td>'.$langs->trans("TicketMessageMailIntro");
Expand Down
56 changes: 16 additions & 40 deletions htdocs/admin/ticket_public.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@
}
}

if (GETPOSTISSET('TICKET_DISABLE_CUSTOMER_MAILS')) { // only for no js case
$param_disable_email = GETPOST('TICKET_DISABLE_CUSTOMER_MAILS', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_DISABLE_CUSTOMER_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
$errors[] = $db->lasterror();
}
}

if (GETPOSTISSET('TICKET_SHOW_COMPANY_LOGO')) { // only for no js case
$param_show_module_logo = GETPOST('TICKET_SHOW_COMPANY_LOGO', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_SHOW_COMPANY_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity);
Expand Down Expand Up @@ -412,23 +403,6 @@
print '</td>';
print '</tr>';

// Also send to main email address
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
print '<tr class="oddeven"><td>'.$langs->trans("TicketsEmailAlsoSendToMainAddress").'</td>';
print '<td class="left">';
if (!empty($conf->use_javascript_ajax)) {
print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, getDolGlobalInt('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'));
}
print '</td>';
print '<td class="center width75">';
print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp", $langs->transnoentitiesnoconv("TicketEmailNotificationTo").' ('.$langs->transnoentitiesnoconv("Creation").')', $langs->trans("Settings")), 1, 'help');
print '</td>';
print '</tr>';
}

if (empty($conf->use_javascript_ajax)) {
print '<tr class="impair"><td colspan="3" align="center"><input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></td>';
print '</tr>';
Expand Down Expand Up @@ -493,20 +467,6 @@
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';

// Activate email creation to user
print '<tr class="pair"><td>';
print $form->textwithpicto($langs->trans("TicketsDisableCustomerEmail"), $langs->trans("TicketsDisableEmailHelp"), 1, 'help');
print '</td>';
print '<td class="left">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_DISABLE_CUSTOMER_MAILS", $arrval, getDolGlobalInt('TICKET_DISABLE_CUSTOMER_MAILS'));
}
print '</td>';
print '</tr>';

// Text of email after creatio of a ticket
$mail_mesg_new = getDolGlobalString("TICKET_MESSAGE_MAIL_NEW", $langs->trans('TicketNewEmailBody'));
print '<tr><td>';
Expand Down Expand Up @@ -541,6 +501,22 @@
print '</td>';
print '</tr>';

// Also send to main email address
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
print '<tr class="oddeven"><td>'.$langs->trans("TicketsEmailAlsoSendToMainAddress");
print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp", $langs->transnoentitiesnoconv("TicketEmailNotificationTo").' ('.$langs->transnoentitiesnoconv("Creation").')', $langs->trans("Settings")), 1, 'help');
print '</td>';
print '<td class="left">';
if (!empty($conf->use_javascript_ajax)) {
print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, getDolGlobalInt('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'));
}
print '</td>';
print '</tr>';
}

print '</table>';
print '</div>';

Expand Down
18 changes: 12 additions & 6 deletions htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,19 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
$see_ticket_customer = 'TicketNewEmailBodyInfosTrackUrlCustomer';

// Send email to notification email
// Note: $object->context['disableticketemail'] is set to 1 by public interface at creation because email sending is already managed by page
// $object->context['createdfrompublicinterface'] may also be defined when creation done from public interface
if (getDolGlobalString('TICKET_NOTIFICATION_EMAIL_TO') && empty($object->context['disableticketemail'])) {
$sendto = !getDolGlobalString('TICKET_NOTIFICATION_EMAIL_TO') ? '' : $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
$sendto = getDolGlobalString('TICKET_NOTIFICATION_EMAIL_TO');
if ($sendto) {
$this->composeAndSendAdminMessage($sendto, $subject_admin, $body_admin, $object, $langs);
}
}

// Send email to customer
if (!getDolGlobalInt('TICKET_DISABLE_CUSTOMER_MAILS') && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) {
// Note: $object->context['disableticketemail'] is set to 1 by public interface at creation because email sending is already managed by page
// $object->context['createdfrompublicinterface'] may also be defined when creation done from public interface
if (empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) {
$sendto = '';

// if contact selected send to email's contact else send to email's thirdparty
Expand Down Expand Up @@ -238,15 +242,17 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
$see_ticket_customer = 'TicketCloseEmailBodyInfosTrackUrlCustomer';

// Send email to notification email
// Note: $object->context['disableticketemail'] is set to 1 by public interface at creation but not at closing
if (getDolGlobalString('TICKET_NOTIFICATION_EMAIL_TO') && empty($object->context['disableticketemail'])) {
$sendto = !getDolGlobalString('TICKET_NOTIFICATION_EMAIL_TO') ? '' : $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
$sendto = getDolGlobalString('TICKET_NOTIFICATION_EMAIL_TO');
if ($sendto) {
$this->composeAndSendAdminMessage($sendto, $subject_admin, $body_admin, $object, $langs);
}
}

// Send email to customer.
if (!getDolGlobalString('TICKET_DISABLE_CUSTOMER_MAILS') && empty($object->context['disableticketemail'])) {
// Note: $object->context['disableticketemail'] is set to 1 by public interface at creation but not at closing
if (empty($object->context['disableticketemail'])) {
$linked_contacts = $object->listeContact(-1, 'thirdparty');
$linked_contacts = array_merge($linked_contacts, $object->listeContact(-1, 'internal'));
if (empty($linked_contacts) && getDolGlobalString('TICKET_NOTIFY_AT_CLOSING') && !empty($object->fk_soc)) {
Expand Down Expand Up @@ -346,7 +352,7 @@ private function composeAndSendAdminMessage($sendto, $base_subject, $body, Ticke
$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 = getDolGlobalString('MAIN_INFO_SOCIETE_NOM') . '<' . getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM').'>';
$from = (getDolGlobalString('MAIN_INFO_SOCIETE_NOM') ? getDolGlobalString('MAIN_INFO_SOCIETE_NOM') . ' ' : '') . '<' . getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM').'>';

$trackid = 'tic'.$object->id;

Expand Down Expand Up @@ -434,7 +440,7 @@ private function composeAndSendCustomerMessage($sendto, $base_subject, $body, $s
$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 = (!getDolGlobalString('MAIN_INFO_SOCIETE_NOM') ? '' : getDolGlobalString('MAIN_INFO_SOCIETE_NOM') . ' ').'<' . getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM').'>';
$from = (getDolGlobalString('MAIN_INFO_SOCIETE_NOM') ? getDolGlobalString('MAIN_INFO_SOCIETE_NOM') . ' ' : '').'<' . getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM').'>';

$trackid = 'tic'.$object->id;

Expand Down
12 changes: 7 additions & 5 deletions htdocs/langs/en_US/ticket.lang
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ TicketPublicAccess=A public interface requiring no identification is available a
TicketSetupDictionaries=The type of ticket, severity and analytic codes are configurable from dictionaries
TicketParamModule=Module variable setup
TicketParamMail=Email setup
TicketEmailNotificationFrom=Sender e-mail for notification on answers
TicketEmailNotificationFromHelp=Sender e-mail to use to send the notification email when an answer is provided inside the back office. For example [email protected]
TicketEmailNotificationFrom=Sender e-mail for notification on tickets
TicketEmailNotificationFromHelp=Sender e-mail to use to send the notification emails for tickets creation or messages. For example [email protected]
TicketEmailNotificationTo=Notify ticket creation to this e-mail address
TicketEmailNotificationToHelp=If present, this e-mail address will be notified of a ticket creation (in addition to already assigned contacts)
TicketEmailNotificationToHelp=If present, this e-mail address will be notified of a ticket creation (in addition to any other default recipients)
TicketNewEmailBodyLabel=Text message sent after creating a ticket
TicketNewEmailBodyHelp=The text specified here will be inserted into the email confirming the creation of a new ticket from the public interface. Information on the consultation of the ticket are automatically added.
TicketParamPublicInterface=Public interface setup
Expand All @@ -96,7 +96,9 @@ TicketPublicInterfaceTextHelpMessageHelpAdmin=This text will appear above the me
ExtraFieldsTicket=Extra attributes
TicketCkEditorEmailNotActivated=HTML editor is not activated. Please put FCKEDITOR_ENABLE_MAIL content to 1 to get it.
TicketsDisableEmail=Do not send emails for ticket creation or message recording
TicketsDisableEmailHelp=By default, emails are sent when new tickets or messages created. Enable this option to disable *all* email notifications
TicketsDisableEmailHelp=By default, notification emails to third parties are sent when new tickets or messages are created for both backoffice and public interface. Enable this option to disable email notifications to thirdparties when creation is done from backoffice.
TicketsNotifyThirdPartyFromBackOfficeByDefault=Notify third party by default on ticket creation from backoffice
TicketsNotifyThirdPartyFromBackOfficeByDefaultHelp=When creating a ticket from the backoffice, the option "Notify third party" will be checked by default
TicketsLogEnableEmail=Enable log by email
TicketsLogEnableEmailHelp=At each change, an email will be sent **to each contact** associated with the ticket.
TicketParams=Params
Expand All @@ -117,7 +119,7 @@ TicketsAutoAssignTicketHelp=When creating a ticket, the user can be automaticall
TicketNumberingModules=Tickets numbering module
TicketsModelModule=Document templates for tickets
TicketNotifyTiersAtCreation=Notify third party at creation
TicketsDisableCustomerEmail=Always disable emails when a ticket is created from public interface
TicketsDisableCustomerEmail=Always disable emails to third parties when a ticket is created from the backoffice
TicketsPublicNotificationNewMessage=Send email(s) when a new message/comment is added to a ticket
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)
Expand Down
2 changes: 1 addition & 1 deletion htdocs/ticket/class/ticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class Ticket extends CommonObject
public $cache_msgs_ticket;

/**
* @var int Notify thirdparty at create
* @var int Save if a thirdparty was notified at creation at ticket or not
*/
public $notify_tiers_at_create;

Expand Down

0 comments on commit 9a5aea0

Please sign in to comment.