From 9626a1bc4f192d122fea0c2c8517e00815343006 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Apr 2010 21:22:06 +0000 Subject: [PATCH] Fix: Missing triggers for suppliers invoices --- htdocs/compta/facture/class/facture.class.php | 19 +++++++--- htdocs/fourn/fournisseur.class.php | 18 +++++----- htdocs/fourn/fournisseur.facture.class.php | 22 ++++++++++-- .../interface_modAgenda_ActionsAuto.class.php | 36 ++++++++++++++++++- ...nterface_modPhenix_Phenixsynchro.class.php | 2 +- htdocs/install/mysql/data/llx_const.sql | 2 +- htdocs/multicompany/sql/init_new_entity.sql | 2 +- ...ace_modWebcalendar_Webcalsynchro.class.php | 2 +- 8 files changed, 81 insertions(+), 22 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3ca98d28ec9..fb1ea3d21e0 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -336,8 +336,8 @@ class Facture extends CommonObject if (! $error) { - $resql=$this->update_price(); - if ($resql) + $result=$this->update_price(); + if ($result > 0) { // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php"); @@ -346,11 +346,20 @@ class Facture extends CommonObject if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers - $this->db->commit(); - return $this->id; + if (! $error) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->db->rollback(); + return -4; + } } else { + $this->error=$langs->trans('FailedToUpdatePrice'); $this->db->rollback(); return -3; } @@ -1223,7 +1232,7 @@ class Facture extends CommonObject /** - * \brief Tag la facture comme abandonnee, sans paiement dessus (exemple car facture de remplacement) + appel trigger BILL_CANCEL + * \brief Tag la facture comme abandonnee, sans paiement dessus (exemple car facture de remplacement) + appel trigger BILL_CANCELED * \param user Objet utilisateur qui modifie * \param close_code Code de fermeture * \param close_note Commentaire de fermeture diff --git a/htdocs/fourn/fournisseur.class.php b/htdocs/fourn/fournisseur.class.php index f25517946f6..44871304028 100644 --- a/htdocs/fourn/fournisseur.class.php +++ b/htdocs/fourn/fournisseur.class.php @@ -19,10 +19,10 @@ */ /** - \file htdocs/fourn/fournisseur.class.php - \ingroup fournisseur,societe - \brief Fichier de la classe des fournisseurs - \version $Id$ + * \file htdocs/fourn/fournisseur.class.php + * \ingroup fournisseur,societe + * \brief Fichier de la classe des fournisseurs + * \version $Id$ */ require_once(DOL_DOCUMENT_ROOT."/societe/societe.class.php"); @@ -31,8 +31,8 @@ require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.product.class.php"); /** - \class Fournisseur - \brief Classe permettant la gestion des fournisseur + * \class Fournisseur + * \brief Classe permettant la gestion des fournisseur */ class Fournisseur extends Societe @@ -41,7 +41,7 @@ class Fournisseur extends Societe /** * \brief Constructeur de la classe - * \param DB handler acc�s base de donn�es + * \param DB handler acces base de donnees * \param id id societe (0 par defaut) */ @@ -196,7 +196,7 @@ class Fournisseur extends Societe } $sql.= " ".$clause." s.fournisseur = 1"; $sql.= " AND s.entity = ".$conf->entity; - + $resql=$this->db->query($sql); if ($resql) { @@ -251,7 +251,7 @@ class Fournisseur extends Societe function ListArray() { global $conf; - + $arr = array(); $sql = "SELECT s.rowid, s.nom"; diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php index 26c96faac14..9c2976b8173 100644 --- a/htdocs/fourn/fournisseur.facture.class.php +++ b/htdocs/fourn/fournisseur.facture.class.php @@ -179,10 +179,26 @@ class FactureFournisseur extends Facture } } // Update total price - if ($this->update_price() > 0) + $result=$this->update_price(); + if ($result > 0) { - $this->db->commit(); - return $this->id; + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('BILL_SUPPLIER_CREATE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + + if (! $error) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->db->rollback(); + return -4; + } } else { diff --git a/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php b/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php index 8be0280ac48..93397d41c36 100644 --- a/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php +++ b/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php @@ -276,7 +276,7 @@ class InterfaceActionsAuto $object->orderrowid=$object->propalrowid=0; $ok=1; } - elseif ($action == 'BILL_CANCELED') + elseif ($action == 'BILL_CANCEL') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("other"); @@ -341,6 +341,40 @@ class InterfaceActionsAuto $object->orderrowid=$object->propalrowid=0; $ok=1; } + elseif ($action == 'BILL_SUPPLIER_PAYED') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + $langs->load("other"); + $langs->load("bills"); + $langs->load("agenda"); + + $object->actiontypecode='AC_OTH'; + $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); + $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); + $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; + + $object->sendtoid=0; + $object->facid=0; + $object->orderrowid=$object->propalrowid=0; + $ok=1; + } + elseif ($action == 'BILL_SUPPLIER_CANCELED') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + $langs->load("other"); + $langs->load("bills"); + $langs->load("agenda"); + + $object->actiontypecode='AC_OTH'; + $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); + $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); + $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; + + $object->sendtoid=0; + $object->facid=0; + $object->orderrowid=$object->propalrowid=0; + $ok=1; + } // Members elseif ($action == 'MEMBER_VALIDATE') diff --git a/htdocs/includes/triggers/interface_modPhenix_Phenixsynchro.class.php b/htdocs/includes/triggers/interface_modPhenix_Phenixsynchro.class.php index f57818ec49f..328c2d4798b 100644 --- a/htdocs/includes/triggers/interface_modPhenix_Phenixsynchro.class.php +++ b/htdocs/includes/triggers/interface_modPhenix_Phenixsynchro.class.php @@ -247,7 +247,7 @@ class InterfacePhenixsynchro $this->desc=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); $this->desc.="\n".$langs->transnoentities("Author").': '.$user->login; } - elseif ($action == 'BILL_CANCELED') + elseif ($action == 'BILL_CANCEL') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("other"); diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql index 686eec6fb74..4000086209a 100644 --- a/htdocs/install/mysql/data/llx_const.sql +++ b/htdocs/install/mysql/data/llx_const.sql @@ -190,7 +190,7 @@ insert into llx_const (name, value, type, note, visible) values ('MAIN_AGENDA_AC insert into llx_const (name, value, type, note, visible) values ('MAIN_AGENDA_ACTIONAUTO_ORDER_SENTBYMAIL','1','chaine','',0); insert into llx_const (name, value, type, note, visible) values ('MAIN_AGENDA_ACTIONAUTO_BILL_VALIDATE','1','chaine','',0); insert into llx_const (name, value, type, note, visible) values ('MAIN_AGENDA_ACTIONAUTO_BILL_PAYED','1','chaine','',0); -insert into llx_const (name, value, type, note, visible) values ('MAIN_AGENDA_ACTIONAUTO_BILL_CANCELED','1','chaine','',0); +insert into llx_const (name, value, type, note, visible) values ('MAIN_AGENDA_ACTIONAUTO_BILL_CANCEL','1','chaine','',0); insert into llx_const (name, value, type, note, visible) values ('MAIN_AGENDA_ACTIONAUTO_BILL_SENTBYMAIL','1','chaine','',0); insert into llx_const (name, value, type, note, visible) values ('MAIN_AGENDA_ACTIONAUTO_ORDER_SUPPLIER_VALIDATE','1','chaine','',0); insert into llx_const (name, value, type, note, visible) values ('MAIN_AGENDA_ACTIONAUTO_BILL_SUPPLIER_VALIDATE','1','chaine','',0); diff --git a/htdocs/multicompany/sql/init_new_entity.sql b/htdocs/multicompany/sql/init_new_entity.sql index 6b59b2dc839..82c82904684 100644 --- a/htdocs/multicompany/sql/init_new_entity.sql +++ b/htdocs/multicompany/sql/init_new_entity.sql @@ -150,7 +150,7 @@ insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_A insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_AGENDA_ACTIONAUTO_ORDER_SENTBYMAIL','1','chaine','',0,__ENTITY__); insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_AGENDA_ACTIONAUTO_BILL_VALIDATE','1','chaine','',0,__ENTITY__); insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_AGENDA_ACTIONAUTO_BILL_PAYED','1','chaine','',0,__ENTITY__); -insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_AGENDA_ACTIONAUTO_BILL_CANCELED','1','chaine','',0,__ENTITY__); +insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_AGENDA_ACTIONAUTO_BILL_CANCEL','1','chaine','',0,__ENTITY__); insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_AGENDA_ACTIONAUTO_BILL_SENTBYMAIL','1','chaine','',0,__ENTITY__); insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_AGENDA_ACTIONAUTO_ORDER_SUPPLIER_VALIDATE','1','chaine','',0,__ENTITY__); insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_AGENDA_ACTIONAUTO_BILL_SUPPLIER_VALIDATE','1','chaine','',0,__ENTITY__); diff --git a/htdocs/webcal/inc/triggers/interface_modWebcalendar_Webcalsynchro.class.php b/htdocs/webcal/inc/triggers/interface_modWebcalendar_Webcalsynchro.class.php index e9a0e10e0c4..73a01b2443c 100644 --- a/htdocs/webcal/inc/triggers/interface_modWebcalendar_Webcalsynchro.class.php +++ b/htdocs/webcal/inc/triggers/interface_modWebcalendar_Webcalsynchro.class.php @@ -224,7 +224,7 @@ class InterfaceWebcalsynchro $this->desc=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); $this->desc.="\n".$langs->transnoentities("Author").': '.$user->login; } - elseif ($action == 'BILL_CANCELED') + elseif ($action == 'BILL_CANCEL') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("other");