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];
101if ($action ==
'setvalue') {
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) {
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"]).
'">';
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"]).
'">';
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') {
331 $model =
'contract_send';
334 $constantes[$notifiedevent[
'code'].
'_TEMPLATE'] = array(
'type'=>
'emailtemplate:'.$model,
'label'=>$label);
337$helptext = $langs->trans(
"EmailTemplateHelp", $langs->transnoentitiesnoconv(
"Tools"), $langs->transnoentitiesnoconv(
"EMailTemplates"));
340print $form->buttonsSaveCancel(
"Save",
'');
400print
'<form method="post" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
401print
'<input type="hidden" name="token" value="'.newToken().
'">';
402print
'<input type="hidden" name="action" value="setfixednotif">';
403print
'<input type="hidden" name="page_y" value="">';
405print
load_fiche_titre($langs->trans(
"ListOfFixedNotifications"),
'',
'email');
407print
'<div class="info">';
408print $langs->trans(
"Note").
':<br>';
409print
'* '.$langs->trans(
"GoOntoUserCardToAddMore").
'<br>';
411 print
'** '.$langs->trans(
"GoOntoContactCardToAddMore").
'<br>';
415print
'<div class="div-table-responsive">';
416print
'<table class="noborder centpercent">';
417print
'<tr class="liste_titre">';
418print
'<td>'.$langs->trans(
"Module").
'</td>';
419print
'<td>'.$langs->trans(
"Code").
'</td>';
420print
'<td>'.$langs->trans(
"Label").
'</td>';
421print
'<td>'.$langs->trans(
"FixedEmailTarget").
'</td>';
422print
'<td>'.$langs->trans(
"Threshold").
'</td>';
426foreach ($listofnotifiedevents as $notifiedevent) {
427 $label = $langs->trans(
"Notify_".$notifiedevent[
'code']);
429 $elementPicto = $notifiedevent[
'elementtype'];
430 $elementLabel = $langs->trans(ucfirst($notifiedevent[
'elementtype']));
432 if ($notifiedevent[
'elementtype'] ==
'order_supplier') {
433 $elementPicto =
'supplier_order';
434 $elementLabel = $langs->trans(
'SupplierOrder');
435 } elseif ($notifiedevent[
'elementtype'] ==
'propal') {
436 $elementLabel = $langs->trans(
'Proposal');
437 } elseif ($notifiedevent[
'elementtype'] ==
'facture') {
438 $elementPicto =
'bill';
439 $elementLabel = $langs->trans(
'Bill');
440 } elseif ($notifiedevent[
'elementtype'] ==
'commande') {
441 $elementPicto =
'order';
442 $elementLabel = $langs->trans(
'Order');
443 } elseif ($notifiedevent[
'elementtype'] ==
'ficheinter') {
444 $elementPicto =
'intervention';
445 $elementLabel = $langs->trans(
'Intervention');
446 } elseif ($notifiedevent[
'elementtype'] ==
'shipping') {
447 $elementPicto =
'shipment';
448 $elementLabel = $langs->trans(
'Shipping');
449 } elseif ($notifiedevent[
'elementtype'] ==
'societe') {
450 $elementPicto =
'company';
451 } elseif ($notifiedevent[
'elementtype'] ==
'expensereport' || $notifiedevent[
'elementtype'] ==
'expense_report') {
452 $elementPicto =
'expensereport';
453 $elementLabel = $langs->trans(
'ExpenseReport');
454 } elseif ($notifiedevent[
'elementtype'] ==
'contrat') {
455 $elementPicto =
'contract';
456 $elementLabel = $langs->trans(
'Contract');
457 } elseif ($notifiedevent[
'elementtype'] ==
'agenda') {
458 $elementPicto =
'action';
461 $labelfortrigger =
'AmountHT';
462 $codehasnotrigger = 0;
463 if (preg_match(
'/^(ACTION|HOLIDAY)/', $notifiedevent[
'code'])) {
467 print
'<tr class="oddeven">';
469 print
img_picto(
'', $elementPicto,
'class="pictofixedwidth"');
472 print
'<td>'.$notifiedevent[
'code'].
'</td>';
473 print
'<td><span class="opacitymedium">'.$label.
'</span></td>';
475 $inputfieldalreadyshown = 0;
477 foreach (
$conf->global as $key => $val) {
478 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.preg_quote($notifiedevent[
'code'],
'/').
'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
482 $param =
'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_'.$reg[1];
483 $value =
GETPOST(
'NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key') ?
GETPOST(
'NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key',
'alpha') :
getDolGlobalString($param);
485 $s =
'<input type="text" class="minwidth200" name="NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key" value="'.
dol_escape_htmltag($value).
'">';
486 $arrayemail = explode(
',', $value);
488 foreach ($arrayemail as $keydet => $valuedet) {
489 $valuedet = trim($valuedet);
490 if (!empty($valuedet) && $valuedet !=
'__SUPERVISOREMAIL__' && $valuedet !=
'__AUTHOREMAIL__' && !
isValidEmail($valuedet, 1)) {
495 $s .=
' '.img_warning($langs->trans(
"ErrorBadEMail"));
497 print $form->textwithpicto($s, $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients").
'<br>'.$langs->trans(
"YouCanAlsoUseSupervisorKeyword").
'<br>'.$langs->trans(
"YouCanAlsoUseAuthorKeyword"), 1,
'help',
'', 0, 2);
500 $inputfieldalreadyshown++;
503 if (empty($inputfieldalreadyshown) || !$codehasnotrigger) {
504 $s =
'<input type="text" class="minwidth200" name="NOTIF_'.$notifiedevent[
'code'].
'_new_key" value="">';
505 print $form->textwithpicto($s, $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients").
'<br>'.$langs->trans(
"YouCanAlsoUseSupervisorKeyword").
'<br>'.$langs->trans(
"YouCanAlsoUseAuthorKeyword"), 1,
'help',
'', 0, 2);
511 $inputfieldalreadyshown = 0;
512 foreach (
$conf->global as $key => $val) {
513 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
517 if (!$codehasnotrigger) {
518 print $langs->trans($labelfortrigger).
' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_amount" value="'.
dol_escape_htmltag($reg[1]).
'">';
521 $inputfieldalreadyshown++;
525 if (!$codehasnotrigger) {
526 print $langs->trans($labelfortrigger).
' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent[
'code'].
'_new_amount" value="">';
539print $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.
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, $allowothertags=array())
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
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.