30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_50_modNotification_Notification.class.php';
36$langs->loadLangs(array(
'admin',
'other',
'orders',
'propal',
'bills',
'errors',
'mails',
'contracts'));
43$action =
GETPOST(
'action',
'aZ09');
52if ($action ==
'settemplates' && $user->admin) {
55 if (!$error && is_array($_POST)) {
57 foreach ($_POST as $key => $val) {
58 if (!preg_match(
'/^constvalue_(.*)_TEMPLATE/', $key, $reg)) {
62 $triggername = $reg[1];
63 $constvalue =
GETPOST($key,
'alpha');
64 $consttype =
'emailtemplate:xxx';
65 $tmparray = explode(
':', $constvalue);
66 if (!empty($tmparray[0]) && !empty($tmparray[1])) {
67 $constvalue = $tmparray[0];
68 $consttype =
'emailtemplate:'.$tmparray[1];
71 $res =
dolibarr_set_const($db, $triggername.
'_TEMPLATE', $constvalue, $consttype, 0,
'', $conf->entity);
94if ($action ==
'setvalue' && $user->admin) {
97 $result =
dolibarr_set_const($db,
"NOTIFICATION_EMAIL_FROM",
GETPOST(
"email_from",
"alphawithlgt"),
'chaine', 0,
'', $conf->entity);
102 $result =
dolibarr_set_const($db,
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE",
GETPOST(
"notif_disable",
"alphawithlgt"),
'chaine', 0,
'', $conf->entity);
119if ($action ==
'setfixednotif' && $user->admin) {
122 if (!$error && is_array($_POST)) {
124 foreach ($_POST as $key => $val) {
125 if (!preg_match(
'/^NOTIF_(.*)_key$/', $key, $reg)) {
132 $shortkey = preg_replace(
'/_key$/',
'', $key);
135 if (preg_match(
'/^NOTIF_(.*)_old_(.*)_key/', $key, $reg)) {
136 dolibarr_del_const($db,
'NOTIFICATION_FIXEDEMAIL_'.$reg[1].
'_THRESHOLD_HIGHER_'.$reg[2], $conf->entity);
138 $newkey =
'NOTIFICATION_FIXEDEMAIL_'.$reg[1].
'_THRESHOLD_HIGHER_'.((int)
GETPOST($shortkey.
'_amount'));
139 $newval =
GETPOST($shortkey.
'_key');
141 } elseif (preg_match(
'/^NOTIF_(.*)_new_key/', $key, $reg)) {
143 $newkey =
'NOTIFICATION_FIXEDEMAIL_'.$reg[1].
'_THRESHOLD_HIGHER_'.((int)
GETPOST($shortkey.
'_amount'));
144 $newval =
GETPOST($shortkey.
'_key');
147 if ($newkey && $newval) {
170$form =
new Form($db);
173llxHeader(
'', $langs->trans(
"NotificationSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-notification');
175$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
176print
load_fiche_titre($langs->trans(
"NotificationSetup"), $linkback,
'title_setup');
178print
'<span class="opacitymedium">';
179print $langs->trans(
"NotificationsDesc").
'<br>';
180print $langs->trans(
"NotificationsDescUser").
'<br>';
181if (isModEnabled(
"societe")) {
182 print $langs->trans(
"NotificationsDescContact").
'<br>';
184print $langs->trans(
"NotificationsDescGlobal").
' - '.$langs->trans(
"YouAreHere").
'<br>';
188print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
189print
'<input type="hidden" name="token" value="'.newToken().
'">';
190print
'<input type="hidden" name="action" value="setvalue">';
192print
'<div class="div-table-responsive-no-min">';
193print
'<table class="noborder centpercent">';
194print
'<tr class="liste_titre">';
195print
'<td>'.$langs->trans(
"Parameter").
'</td>';
196print
'<td>'.$langs->trans(
"Value").
'</td>';
200print
'<tr class="oddeven"><td>';
201print $langs->trans(
"NotificationEMailFrom").
'</td>';
203print
img_picto(
'',
'email',
'class="pictofixedwidth"');
204print
'<input class="width150 quatrevingtpercentminusx" type="email" name="email_from" value="'.getDolGlobalString(
'NOTIFICATION_EMAIL_FROM').
'">';
206 print
' '.img_warning($langs->trans(
"ErrorBadEMail"));
212print
'<tr class="oddeven"><td>';
213print $langs->trans(
"NotificationDisableConfirmMessageUser").
'</td>';
215if ($conf->use_javascript_ajax) {
216 print ajax_constantonoff(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER');
218 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
219 print $form->selectarray(
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER", $arrval,
getDolGlobalString(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER'));
225print
'<tr class="oddeven"><td>';
226print $langs->trans(
"NotificationDisableConfirmMessageContact").
'</td>';
228if ($conf->use_javascript_ajax) {
229 print ajax_constantonoff(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT');
231 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
232 print $form->selectarray(
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT", $arrval,
getDolGlobalString(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT'));
238print
'<tr class="oddeven"><td>';
239print $langs->trans(
"NotificationDisableConfirmMessageFix").
'</td>';
241if ($conf->use_javascript_ajax) {
242 print ajax_constantonoff(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX');
244 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
245 print $form->selectarray(
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX", $arrval,
getDolGlobalString(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX'));
254print $form->buttonsSaveCancel(
"Save",
'');
264print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
265print
'<input type="hidden" name="token" value="'.newToken().
'">';
266print
'<input type="hidden" name="action" value="settemplates">';
268$title = $langs->trans(
"TemplatesForNotifications");
274$listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
277$constantes = array();
278foreach ($listofnotifiedevents as $notifiedevent) {
279 $label = $langs->trans(
"Notify_".$notifiedevent[
'code']);
280 $elementLabel = $langs->trans(ucfirst($notifiedevent[
'elementtype']));
282 $model = $notifiedevent[
'elementtype'];
284 if ($notifiedevent[
'elementtype'] ==
'order_supplier') {
285 $elementLabel = $langs->trans(
'SupplierOrder');
286 } elseif ($notifiedevent[
'elementtype'] ==
'propal') {
287 $elementLabel = $langs->trans(
'Proposal');
288 } elseif ($notifiedevent[
'elementtype'] ==
'facture') {
289 $elementLabel = $langs->trans(
'Bill');
290 } elseif ($notifiedevent[
'elementtype'] ==
'commande') {
291 $elementLabel = $langs->trans(
'Order');
292 } elseif ($notifiedevent[
'elementtype'] ==
'ficheinter') {
293 $elementLabel = $langs->trans(
'Intervention');
294 } elseif ($notifiedevent[
'elementtype'] ==
'shipping') {
295 $elementLabel = $langs->trans(
'Shipping');
296 } elseif ($notifiedevent[
'elementtype'] ==
'expensereport' || $notifiedevent[
'elementtype'] ==
'expense_report') {
297 $elementLabel = $langs->trans(
'ExpenseReport');
298 } elseif ($notifiedevent[
'elementtype'] ==
'contrat') {
299 $elementLabel = $langs->trans(
'Contract');
302 if ($notifiedevent[
'elementtype'] ==
'propal') {
303 $model =
'propal_send';
304 } elseif ($notifiedevent[
'elementtype'] ==
'commande') {
305 $model =
'order_send';
306 } elseif ($notifiedevent[
'elementtype'] ==
'facture') {
307 $model =
'facture_send';
308 } elseif ($notifiedevent[
'elementtype'] ==
'shipping') {
309 $model =
'shipping_send';
310 } elseif ($notifiedevent[
'elementtype'] ==
'ficheinter') {
311 $model =
'fichinter_send';
312 } elseif ($notifiedevent[
'elementtype'] ==
'expensereport') {
313 $model =
'expensereport_send';
314 } elseif ($notifiedevent[
'elementtype'] ==
'order_supplier') {
315 $model =
'order_supplier_send';
316 } elseif ($notifiedevent[
'elementtype'] ==
'invoice_supplier') {
317 $model =
'invoice_supplier_send';
318 } elseif ($notifiedevent[
'elementtype'] ==
'member') {
320 } elseif ($notifiedevent[
'elementtype'] ==
'contrat') {
321 $model =
'contract_send';
324 $constantes[$notifiedevent[
'code'].
'_TEMPLATE'] = array(
'type'=>
'emailtemplate:'.$model,
'label'=>$label);
327$helptext = $langs->trans(
"EmailTemplateHelp", $langs->transnoentitiesnoconv(
"Tools"), $langs->transnoentitiesnoconv(
"EMailTemplates"));
330print $form->buttonsSaveCancel(
"Save",
'');
390print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
391print
'<input type="hidden" name="token" value="'.newToken().
'">';
392print
'<input type="hidden" name="action" value="setfixednotif">';
393print
'<input type="hidden" name="page_y" value="">';
395print
load_fiche_titre($langs->trans(
"ListOfFixedNotifications"),
'',
'email');
397print
'<div class="info">';
398print $langs->trans(
"Note").
':<br>';
399print
'* '.$langs->trans(
"GoOntoUserCardToAddMore").
'<br>';
400if (isModEnabled(
"societe")) {
401 print
'** '.$langs->trans(
"GoOntoContactCardToAddMore").
'<br>';
405print
'<div class="div-table-responsive">';
406print
'<table class="noborder centpercent">';
407print
'<tr class="liste_titre">';
408print
'<td>'.$langs->trans(
"Module").
'</td>';
409print
'<td>'.$langs->trans(
"Code").
'</td>';
410print
'<td>'.$langs->trans(
"Label").
'</td>';
411print
'<td>'.$langs->trans(
"FixedEmailTarget").
'</td>';
412print
'<td>'.$langs->trans(
"Threshold").
'</td>';
416foreach ($listofnotifiedevents as $notifiedevent) {
417 $label = $langs->trans(
"Notify_".$notifiedevent[
'code']);
419 $elementPicto = $notifiedevent[
'elementtype'];
420 $elementLabel = $langs->trans(ucfirst($notifiedevent[
'elementtype']));
422 if ($notifiedevent[
'elementtype'] ==
'order_supplier') {
423 $elementPicto =
'supplier_order';
424 $elementLabel = $langs->trans(
'SupplierOrder');
425 } elseif ($notifiedevent[
'elementtype'] ==
'propal') {
426 $elementLabel = $langs->trans(
'Proposal');
427 } elseif ($notifiedevent[
'elementtype'] ==
'facture') {
428 $elementPicto =
'bill';
429 $elementLabel = $langs->trans(
'Bill');
430 } elseif ($notifiedevent[
'elementtype'] ==
'commande') {
431 $elementPicto =
'order';
432 $elementLabel = $langs->trans(
'Order');
433 } elseif ($notifiedevent[
'elementtype'] ==
'ficheinter') {
434 $elementPicto =
'intervention';
435 $elementLabel = $langs->trans(
'Intervention');
436 } elseif ($notifiedevent[
'elementtype'] ==
'shipping') {
437 $elementPicto =
'shipment';
438 $elementLabel = $langs->trans(
'Shipping');
439 } elseif ($notifiedevent[
'elementtype'] ==
'expensereport' || $notifiedevent[
'elementtype'] ==
'expense_report') {
440 $elementPicto =
'expensereport';
441 $elementLabel = $langs->trans(
'ExpenseReport');
442 } elseif ($notifiedevent[
'elementtype'] ==
'contrat') {
443 $elementPicto =
'contract';
444 $elementLabel = $langs->trans(
'Contract');
445 } elseif ($notifiedevent[
'elementtype'] ==
'agenda') {
446 $elementPicto =
'action';
449 $labelfortrigger =
'AmountHT';
450 $codehasnotrigger = 0;
451 if (preg_match(
'/^(ACTION|HOLIDAY)/', $notifiedevent[
'code'])) {
455 print
'<tr class="oddeven">';
457 print
img_picto(
'', $elementPicto,
'class="pictofixedwidth"');
460 print
'<td>'.$notifiedevent[
'code'].
'</td>';
461 print
'<td><span class="opacitymedium">'.$label.
'</span></td>';
463 $inputfieldalreadyshown = 0;
465 foreach ($conf->global as $key => $val) {
466 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.preg_quote($notifiedevent[
'code'],
'/').
'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
470 $param =
'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_'.$reg[1];
471 $value =
GETPOST(
'NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key') ?
GETPOST(
'NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key',
'alpha') :
getDolGlobalString($param);
473 $s =
'<input type="text" class="minwidth200" name="NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key" value="'.
dol_escape_htmltag($value).
'">';
474 $arrayemail = explode(
',', $value);
476 foreach ($arrayemail as $keydet => $valuedet) {
477 $valuedet = trim($valuedet);
483 $s .=
' '.img_warning($langs->trans(
"ErrorBadEMail"));
485 print $form->textwithpicto($s, $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients").
'<br>'.$langs->trans(
"YouCanAlsoUseSupervisorKeyword"), 1,
'help',
'', 0, 2);
488 $inputfieldalreadyshown++;
491 if (empty($inputfieldalreadyshown) || !$codehasnotrigger) {
492 $s =
'<input type="text" class="minwidth200" name="NOTIF_'.$notifiedevent[
'code'].
'_new_key" value="">';
493 print $form->textwithpicto($s, $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients").
'<br>'.$langs->trans(
"YouCanAlsoUseSupervisorKeyword"), 1,
'help',
'', 0, 2);
499 $inputfieldalreadyshown = 0;
500 foreach ($conf->global as $key => $val) {
501 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
505 if (!$codehasnotrigger) {
506 print $langs->trans($labelfortrigger).
' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_amount" value="'.
dol_escape_htmltag($reg[1]).
'">';
509 $inputfieldalreadyshown++;
513 if (!$codehasnotrigger) {
514 print $langs->trans($labelfortrigger).
' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent[
'code'].
'_new_amount" value="">';
527print $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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.