2006-08-05 20:21:19 +02:00
|
|
|
<?php
|
|
|
|
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2011-06-06 10:44:36 +02:00
|
|
|
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.org>
|
2013-08-20 16:10:01 +02:00
|
|
|
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
|
2006-08-05 20:21:19 +02:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2006-08-05 20:21:19 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2011-08-01 00:21:57 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-08-05 20:21:19 +02:00
|
|
|
*/
|
2009-07-30 00:03:20 +02:00
|
|
|
|
2006-08-05 20:21:19 +02:00
|
|
|
/**
|
2009-07-30 00:03:20 +02:00
|
|
|
* \file htdocs/admin/notification.php
|
|
|
|
|
* \ingroup notification
|
2011-06-06 10:44:36 +02:00
|
|
|
* \brief Page to setup notification module
|
2009-07-30 00:03:20 +02:00
|
|
|
*/
|
2006-08-05 20:21:19 +02:00
|
|
|
|
2012-08-22 23:24:21 +02:00
|
|
|
require '../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/triggers/interface_50_modNotification_Notification.class.php';
|
2006-08-05 20:21:19 +02:00
|
|
|
|
|
|
|
|
$langs->load("admin");
|
2011-09-06 12:52:42 +02:00
|
|
|
$langs->load("other");
|
2012-12-31 05:54:38 +01:00
|
|
|
$langs->load("orders");
|
|
|
|
|
$langs->load("propal");
|
|
|
|
|
$langs->load("bills");
|
2014-10-25 00:42:52 +02:00
|
|
|
$langs->load("errors");
|
2006-08-05 20:21:19 +02:00
|
|
|
|
2009-07-30 00:03:20 +02:00
|
|
|
// Security check
|
2006-08-05 20:21:19 +02:00
|
|
|
if (!$user->admin)
|
|
|
|
|
accessforbidden();
|
|
|
|
|
|
2011-09-06 12:52:42 +02:00
|
|
|
$action = GETPOST("action");
|
2006-08-05 20:21:19 +02:00
|
|
|
|
2014-10-25 00:42:52 +02:00
|
|
|
|
2011-06-06 10:44:36 +02:00
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
|
|
|
|
|
2011-09-06 12:52:42 +02:00
|
|
|
if ($action == 'setvalue' && $user->admin)
|
2006-08-05 20:21:19 +02:00
|
|
|
{
|
2014-10-25 00:42:52 +02:00
|
|
|
$result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", $_POST["email_from"], 'chaine', 0, '', $conf->entity);
|
|
|
|
|
if ($result < 0) $error++;
|
|
|
|
|
|
|
|
|
|
if (! $error)
|
|
|
|
|
{
|
|
|
|
|
foreach($_POST as $key => $val)
|
|
|
|
|
{
|
|
|
|
|
if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_/',$key)) continue;
|
|
|
|
|
//print $key.' - '.$val.'<br>';
|
|
|
|
|
$result=dolibarr_set_const($db, $key, $val, 'chaine', 0, '', $conf->entity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! $error)
|
2013-08-20 16:10:01 +02:00
|
|
|
{
|
|
|
|
|
setEventMessage($langs->trans("SetupSaved"));
|
|
|
|
|
}
|
|
|
|
|
else
|
2014-10-25 00:42:52 +02:00
|
|
|
{
|
2013-08-20 16:10:01 +02:00
|
|
|
setEventMessage($langs->trans("Error"),'errors');
|
2006-08-05 20:21:19 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-07-30 00:03:20 +02:00
|
|
|
* View
|
2006-08-05 20:21:19 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
llxHeader();
|
|
|
|
|
|
2008-01-26 16:10:18 +01:00
|
|
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
|
|
|
|
print_fiche_titre($langs->trans("NotificationSetup"),$linkback,'setup');
|
2006-08-05 20:21:19 +02:00
|
|
|
|
2014-10-25 00:42:52 +02:00
|
|
|
print $langs->trans("NotificationsDesc").'<br><br>';
|
2006-08-05 20:21:19 +02:00
|
|
|
|
|
|
|
|
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
2009-05-17 10:01:54 +02:00
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
2006-08-05 20:21:19 +02:00
|
|
|
print '<input type="hidden" name="action" value="setvalue">';
|
|
|
|
|
|
|
|
|
|
$var=true;
|
|
|
|
|
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
print '<td>'.$langs->trans("Parameter").'</td>';
|
|
|
|
|
print '<td>'.$langs->trans("Value").'</td>';
|
|
|
|
|
print "</tr>\n";
|
|
|
|
|
$var=!$var;
|
|
|
|
|
print '<tr '.$bc[$var].'><td>';
|
|
|
|
|
print $langs->trans("NotificationEMailFrom").'</td><td>';
|
2014-10-25 00:42:52 +02:00
|
|
|
print '<input size="32" type="email" name="email_from" value="'.$conf->global->NOTIFICATION_EMAIL_FROM.'">';
|
|
|
|
|
if (! empty($conf->global->NOTIFICATION_EMAIL_FROM) && ! isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print ' '.img_warning($langs->trans("ErrorBadEMail"));
|
2006-08-05 20:21:19 +02:00
|
|
|
print '</td></tr>';
|
2009-07-30 00:03:20 +02:00
|
|
|
print '</table>';
|
|
|
|
|
|
|
|
|
|
print '<br>';
|
|
|
|
|
|
2011-06-06 10:44:36 +02:00
|
|
|
print_fiche_titre($langs->trans("ListOfAvailableNotifications"),'','');
|
|
|
|
|
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
print '<td>'.$langs->trans("Module").'</td>';
|
|
|
|
|
print '<td>'.$langs->trans("Code").'</td>';
|
|
|
|
|
print '<td>'.$langs->trans("Label").'</td>';
|
2014-10-25 00:42:52 +02:00
|
|
|
print '<td>'.$langs->trans("FixedEmailTarget").'</td>';
|
2011-06-06 10:44:36 +02:00
|
|
|
print "</tr>\n";
|
|
|
|
|
|
|
|
|
|
// Load array of available notifications
|
|
|
|
|
$notificationtrigger=new InterfaceNotification($db);
|
|
|
|
|
$listofnotifiedevents=$notificationtrigger->getListOfManagedEvents();
|
|
|
|
|
|
|
|
|
|
foreach($listofnotifiedevents as $notifiedevent)
|
|
|
|
|
{
|
|
|
|
|
$var=!$var;
|
2011-09-06 12:52:42 +02:00
|
|
|
$label=$langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
|
2012-12-31 05:54:38 +01:00
|
|
|
|
|
|
|
|
if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder');
|
|
|
|
|
elseif ($notifiedevent['elementtype'] == 'propal') $elementLabel = $langs->trans('Proposal');
|
|
|
|
|
elseif ($notifiedevent['elementtype'] == 'facture') $elementLabel = $langs->trans('Bill');
|
|
|
|
|
elseif ($notifiedevent['elementtype'] == 'commande') $elementLabel = $langs->trans('Order');
|
|
|
|
|
|
2011-06-06 10:44:36 +02:00
|
|
|
print '<tr '.$bc[$var].'>';
|
2012-12-31 05:54:38 +01:00
|
|
|
print '<td>'.$elementLabel.'</td>';
|
2011-06-06 10:44:36 +02:00
|
|
|
print '<td>'.$notifiedevent['code'].'</td>';
|
|
|
|
|
print '<td>'.$label.'</td>';
|
2014-10-25 00:42:52 +02:00
|
|
|
$param='NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'];
|
|
|
|
|
print '<td><input type="email" size="32" name="'.$param.'" value="'.dol_escape_htmltag(GETPOST($param)?GETPOST($param,'alpha'):$conf->global->$param).'">';
|
|
|
|
|
if (! empty($conf->global->$param) && ! isValidEmail($conf->global->$param)) print ' '.img_warning($langs->trans("ErrorBadEMail"));
|
|
|
|
|
print '</td>';
|
2011-06-06 10:44:36 +02:00
|
|
|
print '</tr>';
|
|
|
|
|
}
|
|
|
|
|
print '</table>';
|
2006-08-05 20:21:19 +02:00
|
|
|
|
2014-10-25 00:42:52 +02:00
|
|
|
print '<br>';
|
|
|
|
|
|
|
|
|
|
print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"></center>';
|
|
|
|
|
|
|
|
|
|
print '</form>';
|
|
|
|
|
|
2006-08-05 20:21:19 +02:00
|
|
|
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2014-10-25 00:42:52 +02:00
|
|
|
|
|
|
|
|
$db->close();
|