diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index c0efb6470c3..bb15b450ad7 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2006 Laurent Destailleur + * Copyright (C) 2005-2011 Laurent Destailleur * * 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 @@ -20,12 +20,13 @@ /** * \file htdocs/admin/notification.php * \ingroup notification - * \brief Page d'administration/configuration du module notification + * \brief Page to setup notification module * \version $Id$ */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/includes/triggers/interface_modNotification_Notification.class.php"); $langs->load("admin"); @@ -34,6 +35,10 @@ if (!$user->admin) accessforbidden(); +/* + * Actions + */ + if ($_POST["action"] == 'setvalue' && $user->admin) { $result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM",$_POST["email_from"],'chaine',0,'',$conf->entity); @@ -85,6 +90,33 @@ print '
'; print '
'; print ''; +print '
'; + + +print_fiche_titre($langs->trans("ListOfAvailableNotifications"),'',''); + +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +// Load array of available notifications +$notificationtrigger=new InterfaceNotification($db); +$listofnotifiedevents=$notificationtrigger->getListOfManagedEvents(); + +foreach($listofnotifiedevents as $notifiedevent) +{ + $var=!$var; + $label=$langs->trans("Notify_".$notifiedevent['code'])!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; + print ''; + print ''; + print ''; + print ''; + print ''; +} +print '
'.$langs->trans("Module").''.$langs->trans("Code").''.$langs->trans("Label").'
'.$notifiedevent['elementtype'].''.$notifiedevent['code'].''.$label.'
'; $db->close(); diff --git a/htdocs/includes/triggers/interface_modNotification_Notification.class.php b/htdocs/includes/triggers/interface_modNotification_Notification.class.php index d1acdd3d980..702daf981d1 100644 --- a/htdocs/includes/triggers/interface_modNotification_Notification.class.php +++ b/htdocs/includes/triggers/interface_modNotification_Notification.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2011 Regis Houssin * * 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 @@ -31,7 +32,7 @@ class InterfaceNotification { var $db; - var $listofnotifiedevents=array('BILL_VALIDATE','ORDER_VALIDATE','PROPAL_VALIDATE', + var $listofmanagedevents=array('BILL_VALIDATE','ORDER_VALIDATE','PROPAL_VALIDATE', 'FICHEINTER_VALIDATE','ORDER_SUPPLIER_APPROVE','ORDER_SUPPLIER_REFUSE'); /** @@ -228,7 +229,7 @@ class InterfaceNotification $qualified=0; // Check is this event is supported by notification module - if (in_array($obj->code,$this->listofnotifiedevents)) $qualified=1; + if (in_array($obj->code,$this->listofmanagedevents)) $qualified=1; // Check if module for this event is active if ($qualified) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index cfee8b82214..c4baf94c0e9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1131,6 +1131,7 @@ MailingEMailError=Return EMail (Errors-to) for emails with errors ##### Notification ##### NotificationSetup=Notification bu email module setup NotificationEMailFrom=Sender EMail (From) for emails sent for notifications +ListOfAvailableNotifications=List of available notifications (This list depends on activated modules) ##### Sendings ##### SendingsSetup=Sending module setup SendingsReceiptModel=Sending receipt model diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index c4bc3425104..b8cb0d49e12 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1142,6 +1142,7 @@ MailingEMailError= EMail retour (Errors-to) pour les réponses lors des envois p ##### Notification ##### NotificationSetup= Configuration du module Notification NotificationEMailFrom= Email émetteur (From) des mails envoyés lors des notifications +ListOfAvailableNotifications=Liste des notifications disponibles (cette liste dépend des modules actifs) ##### Sendings ##### SendingsSetup= Configuration du module Expédition/Livraison SendingsReceiptModel= Modèle du bordereau d'expédition diff --git a/htdocs/societe/notify/fiche.php b/htdocs/societe/notify/fiche.php index 53f8d37b24d..0373cabbdf4 100644 --- a/htdocs/societe/notify/fiche.php +++ b/htdocs/societe/notify/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2010 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -28,6 +28,7 @@ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); +require_once(DOL_DOCUMENT_ROOT."/includes/triggers/interface_modNotification_Notification.class.php"); $langs->load("companies"); $langs->load("mails"); @@ -54,6 +55,7 @@ if (! $sortfield) $sortfield="c.name"; * Action */ +// Add a notification if ($_POST["action"] == 'add') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; @@ -78,9 +80,7 @@ if ($_POST["action"] == 'add') } } -/* - * Action suppression notification - */ +// Remove a notification if ($_GET["action"] == 'delete') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".$_GET["actid"].";"; @@ -169,37 +169,23 @@ if ( $soc->fetch($soc->id) ) $var=false; if (count($soc->thirdparty_and_contact_email_array()) > 0) { - // Load array of notifications type available - $sql = "SELECT a.rowid, a.code, a.label"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a"; - $sql.= " ORDER BY a.rang ASC"; + $actions=array(); - $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $label=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label); - $actions[$obj->rowid] = $label; - - $i++; - } - $db->free($resql); - } - else - { - dol_print_error($db); - } + // Load array of available notifications + $notificationtrigger=new InterfaceNotification($db); + $listofnotifiedevents=$notificationtrigger->getListOfManagedEvents(); + foreach($listofnotifiedevents as $notifiedevent) + { + $label=$langs->trans("Notify_".$notifiedevent['code'])!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; + $actions[$notifiedevent['rowid']]=$label; + } print ''; print ''; print $html->selectarray("contactid",$soc->thirdparty_and_contact_email_array()); print ''; print ''; - print $html->selectarray("actionid",$actions); + print $html->selectarray("actionid",$actions,'',1); print ''; print ''; $type=array('email'=>$langs->trans("EMail"));