diff --git a/ChangeLog b/ChangeLog index 0e8f03346db..c10c81413f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 01942db469e..5a3d91d53ef 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -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=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("NotificationSetup"),$linkback,'setup'); -if ($mesg) print '
'.$mesg; +print $langs->trans("NotificationsDesc").'

'; + +if ($mesg) print $mesg.'
'; -print '
'; print '
'; print ''; print ''; @@ -80,9 +78,13 @@ print ''; print $langs->trans("NotificationEMailFrom").''; print ''; print ''; +print ''; -print ''; -print '
'; +print '
'; + +print '
'; + +print ''; $db->close(); diff --git a/htdocs/compta/fiche.php b/htdocs/compta/fiche.php index f9f2c82bb64..3f51630ea96 100644 --- a/htdocs/compta/fiche.php +++ b/htdocs/compta/fiche.php @@ -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 ''.($societe->remise_client?price2num($societe->remise_client,'MT').'%':$langs->trans("DiscountNone")).''; print ''; - // R�ductions (Remises-Ristournes-Rabbais) + // Reductions (Remises-Ristournes-Rabbais) print ''; print ''; print ''; + print ''; + print''; + $i++; + } + $db->free($resql); + } + else + { + dol_print_error($db); + } + + print '
'; @@ -336,27 +336,43 @@ if ($socid > 0) /* * Barre d'actions - * */ print '
'; 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) { - $langs->load("bills"); - print "id\">".$langs->trans("AddBill").""; + if ($conf->facture->enabled) + { + if ($user->rights->facture->creer) + { + $langs->load("bills"); + if ($societe->client != 0) print "id\">".$langs->trans("AddBill").""; + else print "trans("ThirdPartyMustBeEditAsCustomer"))."\" href=\"#\">".$langs->trans("AddBill").""; + } + else + { + print "trans("ThirdPartyMustBeEditAsCustomer"))."\" href=\"#\">".$langs->trans("AddBill").""; + } } - if ($conf->deplacement->enabled) { + if ($conf->deplacement->enabled) + { $langs->load("trips"); print "id&action=create\">".$langs->trans("AddTrip").""; } } - if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) + if ($conf->agenda->enabled) { - print ''.$langs->trans("AddAction").''; + if ($user->rights->agenda->myactions->create) + { + print ''.$langs->trans("AddAction").''; + } + else + { + print ''.$langs->trans("AddAction").''; + } } if ($user->rights->societe->contact->creer) diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index a3bc49df705..9b32984f4dc 100644 --- a/htdocs/fourn/fournisseur.commande.class.php +++ b/htdocs/fourn/fournisseur.commande.class.php @@ -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 diff --git a/htdocs/includes/modules/modNotification.class.php b/htdocs/includes/modules/modNotification.class.php index 1d080770a72..f24a27b04fd 100644 --- a/htdocs/includes/modules/modNotification.class.php +++ b/htdocs/includes/modules/modNotification.class.php @@ -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 { diff --git a/htdocs/includes/triggers/interface_modNotification_Notification.class.php b/htdocs/includes/triggers/interface_modNotification_Notification.class.php index f12a6c996a4..98d9072fb65 100644 --- a/htdocs/includes/triggers/interface_modNotification_Notification.class.php +++ b/htdocs/includes/triggers/interface_modNotification_Notification.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2009 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 @@ -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); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 2d5d0ef4b72..6914d32b7ff 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -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 diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 68130abcc79..91f62ce72c8 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -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. diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 3ed27d0730f..beb594b5f3d 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -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 \ No newline at end of file +AddNewNotification=Activate a new email notification request +ListOfActiveNotifications=List all active email notification requests \ No newline at end of file diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 164259674a1..6bce13639e0 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -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 diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index f5e77fdf4b8..69167d2ac11 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -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 diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index d3d8f289a94..d47a340711d 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -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. diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index 9d2bd88ebdd..6a661719188 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 3d0d664b3c3..2291a9eabdc 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -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 diff --git a/htdocs/notify.class.php b/htdocs/notify.class.php index 90afded1970..c7aecca3a31 100644 --- a/htdocs/notify.class.php +++ b/htdocs/notify.class.php @@ -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; diff --git a/htdocs/societe/notify/fiche.php b/htdocs/societe/notify/fiche.php index bf7f1c98755..f2baea6de42 100644 --- a/htdocs/societe/notify/fiche.php +++ b/htdocs/societe/notify/fiche.php @@ -1,7 +1,7 @@ - * Copyright (C) 2004-2006 Laurent Destailleur - * + * Copyright (C) 2004-2009 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 * the Free Software Foundation; either version 2 of the License, or @@ -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,36 +43,31 @@ if (! $sortfield) $sortfield="c.name"; /* -* View -*/ - -llxHeader(); - -/* - * Action ajout notification + * Action */ + if ($_POST["action"] == 'add') { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; - $sql .= " WHERE fk_soc=".$socid." AND fk_contact=".$_POST["contactid"]." AND fk_action=".$_POST["actionid"]; - if ($db->query($sql)) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)"; - $sql .= " VALUES (".$db->idate(mktime()).",".$socid.",".$_POST["contactid"].",".$_POST["actionid"].")"; - - if ($db->query($sql)) + $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; + $sql .= " WHERE fk_soc=".$socid." AND fk_contact=".$_POST["contactid"]." AND fk_action=".$_POST["actionid"]; + if ($db->query($sql)) { - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)"; + $sql .= " VALUES (".$db->idate(mktime()).",".$socid.",".$_POST["contactid"].",".$_POST["actionid"].")"; + + if ($db->query($sql)) + { + + } + else + { + dol_print_error($db); + } } - else + else { - dol_print_error($db); + dol_print_error($db); } - } - else - { - dol_print_error($db); - } } /* @@ -85,160 +80,183 @@ if ($_GET["action"] == 'delete') } + /* - * Affichage notifications - * + * View */ + +$form = new Form($db); + +llxHeader(); + $soc = new Societe($db); $soc->id = $socid; if ( $soc->fetch($soc->id) ) { - $html = new Form($db); - $langs->load("other"); - - /* - * Affichage onglets - */ + $html = new Form($db); + $langs->load("other"); + + $head = societe_prepare_head($soc); - dol_fiche_head($head, 'notify', $soc->nom); - - - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans("Name").''.$soc->nom.'
'.$langs->trans("NbOfActiveNotifications").''; - $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n"; - $sql.= " WHERE fk_soc = ".$soc->id; - $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $nb=$obj->nb; - $i++; - } - } - else { - dol_print_error($db); - } - print $nb; - print '
'; - - print '
'; - - print "\n"; - - if(count($soc->contact_email_array()) > 0) - { - print_fiche_titre($langs->trans("AddNewNotification")); - - print '
'; - print ''; - - // Ligne de titres - print ''; - print ''; - 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 ''; - print ''; - - // Charge tableau $actions - $sql = "SELECT a.rowid, a.code, a.titre"; - $sql.= " FROM ".MAIN_DB_PREFIX."action_def as a"; - - $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $libelle=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->titre); - $actions[$obj->rowid] = $libelle; - - $i++; - } - $db->free($resql); - } - else - { - dol_print_error($db); - } - - $var=false; - - print ''; - print ''; - print ''; - print ''; - print ''; - print '
 
'; - $html->select_array("contactid",$soc->contact_email_array()); - print ''; - $html->select_array("actionid",$actions); - print '
'; - - print '
'; - print '
'; - } + dol_fiche_head($head, 'notify', $langs->trans("ThirdParty")); - print_fiche_titre($langs->trans("ListOfActiveNotifications")); + print ''; + + print ''; + + print ''; + print ''; + print '
'.$langs->trans("Name").''; + print $form->showrefnav($soc,'socid','',1,'rowid','nom'); + print '
'.$langs->trans("NbOfActiveNotifications").''; + $sql = "SELECT COUNT(n.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n"; + $sql.= " WHERE fk_soc = ".$soc->id; + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $nb=$obj->nb; + $i++; + } + } + else { + dol_print_error($db); + } + print $nb; + print '
'; + + print ''; + + + // Help + $langs->load("admin"); + print $langs->trans("NotificationsDesc").'

'; + + + print "\n"; + + // Add notification form + print_fiche_titre($langs->trans("AddNewNotification"),'',''); + + print '
'; + print ''; + + // Ligne de titres + print ''; + print ''; + 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 ''; + print ''; + + $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"; + + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $libelle=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->titre); + $actions[$obj->rowid] = $libelle; + + $i++; + } + $db->free($resql); + } + else + { + dol_print_error($db); + } + + print ''; + print ''; + print ''; + print ''; + print ''; + } + else + { + print ''; + } + + print '
 
'; + $html->select_array("contactid",$soc->contact_email_array()); + print ''; + $html->select_array("actionid",$actions); + print '
'; + print $langs->trans("YouMustCreateContactFirst"); + print '
'; + + print '
'; + print '
'; + + + // List of active notifications + print_fiche_titre($langs->trans("ListOfActiveNotifications"),'',''); $var=true; - - // Ligne de titres - print ''; - print ''; - 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 ''; - print ''; - - // Liste - $sql = "SELECT c.rowid as id, 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"; - $sql.= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action AND n.fk_soc = ".$soc->id; - - $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; + + // Ligne de titres + print '
 
'; + print ''; + 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_liste_field_titre('','',''); + print ''; + + // Liste + $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; + + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; $contactstatic=new Contact($db); - - while ($i < $num) - { - $var = !$var; - $obj = $db->fetch_object($resql); - - $contactstatic->id=$obj->id; - $contactstatic->name=$obj->name; - $contactstatic->firstname=$obj->firstname; - print ''; - print ''; - print''; - $i++; - } - $db->free($resql); - } - else - { - dol_print_error($db); - } - - print '
'.$contactstatic->getNomUrl(1).''.$obj->titre.''.img_delete().''; - print '
'; + while ($i < $num) + { + $var = !$var; + + $obj = $db->fetch_object($resql); + + $contactstatic->id=$obj->id; + $contactstatic->name=$obj->name; + $contactstatic->firstname=$obj->firstname; + print '
'.$contactstatic->getNomUrl(1); + print $obj->email?' <'.$obj->email.'>':$langs->trans("NoMail"); + print ''.$obj->titre.''.img_delete().''; + print '
'; } diff --git a/mysql/data/data.sql b/mysql/data/data.sql index 92a62491d02..570be2b33a8 100644 --- a/mysql/data/data.sql +++ b/mysql/data/data.sql @@ -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 diff --git a/mysql/migration/2.6.0-2.7.0.sql b/mysql/migration/2.6.0-2.7.0.sql index 70ce5181943..4d2d91b55b4 100644 --- a/mysql/migration/2.6.0-2.7.0.sql +++ b/mysql/migration/2.6.0-2.7.0.sql @@ -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'); +