31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
34require_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' && $user->admin) {
64 if (!$error && 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];
103if ($action ==
'setvalue' && $user->admin) {
111 $result =
dolibarr_set_const($db,
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE",
GETPOST(
"notif_disable",
"alphawithlgt"),
'chaine', 0,
'',
$conf->entity);
128if ($action ==
'setfixednotif' && $user->admin) {
131 if (!$error && is_array($_POST)) {
133 foreach ($_POST as $key => $val) {
134 if (!preg_match(
'/^NOTIF_(.*)_key$/', $key, $reg)) {
141 $shortkey = preg_replace(
'/_key$/',
'', $key);
144 if (preg_match(
'/^NOTIF_(.*)_old_(.*)_key/', $key, $reg)) {
147 $newkey =
'NOTIFICATION_FIXEDEMAIL_'.$reg[1].
'_THRESHOLD_HIGHER_'.((int)
GETPOST($shortkey.
'_amount'));
148 $newval =
GETPOST($shortkey.
'_key');
150 } elseif (preg_match(
'/^NOTIF_(.*)_new_key/', $key, $reg)) {
152 $newkey =
'NOTIFICATION_FIXEDEMAIL_'.$reg[1].
'_THRESHOLD_HIGHER_'.((int)
GETPOST($shortkey.
'_amount'));
153 $newval =
GETPOST($shortkey.
'_key');
156 if ($newkey && $newval) {
179$form =
new Form($db);
182llxHeader(
'', $langs->trans(
"NotificationSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-notification');
184$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
185print
load_fiche_titre($langs->trans(
"NotificationSetup"), $linkback,
'title_setup');
187print
'<span class="opacitymedium">';
188print $langs->trans(
"NotificationsDesc").
'<br>';
189print $langs->trans(
"NotificationsDescUser").
'<br>';
190if (isModEnabled(
"societe")) {
191 print $langs->trans(
"NotificationsDescContact").
'<br>';
193print $langs->trans(
"NotificationsDescGlobal").
' - '.$langs->trans(
"YouAreHere").
'<br>';
197print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
198print
'<input type="hidden" name="token" value="'.newToken().
'">';
199print
'<input type="hidden" name="action" value="setvalue">';
201print
'<div class="div-table-responsive-no-min">';
202print
'<table class="noborder centpercent">';
203print
'<tr class="liste_titre">';
204print
'<td>'.$langs->trans(
"Parameter").
'</td>';
205print
'<td>'.$langs->trans(
"Value").
'</td>';
209print
'<tr class="oddeven"><td>';
210print $langs->trans(
"NotificationEMailFrom").
'</td>';
212print
img_picto(
'',
'email',
'class="pictofixedwidth"');
213print
'<input class="width150 quatrevingtpercentminusx" type="email" name="email_from" value="'.getDolGlobalString(
'NOTIFICATION_EMAIL_FROM').
'">';
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="'.$_SERVER[
"PHP_SELF"].
'">';
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'] ==
'order_supplier') {
324 $model =
'order_supplier_send';
325 } elseif ($notifiedevent[
'elementtype'] ==
'invoice_supplier') {
326 $model =
'invoice_supplier_send';
327 } elseif ($notifiedevent[
'elementtype'] ==
'member') {
329 } elseif ($notifiedevent[
'elementtype'] ==
'contrat') {
330 $model =
'contract_send';
333 $constantes[$notifiedevent[
'code'].
'_TEMPLATE'] = array(
'type'=>
'emailtemplate:'.$model,
'label'=>$label);
336$helptext = $langs->trans(
"EmailTemplateHelp", $langs->transnoentitiesnoconv(
"Tools"), $langs->transnoentitiesnoconv(
"EMailTemplates"));
339print $form->buttonsSaveCancel(
"Save",
'');
399print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
400print
'<input type="hidden" name="token" value="'.newToken().
'">';
401print
'<input type="hidden" name="action" value="setfixednotif">';
402print
'<input type="hidden" name="page_y" value="">';
404print
load_fiche_titre($langs->trans(
"ListOfFixedNotifications"),
'',
'email');
406print
'<div class="info">';
407print $langs->trans(
"Note").
':<br>';
408print
'* '.$langs->trans(
"GoOntoUserCardToAddMore").
'<br>';
409if (isModEnabled(
"societe")) {
410 print
'** '.$langs->trans(
"GoOntoContactCardToAddMore").
'<br>';
414print
'<div class="div-table-responsive">';
415print
'<table class="noborder centpercent">';
416print
'<tr class="liste_titre">';
417print
'<td>'.$langs->trans(
"Module").
'</td>';
418print
'<td>'.$langs->trans(
"Code").
'</td>';
419print
'<td>'.$langs->trans(
"Label").
'</td>';
420print
'<td>'.$langs->trans(
"FixedEmailTarget").
'</td>';
421print
'<td>'.$langs->trans(
"Threshold").
'</td>';
425foreach ($listofnotifiedevents as $notifiedevent) {
426 $label = $langs->trans(
"Notify_".$notifiedevent[
'code']);
428 $elementPicto = $notifiedevent[
'elementtype'];
429 $elementLabel = $langs->trans(ucfirst($notifiedevent[
'elementtype']));
431 if ($notifiedevent[
'elementtype'] ==
'order_supplier') {
432 $elementPicto =
'supplier_order';
433 $elementLabel = $langs->trans(
'SupplierOrder');
434 } elseif ($notifiedevent[
'elementtype'] ==
'propal') {
435 $elementLabel = $langs->trans(
'Proposal');
436 } elseif ($notifiedevent[
'elementtype'] ==
'facture') {
437 $elementPicto =
'bill';
438 $elementLabel = $langs->trans(
'Bill');
439 } elseif ($notifiedevent[
'elementtype'] ==
'commande') {
440 $elementPicto =
'order';
441 $elementLabel = $langs->trans(
'Order');
442 } elseif ($notifiedevent[
'elementtype'] ==
'ficheinter') {
443 $elementPicto =
'intervention';
444 $elementLabel = $langs->trans(
'Intervention');
445 } elseif ($notifiedevent[
'elementtype'] ==
'shipping') {
446 $elementPicto =
'shipment';
447 $elementLabel = $langs->trans(
'Shipping');
448 } elseif ($notifiedevent[
'elementtype'] ==
'expensereport' || $notifiedevent[
'elementtype'] ==
'expense_report') {
449 $elementPicto =
'expensereport';
450 $elementLabel = $langs->trans(
'ExpenseReport');
451 } elseif ($notifiedevent[
'elementtype'] ==
'contrat') {
452 $elementPicto =
'contract';
453 $elementLabel = $langs->trans(
'Contract');
454 } elseif ($notifiedevent[
'elementtype'] ==
'agenda') {
455 $elementPicto =
'action';
458 $labelfortrigger =
'AmountHT';
459 $codehasnotrigger = 0;
460 if (preg_match(
'/^(ACTION|HOLIDAY)/', $notifiedevent[
'code'])) {
464 print
'<tr class="oddeven">';
466 print
img_picto(
'', $elementPicto,
'class="pictofixedwidth"');
469 print
'<td>'.$notifiedevent[
'code'].
'</td>';
470 print
'<td><span class="opacitymedium">'.$label.
'</span></td>';
472 $inputfieldalreadyshown = 0;
474 foreach (
$conf->global as $key => $val) {
475 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.preg_quote($notifiedevent[
'code'],
'/').
'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
479 $param =
'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_'.$reg[1];
480 $value =
GETPOST(
'NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key') ?
GETPOST(
'NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key',
'alpha') :
getDolGlobalString($param);
482 $s =
'<input type="text" class="minwidth200" name="NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key" value="'.
dol_escape_htmltag($value).
'">';
483 $arrayemail = explode(
',', $value);
485 foreach ($arrayemail as $keydet => $valuedet) {
486 $valuedet = trim($valuedet);
492 $s .=
' '.img_warning($langs->trans(
"ErrorBadEMail"));
494 print $form->textwithpicto($s, $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients").
'<br>'.$langs->trans(
"YouCanAlsoUseSupervisorKeyword"), 1,
'help',
'', 0, 2);
497 $inputfieldalreadyshown++;
500 if (empty($inputfieldalreadyshown) || !$codehasnotrigger) {
501 $s =
'<input type="text" class="minwidth200" name="NOTIF_'.$notifiedevent[
'code'].
'_new_key" value="">';
502 print $form->textwithpicto($s, $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients").
'<br>'.$langs->trans(
"YouCanAlsoUseSupervisorKeyword"), 1,
'help',
'', 0, 2);
508 $inputfieldalreadyshown = 0;
509 foreach (
$conf->global as $key => $val) {
510 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
514 if (!$codehasnotrigger) {
515 print $langs->trans($labelfortrigger).
' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_amount" value="'.
dol_escape_htmltag($reg[1]).
'">';
518 $inputfieldalreadyshown++;
522 if (!$codehasnotrigger) {
523 print $langs->trans($labelfortrigger).
' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent[
'code'].
'_new_amount" value="">';
536print $form->buttonsSaveCancel(
"Save",
'');
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).
form_constantes($tableau, $strictw3c=2, $helptext='', $text='Value')
Show array with constants to edit.
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.