diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index c0efb6470c31b37d351392fec258a5aeb78ff8f3..bb15b450ad71f158730f7ad4977096cdb4b95c69 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.org> + * Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.org> * * 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 '<br>'; print '<center><input type="submit" class="button" value="'.$langs->trans("Modify").'"></center>'; print '</form>'; +print '<br>'; + + +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>'; +print "</tr>\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 '<tr '.$bc[$var].'>'; + print '<td>'.$notifiedevent['elementtype'].'</td>'; + print '<td>'.$notifiedevent['code'].'</td>'; + print '<td>'.$label.'</td>'; + print '</tr>'; +} +print '</table>'; $db->close(); diff --git a/htdocs/includes/triggers/interface_modNotification_Notification.class.php b/htdocs/includes/triggers/interface_modNotification_Notification.class.php index d1acdd3d98043da8b3888210f96d276124def5cd..702daf981d1071526fa64eb5164619c96d1f274d 100644 --- a/htdocs/includes/triggers/interface_modNotification_Notification.class.php +++ b/htdocs/includes/triggers/interface_modNotification_Notification.class.php @@ -1,5 +1,6 @@ <?php /* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr> * * 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 cfee8b822141680bc8415c5ecbe7c24cfeb3ff91..c4baf94c0e9e1ae6edf843aeddc68e96f6f4eec6 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 c4bc342510492babcc644d827a5058a0fb6c7381..b8cb0d49e12097569b1bdfbad098309190e7137d 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 53f8d37b24d20a99d49edd8820d62c685ae8996d..0373cabbdf4af59b3d38a1d094213ddbbc8b065a 100644 --- a/htdocs/societe/notify/fiche.php +++ b/htdocs/societe/notify/fiche.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> * * 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"; - - $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; + $actions=array(); - $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 '<input type="hidden" name="action" value="add">'; print '<tr '.$bc[$var].'><td>'; print $html->selectarray("contactid",$soc->thirdparty_and_contact_email_array()); print '</td>'; print '<td>'; - print $html->selectarray("actionid",$actions); + print $html->selectarray("actionid",$actions,'',1); print '</td>'; print '<td>'; $type=array('email'=>$langs->trans("EMail"));