30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_50_modNotification_Notification.class.php';
36 $langs->loadLangs(array(
'admin',
'other',
'orders',
'propal',
'bills',
'errors',
'mails'));
43 $action =
GETPOST(
'action',
'aZ09');
52 if ($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);
94 if ($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);
119 if ($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) {
171 $notify =
new Notify($db);
173 llxHeader(
'', $langs->trans(
"NotificationSetup"));
175 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
176 print
load_fiche_titre($langs->trans(
"NotificationSetup"), $linkback,
'title_setup');
178 print
'<span class="opacitymedium">';
179 print $langs->trans(
"NotificationsDesc").
'<br>';
180 print $langs->trans(
"NotificationsDescUser").
'<br>';
182 print $langs->trans(
"NotificationsDescContact").
'<br>';
184 print $langs->trans(
"NotificationsDescGlobal").
'<br>';
188 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
189 print
'<input type="hidden" name="token" value="'.newToken().
'">';
190 print
'<input type="hidden" name="action" value="setvalue">';
192 print
'<div class="div-table-responsive">';
193 print
'<table class="noborder centpercent">';
194 print
'<tr class="liste_titre">';
195 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
196 print
'<td>'.$langs->trans(
"Value").
'</td>';
199 print
'<tr class="oddeven"><td>';
200 print $langs->trans(
"NotificationEMailFrom").
'</td>';
202 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
203 print
'<input class="width150 quatrevingtpercentminusx" type="email" name="email_from" value="'.getDolGlobalString(
'NOTIFICATION_EMAIL_FROM').
'">';
204 if (!empty($conf->global->NOTIFICATION_EMAIL_FROM) && !
isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) {
205 print
' '.img_warning($langs->trans(
"ErrorBadEMail"));
210 print
'<tr class="oddeven"><td>';
211 print $langs->trans(
"NotificationDisableConfirmMessageContact").
'</td>';
213 if ($conf->use_javascript_ajax) {
216 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
217 print
$form->selectarray(
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT", $arrval,
getDolGlobalString(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT'));
222 print
'<tr class="oddeven"><td>';
223 print $langs->trans(
"NotificationDisableConfirmMessageUser").
'</td>';
225 if ($conf->use_javascript_ajax) {
228 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
229 print
$form->selectarray(
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER", $arrval,
getDolGlobalString(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER'));
234 print
'<tr class="oddeven"><td>';
235 print $langs->trans(
"NotificationDisableConfirmMessageFix").
'</td>';
237 if ($conf->use_javascript_ajax) {
240 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
241 print
$form->selectarray(
"NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX", $arrval,
getDolGlobalString(
'NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX'));
248 print
$form->buttonsSaveCancel(
"Save",
'');
256 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
257 print
'<input type="hidden" name="token" value="'.newToken().
'">';
258 print
'<input type="hidden" name="action" value="settemplates">';
261 $title = $langs->trans(
"TemplatesForNotifications");
267 $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
270 $constantes = array();
271 foreach ($listofnotifiedevents as $notifiedevent) {
272 $label = $langs->trans(
"Notify_".$notifiedevent[
'code']);
273 $elementLabel = $langs->trans(ucfirst($notifiedevent[
'elementtype']));
275 $model = $notifiedevent[
'elementtype'];
277 if ($notifiedevent[
'elementtype'] ==
'order_supplier') {
278 $elementLabel = $langs->trans(
'SupplierOrder');
279 } elseif ($notifiedevent[
'elementtype'] ==
'propal') {
280 $elementLabel = $langs->trans(
'Proposal');
281 } elseif ($notifiedevent[
'elementtype'] ==
'facture') {
282 $elementLabel = $langs->trans(
'Bill');
283 } elseif ($notifiedevent[
'elementtype'] ==
'commande') {
284 $elementLabel = $langs->trans(
'Order');
285 } elseif ($notifiedevent[
'elementtype'] ==
'ficheinter') {
286 $elementLabel = $langs->trans(
'Intervention');
287 } elseif ($notifiedevent[
'elementtype'] ==
'shipping') {
288 $elementLabel = $langs->trans(
'Shipping');
289 } elseif ($notifiedevent[
'elementtype'] ==
'expensereport' || $notifiedevent[
'elementtype'] ==
'expense_report') {
290 $elementLabel = $langs->trans(
'ExpenseReport');
293 if ($notifiedevent[
'elementtype'] ==
'propal') {
294 $model =
'propal_send';
295 } elseif ($notifiedevent[
'elementtype'] ==
'commande') {
296 $model =
'order_send';
297 } elseif ($notifiedevent[
'elementtype'] ==
'facture') {
298 $model =
'facture_send';
299 } elseif ($notifiedevent[
'elementtype'] ==
'shipping') {
300 $model =
'shipping_send';
301 } elseif ($notifiedevent[
'elementtype'] ==
'ficheinter') {
302 $model =
'fichinter_send';
303 } elseif ($notifiedevent[
'elementtype'] ==
'expensereport') {
304 $model =
'expensereport_send';
305 } elseif ($notifiedevent[
'elementtype'] ==
'order_supplier') {
306 $model =
'order_supplier_send';
308 } elseif ($notifiedevent[
'elementtype'] ==
'member') {
312 $constantes[$notifiedevent[
'code'].
'_TEMPLATE'] = array(
'type'=>
'emailtemplate:'.$model,
'label'=>$label);
318 print
$form->buttonsSaveCancel(
"Save",
'');
378 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
379 print
'<input type="hidden" name="token" value="'.newToken().
'">';
380 print
'<input type="hidden" name="action" value="setfixednotif">';
381 print
'<input type="hidden" name="page_y" value="">';
383 print
load_fiche_titre($langs->trans(
"ListOfFixedNotifications"),
'',
'email');
385 print
'<div class="info">';
386 print $langs->trans(
"Note").
':<br>';
387 print
'* '.$langs->trans(
"GoOntoUserCardToAddMore").
'<br>';
389 print
'** '.$langs->trans(
"GoOntoContactCardToAddMore").
'<br>';
393 print
'<div class="div-table-responsive">';
394 print
'<table class="noborder centpercent">';
395 print
'<tr class="liste_titre">';
396 print
'<td>'.$langs->trans(
"Module").
'</td>';
397 print
'<td>'.$langs->trans(
"Code").
'</td>';
398 print
'<td>'.$langs->trans(
"Label").
'</td>';
399 print
'<td>'.$langs->trans(
"FixedEmailTarget").
'</td>';
400 print
'<td>'.$langs->trans(
"Threshold").
'</td>';
404 foreach ($listofnotifiedevents as $notifiedevent) {
405 $label = $langs->trans(
"Notify_".$notifiedevent[
'code']);
407 $elementPicto = $notifiedevent[
'elementtype'];
408 $elementLabel = $langs->trans(ucfirst($notifiedevent[
'elementtype']));
410 if ($notifiedevent[
'elementtype'] ==
'order_supplier') {
411 $elementPicto =
'supplier_order';
412 $elementLabel = $langs->trans(
'SupplierOrder');
413 } elseif ($notifiedevent[
'elementtype'] ==
'propal') {
414 $elementLabel = $langs->trans(
'Proposal');
415 } elseif ($notifiedevent[
'elementtype'] ==
'facture') {
416 $elementPicto =
'bill';
417 $elementLabel = $langs->trans(
'Bill');
418 } elseif ($notifiedevent[
'elementtype'] ==
'commande') {
419 $elementPicto =
'order';
420 $elementLabel = $langs->trans(
'Order');
421 } elseif ($notifiedevent[
'elementtype'] ==
'ficheinter') {
422 $elementPicto =
'intervention';
423 $elementLabel = $langs->trans(
'Intervention');
424 } elseif ($notifiedevent[
'elementtype'] ==
'shipping') {
425 $elementPicto =
'shipment';
426 $elementLabel = $langs->trans(
'Shipping');
427 } elseif ($notifiedevent[
'elementtype'] ==
'expensereport' || $notifiedevent[
'elementtype'] ==
'expense_report') {
428 $elementPicto =
'expensereport';
429 $elementLabel = $langs->trans(
'ExpenseReport');
432 $labelfortrigger =
'AmountHT';
433 $codehasnotrigger = 0;
434 if (preg_match(
'/^HOLIDAY/', $notifiedevent[
'code'])) {
438 print
'<tr class="oddeven">';
440 print
img_picto(
'', $elementPicto,
'class="pictofixedwidth"');
443 print
'<td>'.$notifiedevent[
'code'].
'</td>';
444 print
'<td><span class="opacitymedium">'.$label.
'</span></td>';
446 $inputfieldalreadyshown = 0;
448 foreach ($conf->global as $key => $val) {
449 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
453 $param =
'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_'.$reg[1];
454 $value =
GETPOST(
'NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key') ?
GETPOST(
'NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key',
'alpha') : $conf->global->$param;
456 $s =
'<input type="text" class="minwidth200" name="NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key" value="'.
dol_escape_htmltag($value).
'">';
457 $arrayemail = explode(
',', $value);
459 foreach ($arrayemail as $keydet => $valuedet) {
460 $valuedet = trim($valuedet);
465 if ((!empty($conf->global->$param)) && $showwarning) {
466 $s .=
' '.img_warning($langs->trans(
"ErrorBadEMail"));
468 print
$form->textwithpicto($s, $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients").
'<br>'.$langs->trans(
"YouCanAlsoUseSupervisorKeyword"), 1,
'help',
'', 0, 2);
471 $inputfieldalreadyshown++;
474 if (empty($inputfieldalreadyshown) || !$codehasnotrigger) {
475 $s =
'<input type="text" class="minwidth200" name="NOTIF_'.$notifiedevent[
'code'].
'_new_key" value="">';
476 print
$form->textwithpicto($s, $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients").
'<br>'.$langs->trans(
"YouCanAlsoUseSupervisorKeyword"), 1,
'help',
'', 0, 2);
482 $inputfieldalreadyshown = 0;
483 foreach ($conf->global as $key => $val) {
484 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
488 if (!$codehasnotrigger) {
489 print $langs->trans($labelfortrigger).
' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_amount" value="'.
dol_escape_htmltag($reg[1]).
'">';
492 $inputfieldalreadyshown++;
496 if (!$codehasnotrigger) {
497 print $langs->trans($labelfortrigger).
' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent[
'code'].
'_new_amount" value="">';
510 print
$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).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
form_constantes($tableau, $strictw3c=0, $helptext='', $text='Value')
Show array with constants to edit.
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='')
On/off button for constant.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class of triggers for notification module.
Class to manage notifications.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.