28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_50_modNotification_Notification.class.php';
34 $langs->loadLangs(array(
'admin',
'other',
'orders',
'propal',
'bills',
'errors',
'mails'));
41 $action =
GETPOST(
'action',
'aZ09');
50 if ($action ==
'settemplates')
54 if (!$error && is_array($_POST))
57 foreach ($_POST as $key => $val)
59 if (!preg_match(
'/^constvalue_(.*)_TEMPLATE/', $key, $reg))
continue;
61 $triggername = $reg[1];
62 $constvalue =
GETPOST($key,
'alpha');
63 $consttype =
'emailtemplate:xxx';
64 $tmparray = explode(
':', $constvalue);
65 if (!empty($tmparray[0]) && !empty($tmparray[1])) {
66 $constvalue = $tmparray[0];
67 $consttype =
'emailtemplate:'.$tmparray[1];
70 $res =
dolibarr_set_const($db, $triggername.
'_TEMPLATE', $constvalue, $consttype, 0,
'', $conf->entity);
94 if ($action ==
'setvalue' && $user->admin)
98 $result =
dolibarr_set_const($db,
"NOTIFICATION_EMAIL_FROM",
GETPOST(
"email_from",
"restricthtml"),
'chaine', 0,
'', $conf->entity);
99 if ($result < 0) $error++;
115 if ($action ==
'setfixednotif' && $user->admin)
119 if (!$error && is_array($_POST))
122 foreach ($_POST as $key => $val)
124 if (!preg_match(
'/^NOTIF_(.*)_key$/', $key, $reg))
continue;
129 $shortkey = preg_replace(
'/_key$/',
'', $key);
132 if (preg_match(
'/^NOTIF_(.*)_old_(.*)_key/', $key, $reg))
134 dolibarr_del_const($db,
'NOTIFICATION_FIXEDEMAIL_'.$reg[1].
'_THRESHOLD_HIGHER_'.$reg[2], $conf->entity);
136 $newkey =
'NOTIFICATION_FIXEDEMAIL_'.$reg[1].
'_THRESHOLD_HIGHER_'.((int)
GETPOST($shortkey.
'_amount'));
137 $newval =
GETPOST($shortkey.
'_key');
139 } elseif (preg_match(
'/^NOTIF_(.*)_new_key/', $key, $reg))
142 $newkey =
'NOTIFICATION_FIXEDEMAIL_'.$reg[1].
'_THRESHOLD_HIGHER_'.((int)
GETPOST($shortkey.
'_amount'));
143 $newval =
GETPOST($shortkey.
'_key');
146 if ($newkey && $newval)
171 $form =
new Form($db);
172 $notify =
new Notify($db);
174 llxHeader(
'', $langs->trans(
"NotificationSetup"));
176 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
179 print '<span class="opacitymedium">';
180 print $langs->trans(
"NotificationsDesc").
'<br>';
181 print $langs->trans(
"NotificationsDescUser").
'<br>';
182 if (!empty($conf->societe->enabled)) print $langs->trans(
"NotificationsDescContact").
'<br>';
183 print $langs->trans(
"NotificationsDescGlobal").
'<br>';
187 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
188 print
'<input type="hidden" name="token" value="'.newToken().
'">';
189 print
'<input type="hidden" name="action" value="setvalue">';
191 print
'<table class="noborder centpercent">';
192 print
'<tr class="liste_titre">';
193 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
194 print
'<td>'.$langs->trans(
"Value").
'</td>';
197 print
'<tr class="oddeven"><td>';
198 print $langs->trans(
"NotificationEMailFrom").
'</td>';
200 print
'<input size="32" type="email" name="email_from" value="'.$conf->global->NOTIFICATION_EMAIL_FROM.
'">';
201 if (!empty($conf->global->NOTIFICATION_EMAIL_FROM) && !
isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print
' '.img_warning($langs->trans(
"ErrorBadEMail"));
206 print
'<div class="center"><input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'"></div>';
214 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
215 print
'<input type="hidden" name="token" value="'.newToken().
'">';
216 print
'<input type="hidden" name="action" value="settemplates">';
219 $title = $langs->trans(
"ListOfNotificationsPerUser");
220 if (!empty($conf->societe->enabled)) $title = $langs->trans(
"ListOfNotificationsPerUserOrContact");
225 $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
228 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
230 $constantes = array();
231 foreach ($listofnotifiedevents as $notifiedevent)
233 $label = $langs->trans(
"Notify_".$notifiedevent[
'code']);
234 $elementLabel = $langs->trans(ucfirst($notifiedevent[
'elementtype']));
236 if ($notifiedevent[
'elementtype'] ==
'order_supplier') $elementLabel = $langs->trans(
'SupplierOrder');
237 elseif ($notifiedevent[
'elementtype'] ==
'propal') $elementLabel = $langs->trans('Proposal');
238 elseif ($notifiedevent['elementtype'] == 'facture') $elementLabel = $langs->trans('Bill');
239 elseif ($notifiedevent['elementtype'] == 'commande') $elementLabel = $langs->trans('Order');
240 elseif ($notifiedevent['elementtype'] == 'ficheinter') $elementLabel = $langs->trans('Intervention');
241 elseif ($notifiedevent['elementtype'] == 'shipping') $elementLabel = $langs->trans('Shipping');
242 elseif ($notifiedevent['elementtype'] == 'expensereport') $elementLabel = $langs->trans('
ExpenseReport');
244 if ($notifiedevent['elementtype'] == 'propal') $model = 'propal_send';
245 elseif ($notifiedevent['elementtype'] == 'commande') $model = 'order_send';
246 elseif ($notifiedevent['elementtype'] == 'facture') $model = 'facture_send';
247 elseif ($notifiedevent['elementtype'] == 'shipping') $model = 'shipping_send';
248 elseif ($notifiedevent['elementtype'] == 'ficheinter') $model = 'fichinter_send';
249 elseif ($notifiedevent['elementtype'] == 'expensereport') $model = 'expensereport_send';
250 elseif ($notifiedevent['elementtype'] == 'order_supplier') $model = 'order_supplier_send';
252 elseif ($notifiedevent['elementtype'] == 'member') $model = 'member';
254 $constantes[$notifiedevent['
code'].'_TEMPLATE'] = array('
type'=>'emailtemplate:'.$model, 'label'=>$label);
260 print
'<table class="noborder centpercent">';
261 print
'<tr class="liste_titre">';
262 print
'<td>'.$langs->trans(
"Label").
'</td>';
268 print
'<tr class="oddeven">';
272 foreach ($listofnotifiedevents as $notifiedevent)
274 $label = $langs->trans(
"Notify_".$notifiedevent[
'code']);
275 $elementLabel = $langs->trans(ucfirst($notifiedevent[
'elementtype']));
277 if ($notifiedevent[
'elementtype'] ==
'order_supplier') $elementLabel = $langs->trans(
'SupplierOrder');
278 elseif ($notifiedevent[
'elementtype'] ==
'propal') $elementLabel = $langs->trans('Proposal');
279 elseif ($notifiedevent['elementtype'] == 'facture') $elementLabel = $langs->trans('Bill');
280 elseif ($notifiedevent['elementtype'] == 'commande') $elementLabel = $langs->trans('Order');
281 elseif ($notifiedevent['elementtype'] == 'ficheinter') $elementLabel = $langs->trans('Intervention');
282 elseif ($notifiedevent['elementtype'] == 'shipping') $elementLabel = $langs->trans('Shipping');
283 elseif ($notifiedevent['elementtype'] == 'expensereport') $elementLabel = $langs->trans('ExpenseReport');
295 print '<div class="center"><input
type="submit" class="button button-save" value="'.$langs->trans("Save").'"></div>';
303 print '<form method="post" action="'.
$_SERVER["PHP_SELF"].'">';
305 print '<input
type="hidden"
name="action" value="setfixednotif">';
309 print '<table class="noborder centpercent">';
310 print '<tr class="liste_titre">';
311 print '<td>'.$langs->trans("Module").'</td>';
312 print '<td>'.$langs->trans("Code").'</td>';
313 print '<td>'.$langs->trans("Label").'</td>';
314 print '<td>'.$langs->trans("FixedEmailTarget").'</td>';
315 print '<td>'.$langs->trans("Threshold").'</td>';
319 foreach ($listofnotifiedevents as $notifiedevent)
321 $label = $langs->trans(
"Notify_".$notifiedevent[
'code']);
323 $elementLabel = $langs->trans(ucfirst($notifiedevent[
'elementtype']));
325 if ($notifiedevent[
'elementtype'] ==
'order_supplier') $elementLabel = $langs->trans(
'SupplierOrder');
326 elseif ($notifiedevent[
'elementtype'] ==
'propal') $elementLabel = $langs->trans('Proposal');
327 elseif ($notifiedevent['elementtype'] == 'facture') $elementLabel = $langs->trans('Bill');
328 elseif ($notifiedevent['elementtype'] == 'commande') $elementLabel = $langs->trans('Order');
329 elseif ($notifiedevent['elementtype'] == 'ficheinter') $elementLabel = $langs->trans('Intervention');
330 elseif ($notifiedevent['elementtype'] == 'shipping') $elementLabel = $langs->trans('Shipping');
331 elseif ($notifiedevent['elementtype'] == 'expensereport') $elementLabel = $langs->trans('ExpenseReport');
333 print '<tr class="oddeven">';
334 print '<td>'.$elementLabel.'</td>';
335 print '<td>'.$notifiedevent['
code'].'</td>';
336 print '<td>'.$label.'</td>';
339 foreach ($conf->global as $key => $val)
341 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_(.*)/', $key, $reg))
continue;
343 $param =
'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_'.$reg[1];
344 $value =
GETPOST(
'NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key') ?
GETPOST(
'NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key',
'alpha') : $conf->global->$param;
346 $s =
'<input type="text" size="32" name="NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_key" value="'.
dol_escape_htmltag($value).
'">';
347 $arrayemail = explode(
',', $value);
349 foreach ($arrayemail as $keydet => $valuedet)
351 $valuedet = trim($valuedet);
352 if (!empty($valuedet) && !
isValidEmail($valuedet, 1)) $showwarning++;
354 if ((!empty($conf->global->$param)) && $showwarning) $s .=
' '.img_warning($langs->trans(
"ErrorBadEMail"));
355 print $form->textwithpicto($s, $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients").
'<br>'.$langs->trans(
"YouCanAlsoUseSupervisorKeyword"), 1,
'help',
'', 0, 2);
359 $s =
'<input type="text" size="32" name="NOTIF_'.$notifiedevent[
'code'].
'_new_key" value="">';
360 print $form->textwithpicto($s, $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients").
'<br>'.$langs->trans(
"YouCanAlsoUseSupervisorKeyword"), 1,
'help',
'', 0, 2);
365 foreach ($conf->global as $key => $val)
367 if ($val ==
'' || !preg_match(
'/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent[
'code'].
'_THRESHOLD_HIGHER_(.*)/', $key, $reg))
continue;
369 print $langs->trans(
"AmountHT").
' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent[
'code'].
'_old_'.$reg[1].
'_amount" value="'.
dol_escape_htmltag($reg[1]).
'">';
373 print $langs->trans(
"AmountHT").
' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent[
'code'].
'_new_amount" value="">';
384 print
'<div class="opacitymedium">';
385 print
'* '.$langs->trans(
"GoOntoUserCardToAddMore").
'<br>';
386 if (!empty($conf->societe->enabled)) print
'** '.$langs->trans(
"GoOntoContactCardToAddMore").
'<br>';
392 print
'<div class="center"><input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'"></div>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage notifications.
if(!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'] country if(!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'] typent code
Class of triggers for notification module.
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).
$conf db name
Only used if Module[ID]Name translation string is not found.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
form_constantes($tableau, $strictw3c=0, $helptext= '')
Show array with constants to edit.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage Trips and Expenses.
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print $_SERVER["PHP_SELF"] n
Edit parameters.
isValidEmail($address, $acceptsupervisorkey=0)
Return true if email syntax is ok.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...