Fix: Notifications events are a small part of triggered events.

This commit is contained in:
Laurent Destailleur
2011-06-06 08:44:36 +00:00
parent d704451f06
commit cf7c5d990f
5 changed files with 53 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -20,12 +20,13 @@
/** /**
* \file htdocs/admin/notification.php * \file htdocs/admin/notification.php
* \ingroup notification * \ingroup notification
* \brief Page d'administration/configuration du module notification * \brief Page to setup notification module
* \version $Id$ * \version $Id$
*/ */
require("../main.inc.php"); require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.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"); $langs->load("admin");
@@ -34,6 +35,10 @@ if (!$user->admin)
accessforbidden(); accessforbidden();
/*
* Actions
*/
if ($_POST["action"] == 'setvalue' && $user->admin) if ($_POST["action"] == 'setvalue' && $user->admin)
{ {
$result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM",$_POST["email_from"],'chaine',0,'',$conf->entity); $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 '<center><input type="submit" class="button" value="'.$langs->trans("Modify").'"></center>';
print '</form>'; 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(); $db->close();

View File

@@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -31,7 +32,7 @@
class InterfaceNotification class InterfaceNotification
{ {
var $db; 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'); 'FICHEINTER_VALIDATE','ORDER_SUPPLIER_APPROVE','ORDER_SUPPLIER_REFUSE');
/** /**
@@ -228,7 +229,7 @@ class InterfaceNotification
$qualified=0; $qualified=0;
// Check is this event is supported by notification module // 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 // Check if module for this event is active
if ($qualified) if ($qualified)
{ {

View File

@@ -1131,6 +1131,7 @@ MailingEMailError=Return EMail (Errors-to) for emails with errors
##### Notification ##### ##### Notification #####
NotificationSetup=Notification bu email module setup NotificationSetup=Notification bu email module setup
NotificationEMailFrom=Sender EMail (From) for emails sent for notifications NotificationEMailFrom=Sender EMail (From) for emails sent for notifications
ListOfAvailableNotifications=List of available notifications (This list depends on activated modules)
##### Sendings ##### ##### Sendings #####
SendingsSetup=Sending module setup SendingsSetup=Sending module setup
SendingsReceiptModel=Sending receipt model SendingsReceiptModel=Sending receipt model

View File

@@ -1142,6 +1142,7 @@ MailingEMailError= EMail retour (Errors-to) pour les réponses lors des envois p
##### Notification ##### ##### Notification #####
NotificationSetup= Configuration du module Notification NotificationSetup= Configuration du module Notification
NotificationEMailFrom= Email émetteur (From) des mails envoyés lors des notifications NotificationEMailFrom= Email émetteur (From) des mails envoyés lors des notifications
ListOfAvailableNotifications=Liste des notifications disponibles (cette liste dépend des modules actifs)
##### Sendings ##### ##### Sendings #####
SendingsSetup= Configuration du module Expédition/Livraison SendingsSetup= Configuration du module Expédition/Livraison
SendingsReceiptModel= Modèle du bordereau d'expédition SendingsReceiptModel= Modèle du bordereau d'expédition

View File

@@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* 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> * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -28,6 +28,7 @@
require("../../main.inc.php"); require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.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."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/includes/triggers/interface_modNotification_Notification.class.php");
$langs->load("companies"); $langs->load("companies");
$langs->load("mails"); $langs->load("mails");
@@ -54,6 +55,7 @@ if (! $sortfield) $sortfield="c.name";
* Action * Action
*/ */
// Add a notification
if ($_POST["action"] == 'add') if ($_POST["action"] == 'add')
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
@@ -78,9 +80,7 @@ if ($_POST["action"] == 'add')
} }
} }
/* // Remove a notification
* Action suppression notification
*/
if ($_GET["action"] == 'delete') if ($_GET["action"] == 'delete')
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".$_GET["actid"].";"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".$_GET["actid"].";";
@@ -169,37 +169,23 @@ if ( $soc->fetch($soc->id) )
$var=false; $var=false;
if (count($soc->thirdparty_and_contact_email_array()) > 0) if (count($soc->thirdparty_and_contact_email_array()) > 0)
{ {
// Load array of notifications type available $actions=array();
$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); // Load array of available notifications
if ($resql) $notificationtrigger=new InterfaceNotification($db);
{ $listofnotifiedevents=$notificationtrigger->getListOfManagedEvents();
$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++; foreach($listofnotifiedevents as $notifiedevent)
}
$db->free($resql);
}
else
{ {
dol_print_error($db); $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 '<input type="hidden" name="action" value="add">';
print '<tr '.$bc[$var].'><td>'; print '<tr '.$bc[$var].'><td>';
print $html->selectarray("contactid",$soc->thirdparty_and_contact_email_array()); print $html->selectarray("contactid",$soc->thirdparty_and_contact_email_array());
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print $html->selectarray("actionid",$actions); print $html->selectarray("actionid",$actions,'',1);
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$type=array('email'=>$langs->trans("EMail")); $type=array('email'=>$langs->trans("EMail"));