diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3ca98d28ec9f552d855dfbfcde4d4a69a0245d71..fb1ea3d21e0c7672fc740c77e5e76476f21b2217 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 f25517946f61f0d49c32753ec47cd595d7b6bdad..44871304028c0cbe0630dc41d6aa09299bdb921d 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 26c96faac14e03688ac740a8246fac4a2c0db481..9c2976b8173ad9ca2c4fc8bd23396b04f8b8bfdc 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 8be0280ac489361fa572aa1a717eb5ee6d874037..93397d41c3642274cd5164940cb82f08fbad3f99 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 f57818ec49f6ed863891e94224981606abb1e69b..328c2d4798bf400ebdfe1adedd6d8f31de7bd146 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 686eec6fb74b09bd6ab8e76323551dbbbcfa0acc..4000086209a2d1961b10e2bc72c2aa010989fb6b 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 6b59b2dc83941c65709196814cc526fcd103d537..82c82904684c705ee157e3e633624f57ef532a19 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 e9a0e10e0c4f7c23e418b26c0e05005a8cbb239e..73a01b2443c3ddfaf92c2280c408f268f24c927a 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");