2
0
forked from Wavyzz/dolibarr

Fix: Debug module notification

This commit is contained in:
Laurent Destailleur
2009-07-29 22:03:20 +00:00
parent 085506205c
commit cf0e98809d
18 changed files with 335 additions and 279 deletions

View File

@@ -30,6 +30,7 @@ For users:
- New: Include Dolibarr version in suggested dump filename.
- New: Enhancement in project module.
- New: Add log tab on emailing module.
- Fix: Debug seriously the email notification module.
- Fix: Error Call to a member function trans when refusing a supplier order.
- Fix: Fix payment conditions on commercial proposals.
- Fix: Nb of orders to process was wrong.

View File

@@ -15,23 +15,21 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
\file htdocs/admin/notification.php
\ingroup notification
\brief Page d'administration/configuration du module notification
\version $Revision$
*/
* \file htdocs/admin/notification.php
* \ingroup notification
* \brief Page d'administration/configuration du module notification
* \version $Id$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
$langs->load("admin");
// Security check
if (!$user->admin)
accessforbidden();
@@ -52,8 +50,7 @@ if ($_POST["action"] == 'setvalue' && $user->admin)
/*
*
*
* View
*/
llxHeader();
@@ -61,9 +58,10 @@ llxHeader();
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("NotificationSetup"),$linkback,'setup');
if ($mesg) print '<br>'.$mesg;
print $langs->trans("NotificationsDesc").'<br><br>';
if ($mesg) print $mesg.'<br>';
print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setvalue">';
@@ -80,9 +78,13 @@ print '<tr '.$bc[$var].'><td>';
print $langs->trans("NotificationEMailFrom").'</td><td>';
print '<input size="32" type="text" name="email_from" value="'.$conf->global->NOTIFICATION_EMAIL_FROM.'">';
print '</td></tr>';
print '</table>';
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '</table></form>';
print '<br>';
print '<center><input type="submit" class="button" value="'.$langs->trans("Modify").'"></center>';
print '</form>';
$db->close();

View File

@@ -40,9 +40,9 @@ $result = restrictedArea($user, 'societe',$socid,'');
/*
* Recherche
*
* Action
*/
if ($mode == 'search')
{
if ($mode-search == 'soc')
@@ -179,7 +179,7 @@ if ($socid > 0)
print '</td><td colspan="3">'.($societe->remise_client?price2num($societe->remise_client,'MT').'%':$langs->trans("DiscountNone")).'</td>';
print '</tr>';
// R<EFBFBD>ductions (Remises-Ristournes-Rabbais)
// Reductions (Remises-Ristournes-Rabbais)
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding">';
print '<tr><td nowrap>';
@@ -336,28 +336,44 @@ if ($socid > 0)
/*
* Barre d'actions
*
*/
print '<div class="tabsAction">';
if ($user->societe_id == 0)
{
// Si societe cliente ou prospect, on affiche bouton "Creer facture client"
if ($societe->client != 0 && $conf->facture->enabled && $user->rights->facture->creer) {
if ($conf->facture->enabled)
{
if ($user->rights->facture->creer)
{
$langs->load("bills");
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/facture.php?action=create&socid=$societe->id\">".$langs->trans("AddBill")."</a>";
if ($societe->client != 0) print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/facture.php?action=create&socid=$societe->id\">".$langs->trans("AddBill")."</a>";
else print "<a class=\"butActionRefused\" title=\"".dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer"))."\" href=\"#\">".$langs->trans("AddBill")."</a>";
}
else
{
print "<a class=\"butActionRefused\" title=\"".dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer"))."\" href=\"#\">".$langs->trans("AddBill")."</a>";
}
}
if ($conf->deplacement->enabled) {
if ($conf->deplacement->enabled)
{
$langs->load("trips");
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/deplacement/fiche.php?socid=$societe->id&amp;action=create\">".$langs->trans("AddTrip")."</a>";
}
}
if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
if ($conf->agenda->enabled)
{
if ($user->rights->agenda->myactions->create)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$socid.'">'.$langs->trans("AddAction").'</a>';
}
else
{
print '<a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a>';
}
}
if ($user->rights->societe->contact->creer)
{

View File

@@ -561,17 +561,6 @@ class CommandeFournisseur extends Commande
// Fin appel triggers
}
if ($error == 0)
{
$langs->load("other");
$subject = $langs->trans("EMailTextOrderApproved",$this->ref);
$message = $langs->trans("Hello").",\n\n";
$message .= $langs->trans("EMailTextOrderApprovedBy",$this->ref,$user->fullname);
$message .= "\n\n".$langs->trans("Sincerely").",\n\n";
$this->_NotifyCreator($user, $subject, $message);
}
if ($error == 0)
{
$this->db->commit();
@@ -615,16 +604,20 @@ class CommandeFournisseur extends Commande
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 9";
$sql .= " WHERE rowid = ".$this->id;
if ($this->db->query($sql) )
if ($this->db->query($sql))
{
$result = 0;
$this->log($user, 9, time());
$subject = $langs->trans("EMailTextOrderRefused",$this->ref);
$message = $langs->trans("Hello").",\n\n";
$message .= $langs->trans("EMailTextOrderRefusedBy",$this->ref,$user->fullname);
$this->_NotifyCreator($user, $subject, $message);
if ($error == 0)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('ORDER_SUPPLIER_REFUSE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
}
else
{
@@ -638,29 +631,7 @@ class CommandeFournisseur extends Commande
}
return $result ;
}
/*
*
*
*/
function _NotifyCreator($user, $subject, $message)
{
require_once (DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php");
$cc = new User($this->db, $this->user_author_id);
$cc->fetch();
$sendto = $cc->email;
$from = $user->email;
$mailfile = new CMailFile($subject,
$sendto,
$from,
$message, array(), array(), array());
if ( $mailfile->sendfile() )
{
return 0;
}
}
/**
* Send a supplier order to supplier

View File

@@ -18,25 +18,23 @@
*/
/**
\defgroup notification Module notification
\brief Module pour g<>rer les notifications (par mail ou autre)
\version $Id$
* \defgroup notification Module notification
* \brief Module pour g<>rer les notifications (par mail ou autre)
* \version $Id$
*/
/**
\file htdocs/includes/modules/modNotification.class.php
\ingroup notification
\brief Fichier de description et activation du module Notification
* \file htdocs/includes/modules/modNotification.class.php
* \ingroup notification
* \brief Fichier de description et activation du module Notification
*/
include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php");
/**
\class modMailing
\brief Classe de description et activation du module Mailing
* \class modMailing
* \brief Classe de description et activation du module Mailing
*/
class modNotification extends DolibarrModules
{

View File

@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@@ -17,18 +17,17 @@
*/
/**
\file htdocs/includes/triggers/interface_modNotification_notification.class.php
\ingroup notification
\brief Fichier de gestion des notifications sur evenement Dolibarr
\version $Id$
*/
* \file htdocs/includes/triggers/interface_modNotification_notification.class.php
* \ingroup notification
* \brief Fichier de gestion des notifications sur evenement Dolibarr
* \version $Id$
*/
/**
\class InterfaceNotification
\brief Classe des fonctions triggers des actions personalisees du workflow
*/
* \class InterfaceNotification
* \brief Classe des fonctions triggers des actions personalisees du workflow
*/
class InterfaceNotification
{
var $db;
@@ -107,7 +106,9 @@ class InterfaceNotification
$action_notify = 'NOTIFY_VAL_FAC';
$ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
$mesg = 'La facture '.$object->ref." a été validée.\n";
if (! file_exists($filepdf)) $filepdf='';
$langs->load("other");
$mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated",$object->ref);
$notify = new Notify($this->db);
$notify->send($action_notify, $object->socid, $mesg, 'facture', $object->id, $filepdf);
@@ -120,20 +121,41 @@ class InterfaceNotification
$action_notify = 'NOTIFY_VAL_FICHINTER';
$ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
$mesg = 'La fiche intervention '.$object->ref." a été validée.\n";
if (! file_exists($filepdf)) $filepdf='';
$langs->load("other");
$mesg = $langs->transnoentitiesnoconv("EMailTextIntervnetionValidated",$object->ref);
$notify = new Notify($this->db);
$notify->send($action_notify, $object->socid, $mesg, 'ficheinter', $object->id, $filepdf);
}
elseif ($action == 'ORDER_SUPPLIER_VALIDATE')
elseif ($action == 'ORDER_SUPPLIER_APPROVE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$action_notify = 'NOTIFY_VAL_ORDER_SUPPLIER';
$action_notify = 'NOTIFY_APP_ORDER_SUPPLIER';
$ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->fournisseur->dir_output . '/commande/' . $ref . '/' . $ref . '.pdf';
$mesg = 'La commande fournisseur '.$object->ref." a été validée.\n";
if (! file_exists($filepdf)) $filepdf='';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy",$object->ref,$user->fullname);
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
$notify = new Notify($this->db);
$notify->send($action_notify, $object->socid, $mesg, 'order_supplier', $object->id, $filepdf);
}
elseif ($action == 'ORDER_SUPPLIER_REFUSE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$action_notify = 'NOTIFY_REF_ORDER_SUPPLIER';
$ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->fournisseur->dir_output . '/commande/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf='';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy",$object->ref,$user->fullname);
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
$notify = new Notify($this->db);
$notify->send($action_notify, $object->socid, $mesg, 'order_supplier', $object->id, $filepdf);

View File

@@ -317,7 +317,7 @@ Module410Desc=Webcalendar integration
Module500Name=Taxes, social contributions and dividends
Module500Desc=Taxes and social contributions' management
Module600Name=Notifications
Module600Desc=Send notifications (by email) on Dolibarr business events
Module600Desc=Send notifications by email on some Dolibarr business events to third party's contacts
Module700Name=Donations
Module700Desc=Donations' management
Module800Name=OSCommerce direct
@@ -713,7 +713,7 @@ ModuleCompanyCodeAquarium=Return an accountancy code built by "401" followed by
ModuleCompanyCodePanicum=Return an empty accountancy code.
ModuleCompanyCodeDigitaria=Accountancy code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code.
UseNotifications=Use notifications
NotificationsDesc=Notifications feature allows you to silently send automatic mail, for some Dolibarr events, to companies that are configured to
NotificationsDesc=EMails notifications feature allows you to silently send automatic mail, for some Dolibarr events, to third parties (customers or suppliers) that are configured to. Choice of active notification and targets contacts is made one third party at time.
##### Webcal setup #####
WebCalSetup=Webcalendar link setup
WebCalSyncro=Add Dolibarr events to WebCalendar
@@ -971,7 +971,7 @@ NewRSS=New RSS Feed
MailingSetup=EMailing module setup
MailingEMailFrom=Sender EMail (From) for emails sent by emailing module
##### Notification #####
NotificationSetup=Mailing module setup
NotificationSetup=Notification bu email module setup
NotificationEMailFrom=Sender EMail (From) for emails sent for notifications
##### Sendings #####
SendingsSetup=Sending module setup

View File

@@ -261,6 +261,7 @@ Organization=Organization
AutomaticallyGenerated=Automatically generated
FiscalYearInformation=Information on the fiscal year
FiscalMonthStart=Starting month of the fiscal year
YouMustCreateContactFirst=You must create emails contacts for third party first to be able to add emails notifications.
# Monkey
MonkeyNumRefModelDesc=Return numero with format %syymm-nnnn for customer code and %syymm-nnnn for supplier code where yy is year, mm is month and nnnn is a sequence with no break and no return to 0.

View File

@@ -104,5 +104,5 @@ Notifications=Notifications
NoNotificationsWillBeSent=No email notifications are planned for this event and company
ANotificationsWillBeSent=1 notification will be sent by email
SomeNotificationsWillBeSent=%s notifications will be sent by email
AddNewNotification=Activate a new notification request
ListOfActiveNotifications=List all active notifications requests
AddNewNotification=Activate a new email notification request
ListOfActiveNotifications=List all active email notification requests

View File

@@ -26,8 +26,10 @@ BirthdayDate=Birthday
DateToBirth=Date to birth
BirthdayAlertOn = birthday alert active
BirthdayAlertOff = birthday alert inactive
Notify_NOTIFY_VAL_FICHINTER=Validate intervention
Notify_NOTIFY_VAL_FAC=Validate bill
Notify_NOTIFY_VAL_FICHINTER=Intervention validated
Notify_NOTIFY_VAL_FAC=Invoice validated
Notify_NOTIFY_APP_ORDER_SUPPLIER=Supplier order approved
Notify_NOTIFY_REF_ORDER_SUPPLIER=Supplier order refused
NbOfAttachedFiles=Number of attached files/documents
TotalSizeOfAttachedFiles=Total size of attached files/documents
MaxSize=Maximum size
@@ -100,11 +102,14 @@ NumberOfUnitsProposals=Number of units on proposals des 12 derniers mois
NumberOfUnitsCustomerOrders=Number of units on customer orders on last 12 month
NumberOfUnitsCustomerInvoices=Number of units on customer invoices on last 12 month
NumberOfUnitsSupplierInvoices=Number of units on supplier invoices on last 12 month
EMailTextInterventionValidated=Intervention %s validated
EMailTextInvoiceValidated=Invoice %s validated
EMailTextOrderApproved=Order %s approved
EMailTextOrderApprovedBy=Order %s approved by %s
EMailTextOrderRefused=Order %s refused
EMailTextOrderRefusedBy=Order %s refused by %s
ImportedWithSet=Importation data set
DolibarrNotification=Automatic notification
##### Bookmark #####
Bookmark=Bookmark

View File

@@ -317,7 +317,7 @@ Module410Desc = Interface avec le calendrier Webcalendar
Module500Name = Taxes et dividendes
Module500Desc = Gestion des taxes, charges sociales et dividendes
Module600Name = Notifications
Module600Desc = Envoi de notifications (par mail) sur les évênements métiers Dolibarr
Module600Desc = Envoi de notifications (par mail) sur certains évênements métiers Dolibarr, aux contacts de tiers
Module700Name = Dons
Module700Desc = Gestion des dons
Module800Name = OSCommerce direct
@@ -713,7 +713,7 @@ ModuleCompanyCodeAquarium = Renvoie un code compta composé de 401 suivi du code
ModuleCompanyCodePanicum = Renvoie un code compta vide.
ModuleCompanyCodeDigitaria = Renvoie un code compta composé suivant le code tiers. Le code est composé du caractère 'C' en première position suivi des 5 premiers caractères du code tiers.
UseNotifications = Utiliser les notifications
NotificationsDesc = La fonction des notifications permet d'envoyer automatiquement un mail, pour certains évênement Dolibarr, aux sociétés configurées pour.
NotificationsDesc = La fonction des notifications par emails permet d'envoyer automatiquement un email, pour certains évênement Dolibarr, aux tiers (sociétés clients, prospects ou fournisseurs) configurés pour. Le choix des notifications et contacts destinataires se fait tiers par tiers.
##### Webcal setup ##### = undefined
WebCalSetup = Configuration du lien vers le calendrier Webcalendar
WebCalSyncro = Intégrer les évênements Dolibarr dans WebCalendar

View File

@@ -264,6 +264,7 @@ Organization=Organisme
AutomaticallyGenerated=Généré automatiquement
FiscalYearInformation=Information sur l'année fiscale
FiscalMonthStart=Mois de début d'exercice
YouMustCreateContactFirst=Vous devez créer des contacts avec emails sur le tiers pour pouvoir lui définir des notifications par mails.
# Monkey
MonkeyNumRefModelDesc=Renvoie le numéro sous la forme %syymm-nnnn pour les codes clients et %syymm-nnnn pour les codes fournisseurs où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0.

View File

@@ -102,7 +102,7 @@ YouCanUseCommaSeparatorForSeveralRecipients=Vous pouvez utiliser le caractère d
# Module Notifications
Notifications=Notifications
NoNotificationsWillBeSent=Aucune notification par email n'est prévue pour cet évenement et société
ANotificationsWillBeSent=1 notification va être envoyée par mail
SomeNotificationsWillBeSent=%s notifications vont être envoyées par mail
AddNewNotification=Activer une nouvelle demande de notification
ListOfActiveNotifications=Liste des demandes de notifications actives
ANotificationsWillBeSent=1 notification va être envoyée par email
SomeNotificationsWillBeSent=%s notifications vont être envoyées par email
AddNewNotification=Activer une nouvelle demande de notification email
ListOfActiveNotifications=Liste des demandes de notifications emails actives

View File

@@ -28,6 +28,8 @@ BirthdayAlertOn = alerte anniversaire active
BirthdayAlertOff = alerte anniversaire inactive
Notify_NOTIFY_VAL_FICHINTER=Validation fiche intervention
Notify_NOTIFY_VAL_FAC=Validation facture
Notify_NOTIFY_APP_ORDER_SUPPLIER=Approbation commande fournisseur
Notify_NOTIFY_REF_ORDER_SUPPLIER=Refus commande fournisseur
NbOfAttachedFiles=Nombre de fichiers/documents liés
TotalSizeOfAttachedFiles=Taille total des fichiers/documents liés
MaxSize=Taille maximum
@@ -100,11 +102,14 @@ NumberOfUnitsProposals=Nombre d'unités sur les propal des 12 derniers mois
NumberOfUnitsCustomerOrders=Nombre d'unités sur les commandes clients des 12 derniers mois
NumberOfUnitsCustomerInvoices=Nombre d'unités sur les factures clients des 12 derniers mois
NumberOfUnitsSupplierInvoices=Nombre d'unités sur les factures fournisseurs des 12 derniers mois
EMailTextInterventionValidated=Fiche intervention %s validée
EMailTextInvoiceValidated=Facture %s validée
EMailTextOrderApproved=Commande %s approuvée
EMailTextOrderApprovedBy=Commande %s approuvée par %s
EMailTextOrderRefused=Commande %s réfusée
EMailTextOrderRefusedBy=Commande %s réfusée par %s
ImportedWithSet=Lot d'importation
DolibarrNotification=Notification automatique
##### Bookmark #####
Bookmark=Marque page

View File

@@ -107,21 +107,30 @@ class Notify
}
/**
* \brief Verifie si notification actice. Si oui, envoi mail et sauve trace
* \return int <0 si ko, sinon nombre de notifications faites
* \brief Check if notification are active for couple action/company.
* If yes, send mail and save trace.
* \param action Code of action to check and send (list in llx_action_def)
* \param socid Id of third party
* \param texte Message to send
* \param objet_type Type of object notification deals on
* \param objet_id Id of object notification deals on
* \param file Attach a file
* \return int <0 if KO or number of changes if OK
*/
function send($action, $socid, $texte, $objet_type, $objet_id, $file="")
{
global $conf,$langs;
$langs->load("other");
$sql = "SELECT s.nom, c.email, c.rowid, c.name, c.firstname, a.titre,n.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c, ".MAIN_DB_PREFIX."action_def as a, ".MAIN_DB_PREFIX."notify_def as n, ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
$sql .= " AND n.fk_soc = s.rowid";
$sql .= " AND a.code = 'NOTIFY_".$action."'";
$sql .= " AND a.code = '".$action."'";
$sql .= " AND s.rowid = ".$socid;
dol_syslog("Notify.class::send $action, $socid, $texte, $objet_type, $objet_id, $file");
dol_syslog("Notify::send $action, $socid, $texte, $objet_type, $objet_id, $file");
$result = $this->db->query($sql);
if ($result)
@@ -136,7 +145,7 @@ class Notify
if (strlen($sendto))
{
$subject = $langs->trans("DolibarrNotification");
$subject = $langs->transnoentitiesnoconv("DolibarrNotification");
$message = $texte;
$filename = split("/",$file);
$msgishtml=0;

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@@ -18,11 +18,11 @@
*/
/**
\file htdocs/societe/notify/fiche.php
\ingroup societe, notification
\brief Onglet notifications pour une societe
\version $Id$
*/
* \file htdocs/societe/notify/fiche.php
* \ingroup societe, notification
* \brief Onglet notifications pour une societe
* \version $Id$
*/
require("pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
@@ -43,14 +43,9 @@ if (! $sortfield) $sortfield="c.name";
/*
* View
*/
llxHeader();
/*
* Action ajout notification
* Action
*/
if ($_POST["action"] == 'add')
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
@@ -85,10 +80,15 @@ if ($_GET["action"] == 'delete')
}
/*
* Affichage notifications
*
* View
*/
$form = new Form($db);
llxHeader();
$soc = new Societe($db);
$soc->id = $socid;
@@ -97,16 +97,18 @@ if ( $soc->fetch($soc->id) )
$html = new Form($db);
$langs->load("other");
/*
* Affichage onglets
*/
$head = societe_prepare_head($soc);
dol_fiche_head($head, 'notify', $soc->nom);
dol_fiche_head($head, 'notify', $langs->trans("ThirdParty"));
print '<table class="border"width="100%">';
print '<tr><td width="20%">'.$langs->trans("Name").'</td><td colspan="3">'.$soc->nom.'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("Name").'</td><td colspan="3">';
print $form->showrefnav($soc,'socid','',1,'rowid','nom');
print '</td></tr>';
print '<tr><td width="30%">'.$langs->trans("NbOfActiveNotifications").'</td>';
print '<td colspan="3">';
$sql = "SELECT COUNT(n.rowid) as nb";
@@ -133,11 +135,16 @@ if ( $soc->fetch($soc->id) )
print '</div>';
// Help
$langs->load("admin");
print $langs->trans("NotificationsDesc").'<br><br>';
print "\n";
if(count($soc->contact_email_array()) > 0)
{
print_fiche_titre($langs->trans("AddNewNotification"));
// Add notification form
print_fiche_titre($langs->trans("AddNewNotification"),'','');
print '<form action="fiche.php?socid='.$socid.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@@ -150,6 +157,9 @@ if ( $soc->fetch($soc->id) )
print '<td>&nbsp;</td>';
print '</tr>';
$var=false;
if (count($soc->contact_email_array()) > 0)
{
// Charge tableau $actions
$sql = "SELECT a.rowid, a.code, a.titre";
$sql.= " FROM ".MAIN_DB_PREFIX."action_def as a";
@@ -174,8 +184,6 @@ if ( $soc->fetch($soc->id) )
dol_print_error($db);
}
$var=false;
print '<input type="hidden" name="action" value="add">';
print '<tr '.$bc[$var].'><td>';
$html->select_array("contactid",$soc->contact_email_array());
@@ -185,14 +193,22 @@ if ( $soc->fetch($soc->id) )
print '</td>';
print '<td align="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>';
}
else
{
print '<tr '.$bc[$var].'><td colspan="3">';
print $langs->trans("YouMustCreateContactFirst");
print '</td></tr>';
}
print '</table>';
print '</form>';
print '<br>';
}
print_fiche_titre($langs->trans("ListOfActiveNotifications"));
// List of active notifications
print_fiche_titre($langs->trans("ListOfActiveNotifications"),'','');
$var=true;
// Ligne de titres
@@ -200,11 +216,11 @@ if ( $soc->fetch($soc->id) )
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Contact"),"fiche.php","c.name",'',"&socid=$socid",'"width="45%"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Action"),"fiche.php","a.titre",'',"&socid=$socid",'"width="45%"',$sortfield,$sortorder);
print '<td>&nbsp;</td>';
print_liste_field_titre('','','');
print '</tr>';
// Liste
$sql = "SELECT c.rowid as id, c.name, c.firstname, a.titre, n.rowid";
$sql = "SELECT c.rowid as id, c.name, c.firstname, c.email, a.titre, n.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c, ".MAIN_DB_PREFIX."action_def as a, ".MAIN_DB_PREFIX."notify_def as n";
$sql.= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action AND n.fk_soc = ".$soc->id;
@@ -225,7 +241,9 @@ if ( $soc->fetch($soc->id) )
$contactstatic->id=$obj->id;
$contactstatic->name=$obj->name;
$contactstatic->firstname=$obj->firstname;
print '<tr '.$bc[$var].'><td>'.$contactstatic->getNomUrl(1).'</td>';
print '<tr '.$bc[$var].'><td>'.$contactstatic->getNomUrl(1);
print $obj->email?' &lt;'.$obj->email.'&gt;':$langs->trans("NoMail");
print '</td>';
print '<td>'.$obj->titre.'</td>';
print'<td align="center"><a href="fiche.php?socid='.$socid.'&action=delete&actid='.$obj->rowid.'">'.img_delete().'</a>';
print '</tr>';

View File

@@ -47,9 +47,10 @@ insert into llx_cond_reglement(rowid, code, sortorder, active, libelle, libelle_
-- Définition des actions de workflow notifications
--
delete from llx_action_def;
insert into llx_action_def (rowid,code,titre,description,objet_type) values (1,'NOTIFY_VAL_FICHINTER','Validation fiche intervention','Déclenché lors de la validation d\'une fiche d\'intervention','ficheinter');
insert into llx_action_def (rowid,code,titre,description,objet_type) values (2,'NOTIFY_VAL_FAC','Validation facture','Déclenché lors de la validation d\'une facture','facture');
insert into llx_action_def (rowid,code,titre,description,objet_type) values (3,'NOTIFY_VAL_ORDER_SUPPLIER','Validation commande fournisseur','Déclenché lors de la validation d\'une commande fournisseur','order_supplier');
insert into llx_action_def (rowid,code,titre,description,objet_type) values (1,'NOTIFY_VAL_FICHINTER','Validation fiche intervention','Executed when a intervention is validated','ficheinter');
insert into llx_action_def (rowid,code,titre,description,objet_type) values (2,'NOTIFY_VAL_FAC','Validation facture client','Executed when a customer invoice is approved','facture');
insert into llx_action_def (rowid,code,titre,description,objet_type) values (3,'NOTIFY_APP_ORDER_SUPPLIER','Approbation commande fournisseur','Executed when a supplier order is approved','order_supplier');
insert into llx_action_def (rowid,code,titre,description,objet_type) values (4,'NOTIFY_REF_ORDER_SUPPLIER','Refus commande fournisseur','Executed when a supplier order is refused','order_supplier');
--
-- Setup constants

View File

@@ -277,3 +277,9 @@ alter table llx_bank_account modify column iban_prefix varchar(34);
alter table llx_projet add column datec date after fk_statut;
delete from llx_action_def;
insert into llx_action_def (rowid,code,titre,description,objet_type) values (1,'NOTIFY_VAL_FICHINTER','Validation fiche intervention','Executed when a intervention is validated','ficheinter');
insert into llx_action_def (rowid,code,titre,description,objet_type) values (2,'NOTIFY_VAL_FAC','Validation facture client','Executed when a customer invoice is approved','facture');
insert into llx_action_def (rowid,code,titre,description,objet_type) values (3,'NOTIFY_APP_ORDER_SUPPLIER','Approbation commande fournisseur','Executed when a supplier order is approved','order_supplier');
insert into llx_action_def (rowid,code,titre,description,objet_type) values (4,'NOTIFY_REF_ORDER_SUPPLIER','Refus commande fournisseur','Executed when a supplier order is refused','order_supplier');