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',
'errors',
'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 print
' '.img_warning($langs->trans(
"ErrorBadEMail"));
220print
'<tr class="oddeven"><td>';
221print $langs->trans(
"NotificationDisableConfirmMessageUser").
'</td>';
223if (
$conf->use_javascript_ajax) {
224 print ajax_constantonoff(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER');
226 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
227 print $form->selectarray(
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER", $arrval,
getDolGlobalString(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER'));
233print
'<tr class="oddeven"><td>';
234print $langs->trans(
"NotificationDisableConfirmMessageContact").
'</td>';
236if (
$conf->use_javascript_ajax) {
237 print ajax_constantonoff(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT');
239 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
240 print $form->selectarray(
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT", $arrval,
getDolGlobalString(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT'));
246print
'<tr class="oddeven"><td>';
247print $langs->trans(
"NotificationDisableConfirmMessageFix").
'</td>';
249if (
$conf->use_javascript_ajax) {
250 print ajax_constantonoff(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX');
252 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
253 print $form->selectarray(
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX", $arrval,
getDolGlobalString(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX'));
262print $form->buttonsSaveCancel(
"Save",
'');
272print
'<form method="post" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'" spellcheck="false">';
273print
'<input type="hidden" name="token" value="'.newToken().
'">';
274print
'<input type="hidden" name="action" value="settemplates">';
276$title = $langs->trans(
"TemplatesForNotifications");
282$listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
285$constantes = array();
286foreach ($listofnotifiedevents as $notifiedevent) {
287 $label = $langs->trans(
"Notify_".$notifiedevent[
'code']);
288 $elementLabel = $langs->trans(ucfirst($notifiedevent[
'elementtype']));
290 $model = $notifiedevent[
'elementtype'];
292 if ($notifiedevent[
'elementtype'] ==
'order_supplier') {
293 $elementLabel = $langs->trans(
'SupplierOrder');
294 } elseif ($notifiedevent[
'elementtype'] ==
'propal') {
295 $elementLabel = $langs->trans(
'Proposal');
296 } elseif ($notifiedevent[
'elementtype'] ==
'facture') {
297 $elementLabel = $langs->trans(
'Bill');
298 } elseif ($notifiedevent[
'elementtype'] ==
'commande') {
299 $elementLabel = $langs->trans(
'Order');
300 } elseif ($notifiedevent[
'elementtype'] ==
'ficheinter') {
301 $elementLabel = $langs->trans(
'Intervention');
302 } elseif ($notifiedevent[
'elementtype'] ==
'shipping') {
303 $elementLabel = $langs->trans(
'Shipping');
304 } elseif ($notifiedevent[
'elementtype'] ==
'expensereport' || $notifiedevent[
'elementtype'] ==
'expense_report') {
305 $elementLabel = $langs->trans(
'ExpenseReport');
306 } elseif ($notifiedevent[
'elementtype'] ==
'contrat') {
307 $elementLabel = $langs->trans(
'Contract');
310 if ($notifiedevent[
'elementtype'] ==
'propal') {
311 $model =
'propal_send';
312 } elseif ($notifiedevent[
'elementtype'] ==
'commande') {
313 $model =
'order_send';
314 } elseif ($notifiedevent[
'elementtype'] ==
'facture') {
315 $model =
'facture_send';
316 } elseif ($notifiedevent[
'elementtype'] ==
'shipping') {
317 $model =
'shipping_send';
318 } elseif ($notifiedevent[
'elementtype'] ==
'ficheinter') {
319 $model =
'fichinter_send';
320 } elseif ($notifiedevent[
'elementtype'] ==
'expensereport') {
321 $model =
'expensereport_send';
322 } elseif ($notifiedevent[
'elementtype'] ==
'societe') {
323 $model =
'thirdparty';
324 } elseif ($notifiedevent[
'elementtype'] ==
'order_supplier') {
325 $model =
'order_supplier_send';
326 } elseif ($notifiedevent[
'elementtype'] ==
'invoice_supplier') {
327 $model =
'invoice_supplier_send';
328 } elseif ($notifiedevent[
'elementtype'] ==
'member') {
330 } elseif ($notifiedevent[
'elementtype'] ==
'contrat') {
332 } elseif ($notifiedevent[
'elementtype'] ==
'stocktransfer') {
333 $model =
'stocktransfer_send';
334 } elseif ($notifiedevent[
'elementtype'] ==
'agenda') {
335 $model =
'actioncomm_send';
338 if (strpos($notifiedevent[
'code'],
'HOLIDAY_') === 0) {
342 $constantes[$notifiedevent[
'code'].
'_TEMPLATE'] = array(
'type'=>
'emailtemplate:'.$model,
'label'=>$label);
345$helptext = $langs->trans(
"EmailTemplateHelp", $langs->transnoentitiesnoconv(
"Tools"), $langs->transnoentitiesnoconv(
"EMailTemplates"));
348print $form->buttonsSaveCancel(
"Save",
'');
408print
'<form method="post" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'" spellcheck="false">';
409print
'<input type="hidden" name="token" value="'.newToken().
'">';
410print
'<input type="hidden" name="action" value="setfixednotif">';
411print
'<input type="hidden" name="page_y" value="">';
413print
load_fiche_titre($langs->trans(
"ListOfFixedNotifications"),
'',
'email');
415print
'<div class="info">';
416print $langs->trans(
"Note").
':<br>';
417print
'* '.$langs->trans(
"GoOntoUserCardToAddMore").
'<br>';
419 print
'** '.$langs->trans(
"GoOntoContactCardToAddMore").
'<br>';
423print
'<div class="div-table-responsive">';
424print
'<table class="noborder centpercent">';
425print
'<tr class="liste_titre">';
426print
'<td>'.$langs->trans(
"Module").
'</td>';
427print
'<td>'.$langs->trans(
"Code").
'</td>';
428print
'<td>'.$langs->trans(
"Label").
'</td>';
429print
'<td>'.$langs->trans(
"FixedEmailTarget").
'</td>';
430print
'<td>'.$langs->trans(
"Threshold").
'</td>';
434foreach ($listofnotifiedevents as $notifiedevent) {
435 $label = $langs->trans(
"Notify_".$notifiedevent[
'code']);
437 $elementPicto = $notifiedevent[
'elementtype'];
438 $elementLabel = $langs->trans(ucfirst($notifiedevent[
'elementtype']));
440 if ($notifiedevent[
'elementtype'] ==
'order_supplier') {
441 $elementPicto =
'supplier_order';
442 $elementLabel = $langs->trans(
'SupplierOrder');
443 } elseif ($notifiedevent[
'elementtype'] ==
'propal') {
444 $elementLabel = $langs->trans(
'Proposal');
445 } elseif ($notifiedevent[
'elementtype'] ==
'facture') {
446 $elementPicto =
'bill';
447 $elementLabel = $langs->trans(
'Bill');
448 } elseif ($notifiedevent[
'elementtype'] ==
'commande') {
449 $elementPicto =
'order';
450 $elementLabel = $langs->trans(
'Order');
451 } elseif ($notifiedevent[
'elementtype'] ==
'ficheinter') {
452 $elementPicto =
'intervention';
453 $elementLabel = $langs->trans(
'Intervention');
454 } elseif ($notifiedevent[
'elementtype'] ==
'shipping') {
455 $elementPicto =
'shipment';
456 $elementLabel = $langs->trans(
'Shipping');
457 } elseif ($notifiedevent[
'elementtype'] ==
'societe') {
458 $elementPicto =
'company';
459 } elseif ($notifiedevent[
'elementtype'] ==
'expensereport' || $notifiedevent[
'elementtype'] ==
'expense_report') {
460 $elementPicto =
'expensereport';
461 $elementLabel = $langs->trans(
'ExpenseReport');
462 } elseif ($notifiedevent[
'elementtype'] ==
'contrat') {
463 $elementPicto =
'contract';
464 $elementLabel = $langs->trans(
'Contract');
465 } elseif ($notifiedevent[
'elementtype'] ==
'agenda') {
466 $elementPicto =
'action';
469 $labelfortrigger =
'AmountHT';
470 $codehasnotrigger = 0;
471 if (preg_match(
'/^(ACTION|HOLIDAY)/', $notifiedevent[
'code'])) {
475 print
'<tr class="oddeven">';
477 print img_picto(
'', $elementPicto,
'class="pictofixedwidth"');
480 print
'<td>'.$notifiedevent[
'code'].
'</td>';
481 print
'<td><span class="opacitymedium">'.$label.
'</span></td>';
483 $inputfieldalreadyshown = 0;
485 foreach (
$conf->global as $key => $val) {
486 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.preg_quote($notifiedevent[
'code'],
'/').
'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
490 $param =
'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_'.$reg[1];
491 $value =
GETPOST(
'NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key') ?
GETPOST(
'NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key',
'alpha') :
getDolGlobalString($param);
493 $s =
'<input type="text" class="minwidth200" name="NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key" value="'.
dol_escape_htmltag($value).
'">';
494 $arrayemail = explode(
',', $value);
496 foreach ($arrayemail as $keydet => $valuedet) {
497 $valuedet = trim($valuedet);
498 if (!empty($valuedet) && $valuedet !=
'__SUPERVISOREMAIL__' && $valuedet !=
'__AUTHOREMAIL__' && !
isValidEmail($valuedet, 1)) {
503 $s .=
' '.img_warning($langs->trans(
"ErrorBadEMail"));
505 print $form->textwithpicto($s, $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients").
'<br>'.$langs->trans(
"YouCanAlsoUseSupervisorKeyword").
'<br>'.$langs->trans(
"YouCanAlsoUseAuthorKeyword"), 1,
'help',
'', 0, 2);
508 $inputfieldalreadyshown++;
511 if (empty($inputfieldalreadyshown) || !$codehasnotrigger) {
512 $s =
'<input type="text" class="minwidth200" name="NOTIF_'.$notifiedevent[
'code'].
'_new_key" value="">';
513 print $form->textwithpicto($s, $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients").
'<br>'.$langs->trans(
"YouCanAlsoUseSupervisorKeyword").
'<br>'.$langs->trans(
"YouCanAlsoUseAuthorKeyword"), 1,
'help',
'', 0, 2);
519 $inputfieldalreadyshown = 0;
520 foreach (
$conf->global as $key => $val) {
521 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
525 if (!$codehasnotrigger) {
526 print $langs->trans($labelfortrigger).
' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_amount" value="'.
dol_escape_htmltag($reg[1]).
'">';
529 $inputfieldalreadyshown++;
533 if (!$codehasnotrigger) {
534 print $langs->trans($labelfortrigger).
' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent[
'code'].
'_new_amount" value="">';
547print $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.
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.