From 4eb9a7625a2628c8062bacbe0aca7d42d608003a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Dec 2021 15:12:35 +0100 Subject: [PATCH] Fix notification setup page. --- htdocs/admin/notification.php | 133 +++++++++++++++-------------- htdocs/core/class/notify.class.php | 10 +++ htdocs/langs/en_US/admin.lang | 6 +- 3 files changed, 85 insertions(+), 64 deletions(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 1b06e9dd25e..db79a1503c9 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -204,6 +204,18 @@ if (!empty($conf->global->NOTIFICATION_EMAIL_FROM) && !isValidEmail($conf->globa print ''; print ''; +print ''; +print $langs->trans("NotificationDisableConfirmMessageContact").''; +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT", $arrval, $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT); +} +print ''; +print ''; + print ''; print $langs->trans("NotificationDisableConfirmMessageUser").''; print ''; @@ -215,6 +227,7 @@ if ($conf->use_javascript_ajax) { } print ''; print ''; + print ''; print $langs->trans("NotificationDisableConfirmMessageFix").''; print ''; @@ -241,79 +254,68 @@ print ''; print ''; // Notification per contacts -$title = $langs->trans("ListOfNotificationsPerUser"); -if (!empty($conf->societe->enabled)) { - $title = $langs->trans("ListOfNotificationsPerUserOrContact"); -} -print load_fiche_titre($title, '', ''); +$title = $langs->trans("TemplatesForNotifications"); + +print load_fiche_titre($title, '', 'email'); // Load array of available notifications $notificationtrigger = new InterfaceNotification($db); $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents(); +// Editing global variables not related to a specific theme +$constantes = array(); +foreach ($listofnotifiedevents as $notifiedevent) { + $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; + $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - // Editing global variables not related to a specific theme - $constantes = array(); - foreach ($listofnotifiedevents as $notifiedevent) { - $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; - $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); - - if ($notifiedevent['elementtype'] == 'order_supplier') { - $elementLabel = $langs->trans('SupplierOrder'); - } elseif ($notifiedevent['elementtype'] == 'propal') { - $elementLabel = $langs->trans('Proposal'); - } elseif ($notifiedevent['elementtype'] == 'facture') { - $elementLabel = $langs->trans('Bill'); - } elseif ($notifiedevent['elementtype'] == 'commande') { - $elementLabel = $langs->trans('Order'); - } elseif ($notifiedevent['elementtype'] == 'ficheinter') { - $elementLabel = $langs->trans('Intervention'); - } elseif ($notifiedevent['elementtype'] == 'shipping') { - $elementLabel = $langs->trans('Shipping'); - } elseif ($notifiedevent['elementtype'] == 'expensereport' || $notifiedevent['elementtype'] == 'expense_report') { - $elementLabel = $langs->trans('ExpenseReport'); - } - - if ($notifiedevent['elementtype'] == 'propal') { - $model = 'propal_send'; - } elseif ($notifiedevent['elementtype'] == 'commande') { - $model = 'order_send'; - } elseif ($notifiedevent['elementtype'] == 'facture') { - $model = 'facture_send'; - } elseif ($notifiedevent['elementtype'] == 'shipping') { - $model = 'shipping_send'; - } elseif ($notifiedevent['elementtype'] == 'ficheinter') { - $model = 'fichinter_send'; - } elseif ($notifiedevent['elementtype'] == 'expensereport') { - $model = 'expensereport_send'; - } elseif ($notifiedevent['elementtype'] == 'order_supplier') { - $model = 'order_supplier_send'; - // } elseif ($notifiedevent['elementtype'] == 'invoice_supplier') $model = 'invoice_supplier_send'; - } elseif ($notifiedevent['elementtype'] == 'member') { - $model = 'member'; - } - - $constantes[$notifiedevent['code'].'_TEMPLATE'] = array('type'=>'emailtemplate:'.$model, 'label'=>$label); + if ($notifiedevent['elementtype'] == 'order_supplier') { + $elementLabel = $langs->trans('SupplierOrder'); + } elseif ($notifiedevent['elementtype'] == 'propal') { + $elementLabel = $langs->trans('Proposal'); + } elseif ($notifiedevent['elementtype'] == 'facture') { + $elementLabel = $langs->trans('Bill'); + } elseif ($notifiedevent['elementtype'] == 'commande') { + $elementLabel = $langs->trans('Order'); + } elseif ($notifiedevent['elementtype'] == 'ficheinter') { + $elementLabel = $langs->trans('Intervention'); + } elseif ($notifiedevent['elementtype'] == 'shipping') { + $elementLabel = $langs->trans('Shipping'); + } elseif ($notifiedevent['elementtype'] == 'expensereport' || $notifiedevent['elementtype'] == 'expense_report') { + $elementLabel = $langs->trans('ExpenseReport'); } - $helptext = ''; - form_constantes($constantes, 3, $helptext, 'EmailTemplate'); - - print '
'; - print '* '.$langs->trans("GoOntoUserCardToAddMore").'
'; - if (!empty($conf->societe->enabled)) { - print '** '.$langs->trans("GoOntoContactCardToAddMore").'
'; + if ($notifiedevent['elementtype'] == 'propal') { + $model = 'propal_send'; + } elseif ($notifiedevent['elementtype'] == 'commande') { + $model = 'order_send'; + } elseif ($notifiedevent['elementtype'] == 'facture') { + $model = 'facture_send'; + } elseif ($notifiedevent['elementtype'] == 'shipping') { + $model = 'shipping_send'; + } elseif ($notifiedevent['elementtype'] == 'ficheinter') { + $model = 'fichinter_send'; + } elseif ($notifiedevent['elementtype'] == 'expensereport') { + $model = 'expensereport_send'; + } elseif ($notifiedevent['elementtype'] == 'order_supplier') { + $model = 'order_supplier_send'; + // } elseif ($notifiedevent['elementtype'] == 'invoice_supplier') $model = 'invoice_supplier_send'; + } elseif ($notifiedevent['elementtype'] == 'member') { + $model = 'member'; } - print '
'; - print $form->buttonsSaveCancel("Save", ''); + $constantes[$notifiedevent['code'].'_TEMPLATE'] = array('type'=>'emailtemplate:'.$model, 'label'=>$label); +} + +$helptext = ''; +form_constantes($constantes, 3, $helptext, 'EmailTemplate'); + +print $form->buttonsSaveCancel("Save", ''); + +/* } else { print ''; print ''; print ''; - /*print ''; - print '';*/ //print ''; print "\n"; @@ -359,6 +361,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { } print ''; } +*/ print ''; @@ -371,7 +374,15 @@ print ''; print ''; print ''; -print load_fiche_titre($langs->trans("ListOfFixedNotifications"), '', ''); +print load_fiche_titre($langs->trans("ListOfFixedNotifications"), '', 'email'); + +print '
'; +print $langs->trans("Note").':
'; +print '* '.$langs->trans("GoOntoUserCardToAddMore").'
'; +if (!empty($conf->societe->enabled)) { + print '** '.$langs->trans("GoOntoContactCardToAddMore").'
'; +} +print '
'; print '
'.$langs->trans("Label").''.$langs->trans("Code").''.$langs->trans("Label").''.$langs->trans("NbOfTargetedContacts").'
'; print ''; @@ -488,8 +499,6 @@ foreach ($listofnotifiedevents as $notifiedevent) { } print '
'; -print '
'; - print $form->buttonsSaveCancel("Save", ''); print ''; diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index a741af3d867..85b622f62ad 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -108,7 +108,9 @@ class Notify global $conf, $langs; $langs->load("mails"); + // Get full list of all notifications subscribed for $action, $socid and $object $listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0); + if (!empty($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER)) { foreach ($listofnotiftodo as $val) { if ($val['type'] == 'touser') { @@ -117,6 +119,14 @@ class Notify } } } + if (!empty($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT)) { + foreach ($listofnotiftodo as $val) { + if ($val['type'] == 'tocontact') { + unset($listofnotiftodo[$val['email']]); + //$listofnotiftodo = array_merge($listofnotiftodo); + } + } + } if (!empty($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX)) { foreach ($listofnotiftodo as $val) { if ($val['type'] == 'tofixedemail') { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index b4ce76ad884..23cb14faae1 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1712,8 +1712,9 @@ MailingDelay=Seconds to wait after sending next message NotificationSetup=Email Notification module setup NotificationEMailFrom=Sender email (From) for emails sent by the Notifications module FixedEmailTarget=Recipient -NotificationDisableConfirmMessageFix=Disable the information about targets into the confirmation message before sending the notifications to the global emails -NotificationDisableConfirmMessageUser=Disable the information about targets into the confirmation message before sending the notifications to the user emails +NotificationDisableConfirmMessageContact=Hide the list of recipients (subscribed as contact) of notifications into the confirmation message +NotificationDisableConfirmMessageUser=Hide the list of recipients (subscribed as user) of notifications into the confirmation message +NotificationDisableConfirmMessageFix=Hide the list of recipients (subscribed as global email) of notifications into the confirmation message ##### Sendings ##### SendingsSetup=Shipping module setup SendingsReceiptModel=Sending receipt model @@ -1905,6 +1906,7 @@ ExpenseReportsRulesSetup=Setup of module Expense Reports - Rules ExpenseReportNumberingModules=Expense reports numbering module NoModueToManageStockIncrease=No module able to manage automatic stock increase has been activated. Stock increase will be done on manual input only. YouMayFindNotificationsFeaturesIntoModuleNotification=You may find options for email notifications by enabling and configuring the module "Notification". +TemplatesForNotifications=Templates for notifications ListOfNotificationsPerUser=List of automatic notifications per user* ListOfNotificationsPerUserOrContact=List of possible automatic notifications (on business event) available per user* or per contact** ListOfFixedNotifications=List of automatic fixed notifications