32require
'../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_50_modNotification_Notification.class.php';
45$langs->loadLangs(array(
'admin',
'other',
'orders',
'propal',
'bills',
'mails',
'contracts'));
52$action =
GETPOST(
'action',
'aZ09');
61if ($action ==
'settemplates') {
64 if (is_array($_POST)) {
66 foreach ($_POST as $key => $val) {
67 if (!preg_match(
'/^constvalue_(.*)_TEMPLATE/', $key, $reg)) {
71 $triggername = $reg[1];
72 $constvalue =
GETPOST($key,
'alpha');
73 $consttype =
'emailtemplate:xxx';
74 $tmparray = explode(
':', $constvalue);
75 if (!empty($tmparray[0]) && !empty($tmparray[1])) {
76 $constvalue = $tmparray[0];
77 $consttype =
'emailtemplate:'.$tmparray[1];
93 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
97 setEventMessages($langs->trans(
"Error"),
null,
'errors');
101if ($action ==
'setvalue') {
109 $result =
dolibarr_set_const($db,
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE",
GETPOST(
"notif_disable",
"alphawithlgt"),
'chaine', 0,
'',
$conf->entity);
117 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
121 setEventMessages($langs->trans(
"Error"),
null,
'errors');
126if ($action ==
'setfixednotif') {
129 if (is_array($_POST)) {
131 foreach ($_POST as $key => $val) {
132 if (!preg_match(
'/^NOTIF_(.*)_key$/', $key, $reg)) {
139 $shortkey = preg_replace(
'/_key$/',
'', $key);
142 if (preg_match(
'/^NOTIF_(.*)_old_(.*)_key/', $key, $reg)) {
145 $newkey =
'NOTIFICATION_FIXEDEMAIL_'.$reg[1].
'_THRESHOLD_HIGHER_'.((int)
GETPOST($shortkey.
'_amount'));
146 $newval =
GETPOST($shortkey.
'_key');
148 } elseif (preg_match(
'/^NOTIF_(.*)_new_key/', $key, $reg)) {
150 $newkey =
'NOTIFICATION_FIXEDEMAIL_'.$reg[1].
'_THRESHOLD_HIGHER_'.((int)
GETPOST($shortkey.
'_amount'));
151 $newval =
GETPOST($shortkey.
'_key');
154 if ($newkey && $newval) {
163 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
167 setEventMessages($langs->trans(
"Error"),
null,
'errors');
177$form =
new Form($db);
180llxHeader(
'', $langs->trans(
"NotificationSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-notification');
182$linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'restore_lastsearch_values' => 1]).
'">'.img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></a>';
184print
load_fiche_titre($langs->trans(
"NotificationSetup"), $linkback,
'title_setup');
186print
'<span class="opacitymedium">';
187print $langs->trans(
"NotificationsDesc").
'<br>';
188print $langs->trans(
"NotificationsDescUser").
'<br>';
190 print $langs->trans(
"NotificationsDescContact").
'<br>';
192print $langs->trans(
"NotificationsDescGlobal").
' - '.$langs->trans(
"YouAreHere").
'<br>';
196print
'<form method="post" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'" spellcheck="false">';
197print
'<input type="hidden" name="token" value="'.newToken().
'">';
198print
'<input type="hidden" name="action" value="setvalue">';
200print
'<div class="div-table-responsive-no-min">';
201print
'<table class="noborder centpercent">';
202print
'<tr class="liste_titre">';
203print
'<td>'.$langs->trans(
"Parameter").
'</td>';
208print
'<tr class="oddeven"><td>';
209print $langs->trans(
"NotificationEMailFrom").
'</td>';
211print img_picto(
'',
'email',
'class="pictofixedwidth"');
212print
'<input class="width150 quatrevingtpercentminusx" type="email" name="email_from" value="'.getDolGlobalString(
'NOTIFICATION_EMAIL_FROM').
'">';
214 $langs->load(
'errors');
215 print
' '.img_warning($langs->trans(
"ErrorBadEMail"));
221print
'<tr class="oddeven"><td>';
222print $langs->trans(
"NotificationDisableConfirmMessageUser").
'</td>';
224if (
$conf->use_javascript_ajax) {
225 print ajax_constantonoff(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER');
227 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
228 print $form->selectarray(
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER", $arrval,
getDolGlobalString(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER'));
234print
'<tr class="oddeven"><td>';
235print $langs->trans(
"NotificationDisableConfirmMessageContact").
'</td>';
237if (
$conf->use_javascript_ajax) {
238 print ajax_constantonoff(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT');
240 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
241 print $form->selectarray(
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT", $arrval,
getDolGlobalString(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT'));
247print
'<tr class="oddeven"><td>';
248print $langs->trans(
"NotificationDisableConfirmMessageFix").
'</td>';
250if (
$conf->use_javascript_ajax) {
251 print ajax_constantonoff(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX');
253 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
254 print $form->selectarray(
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX", $arrval,
getDolGlobalString(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX'));
263print $form->buttonsSaveCancel(
"Save",
'');
273print
'<form method="post" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'" spellcheck="false">';
274print
'<input type="hidden" name="token" value="'.newToken().
'">';
275print
'<input type="hidden" name="action" value="settemplates">';
277$title = $langs->trans(
"TemplatesForNotifications");
283$listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
286$constantes = array();
287foreach ($listofnotifiedevents as $notifiedevent) {
288 $label = $langs->trans(
"Notify_".$notifiedevent[
'code']);
289 $elementLabel = $langs->trans(ucfirst($notifiedevent[
'elementtype']));
291 $model = $notifiedevent[
'elementtype'];
293 if ($notifiedevent[
'elementtype'] ==
'order_supplier') {
294 $elementLabel = $langs->trans(
'SupplierOrder');
295 } elseif ($notifiedevent[
'elementtype'] ==
'propal') {
296 $elementLabel = $langs->trans(
'Proposal');
297 } elseif ($notifiedevent[
'elementtype'] ==
'facture') {
298 $elementLabel = $langs->trans(
'Bill');
299 } elseif ($notifiedevent[
'elementtype'] ==
'commande') {
300 $elementLabel = $langs->trans(
'Order');
301 } elseif ($notifiedevent[
'elementtype'] ==
'ficheinter') {
302 $elementLabel = $langs->trans(
'Intervention');
303 } elseif ($notifiedevent[
'elementtype'] ==
'shipping') {
304 $elementLabel = $langs->trans(
'Shipping');
305 } elseif ($notifiedevent[
'elementtype'] ==
'expensereport' || $notifiedevent[
'elementtype'] ==
'expense_report') {
306 $elementLabel = $langs->trans(
'ExpenseReport');
307 } elseif ($notifiedevent[
'elementtype'] ==
'contrat') {
308 $elementLabel = $langs->trans(
'Contract');
311 if ($notifiedevent[
'elementtype'] ==
'propal') {
312 $model =
'propal_send';
313 } elseif ($notifiedevent[
'elementtype'] ==
'commande') {
314 $model =
'order_send';
315 } elseif ($notifiedevent[
'elementtype'] ==
'facture') {
316 $model =
'facture_send';
317 } elseif ($notifiedevent[
'elementtype'] ==
'shipping') {
318 $model =
'shipping_send';
319 } elseif ($notifiedevent[
'elementtype'] ==
'ficheinter') {
320 $model =
'fichinter_send';
321 } elseif ($notifiedevent[
'elementtype'] ==
'expensereport') {
322 $model =
'expensereport_send';
323 } elseif ($notifiedevent[
'elementtype'] ==
'societe') {
324 $model =
'thirdparty';
325 } elseif ($notifiedevent[
'elementtype'] ==
'order_supplier') {
326 $model =
'order_supplier_send';
327 } elseif ($notifiedevent[
'elementtype'] ==
'invoice_supplier') {
328 $model =
'invoice_supplier_send';
329 } elseif ($notifiedevent[
'elementtype'] ==
'member') {
331 } elseif ($notifiedevent[
'elementtype'] ==
'contrat') {
333 } elseif ($notifiedevent[
'elementtype'] ==
'stocktransfer') {
334 $model =
'stocktransfer_send';
335 } elseif ($notifiedevent[
'elementtype'] ==
'agenda') {
336 $model =
'actioncomm_send';
339 if (strpos($notifiedevent[
'code'],
'HOLIDAY_') === 0) {
343 $constantes[$notifiedevent[
'code'].
'_TEMPLATE'] = array(
'type'=>
'emailtemplate:'.$model,
'label'=>$label);
346$helptext = $langs->trans(
"EmailTemplateHelp", $langs->transnoentitiesnoconv(
"Tools"), $langs->transnoentitiesnoconv(
"EMailTemplates"));
349print $form->buttonsSaveCancel(
"Save",
'');
409print
'<form method="post" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'" spellcheck="false">';
410print
'<input type="hidden" name="token" value="'.newToken().
'">';
411print
'<input type="hidden" name="action" value="setfixednotif">';
412print
'<input type="hidden" name="page_y" value="">';
414print
load_fiche_titre($langs->trans(
"ListOfFixedNotifications"),
'',
'email');
416print
'<div class="info">';
417print $langs->trans(
"Note").
':<br>';
418print
'* '.$langs->trans(
"GoOntoUserCardToAddMore").
'<br>';
420 print
'** '.$langs->trans(
"GoOntoContactCardToAddMore").
'<br>';
424print
'<div class="div-table-responsive">';
425print
'<table class="noborder centpercent">';
426print
'<tr class="liste_titre">';
427print
'<td>'.$langs->trans(
"Module").
'</td>';
428print
'<td>'.$langs->trans(
"Code").
'</td>';
429print
'<td>'.$langs->trans(
"Label").
'</td>';
430print
'<td>'.$langs->trans(
"FixedEmailTarget").
'</td>';
431print
'<td>'.$langs->trans(
"Threshold").
'</td>';
435foreach ($listofnotifiedevents as $notifiedevent) {
436 $label = $langs->trans(
"Notify_".$notifiedevent[
'code']);
438 $elementPicto = $notifiedevent[
'elementtype'];
439 $elementLabel = $langs->trans(ucfirst($notifiedevent[
'elementtype']));
441 if ($notifiedevent[
'elementtype'] ==
'order_supplier') {
442 $elementPicto =
'supplier_order';
443 $elementLabel = $langs->trans(
'SupplierOrder');
444 } elseif ($notifiedevent[
'elementtype'] ==
'propal') {
445 $elementLabel = $langs->trans(
'Proposal');
446 } elseif ($notifiedevent[
'elementtype'] ==
'facture') {
447 $elementPicto =
'bill';
448 $elementLabel = $langs->trans(
'Bill');
449 } elseif ($notifiedevent[
'elementtype'] ==
'commande') {
450 $elementPicto =
'order';
451 $elementLabel = $langs->trans(
'Order');
452 } elseif ($notifiedevent[
'elementtype'] ==
'ficheinter') {
453 $elementPicto =
'intervention';
454 $elementLabel = $langs->trans(
'Intervention');
455 } elseif ($notifiedevent[
'elementtype'] ==
'shipping') {
456 $elementPicto =
'shipment';
457 $elementLabel = $langs->trans(
'Shipping');
458 } elseif ($notifiedevent[
'elementtype'] ==
'societe') {
459 $elementPicto =
'company';
460 } elseif ($notifiedevent[
'elementtype'] ==
'expensereport' || $notifiedevent[
'elementtype'] ==
'expense_report') {
461 $elementPicto =
'expensereport';
462 $elementLabel = $langs->trans(
'ExpenseReport');
463 } elseif ($notifiedevent[
'elementtype'] ==
'contrat') {
464 $elementPicto =
'contract';
465 $elementLabel = $langs->trans(
'Contract');
466 } elseif ($notifiedevent[
'elementtype'] ==
'agenda') {
467 $elementPicto =
'action';
470 $labelfortrigger =
'AmountHT';
471 $codehasnotrigger = 0;
472 if (preg_match(
'/^(ACTION|HOLIDAY)/', $notifiedevent[
'code'])) {
476 print
'<tr class="oddeven">';
478 print img_picto(
'', $elementPicto,
'class="pictofixedwidth"');
481 print
'<td>'.$notifiedevent[
'code'].
'</td>';
482 print
'<td><span class="opacitymedium">'.$label.
'</span></td>';
484 $inputfieldalreadyshown = 0;
486 foreach (
$conf->global as $key => $val) {
487 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.preg_quote($notifiedevent[
'code'],
'/').
'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
491 $param =
'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_'.$reg[1];
492 $value =
GETPOST(
'NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key') ?
GETPOST(
'NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key',
'alpha') :
getDolGlobalString($param);
494 $s =
'<input type="text" class="minwidth200" name="NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key" value="'.
dol_escape_htmltag($value).
'">';
495 $arrayemail = explode(
',', $value);
497 foreach ($arrayemail as $keydet => $valuedet) {
498 $valuedet = trim($valuedet);
499 if (!empty($valuedet) && $valuedet !=
'__SUPERVISOREMAIL__' && $valuedet !=
'__AUTHOREMAIL__' && !
isValidEmail($valuedet, 1)) {
504 $langs->load(
'errors');
505 $s .=
' '.img_warning($langs->trans(
"ErrorBadEMail"));
507 print $form->textwithpicto($s, $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients").
'<br>'.$langs->trans(
"YouCanAlsoUseSupervisorKeyword").
'<br>'.$langs->trans(
"YouCanAlsoUseAuthorKeyword"), 1,
'help',
'', 0, 2);
510 $inputfieldalreadyshown++;
513 if (empty($inputfieldalreadyshown) || !$codehasnotrigger) {
514 $s =
'<input type="text" class="minwidth200" name="NOTIF_'.$notifiedevent[
'code'].
'_new_key" value="">';
515 print $form->textwithpicto($s, $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients").
'<br>'.$langs->trans(
"YouCanAlsoUseSupervisorKeyword").
'<br>'.$langs->trans(
"YouCanAlsoUseAuthorKeyword"), 1,
'help',
'', 0, 2);
521 $inputfieldalreadyshown = 0;
522 foreach (
$conf->global as $key => $val) {
523 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
527 if (!$codehasnotrigger) {
528 print $langs->trans($labelfortrigger).
' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_amount" value="'.
dol_escape_htmltag($reg[1]).
'">';
531 $inputfieldalreadyshown++;
535 if (!$codehasnotrigger) {
536 print $langs->trans($labelfortrigger).
' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent[
'code'].
'_new_amount" value="">';
549print $form->buttonsSaveCancel(
"Save",
'');
form_constantes($tableau, $strictw3c=2, $helptext='', $text='')
Show array with constants to edit.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class of triggers for notification module.
Class to manage the table of subscription to notifications.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.