diff --git a/htdocs/core/modules/fichinter/modules_fichinter.php b/htdocs/core/modules/fichinter/modules_fichinter.php index 452e94f9ad0..c74a7aba45d 100644 --- a/htdocs/core/modules/fichinter/modules_fichinter.php +++ b/htdocs/core/modules/fichinter/modules_fichinter.php @@ -227,7 +227,7 @@ function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails=0, $ // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($db); - $result=$interface->run_triggers('FICHEINTER_BUILDDOC',$object,$user,$langs,$conf); + $result=$interface->run_triggers('FICHINTER_BUILDDOC',$object,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index e3bf26df606..d4c32f5d7dd 100755 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -311,7 +311,7 @@ class InterfaceActionsAuto $object->sendtoid=0; $ok=1; } - elseif ($action == 'FICHEINTER_VALIDATE') + elseif ($action == 'FICHINTER_VALIDATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("other"); @@ -328,7 +328,7 @@ class InterfaceActionsAuto $object->elementtype=''; $ok=1; } - elseif ($action == 'FICHEINTER_SENTBYMAIL') + elseif ($action == 'FICHINTER_SENTBYMAIL') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("other"); diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index d01f817d442..42a328b0e4b 100755 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -29,8 +29,14 @@ class InterfaceNotification { var $db; - var $listofmanagedevents=array('BILL_VALIDATE','ORDER_VALIDATE','PROPAL_VALIDATE', - 'FICHEINTER_VALIDATE','ORDER_SUPPLIER_APPROVE','ORDER_SUPPLIER_REFUSE'); + var $listofmanagedevents=array( + 'BILL_VALIDATE', + 'ORDER_VALIDATE', + 'PROPAL_VALIDATE', + 'FICHINTER_VALIDATE', + 'ORDER_SUPPLIER_APPROVE', + 'ORDER_SUPPLIER_REFUSE' + ); /** * Constructor @@ -146,7 +152,7 @@ class InterfaceNotification $notify->send($action, $object->socid, $mesg, 'propal', $object->id, $filepdf); } - elseif ($action == 'FICHEINTER_VALIDATE') + elseif ($action == 'FICHINTER_VALIDATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 86b7a8a067d..4d49697f4fb 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -164,18 +164,27 @@ class Fichinter extends CommonObject if (! $ret) dol_print_error($this->db); } - $this->db->commit(); - // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); - $result=$interface->run_triggers('FICHEINTER_CREATE',$this,$user,$langs,$conf); + $result=$interface->run_triggers('FICHINTER_CREATE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers - return $this->id; + if (! $error) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->db->rollback(); + $this->error=join(',',$this->errors); + dol_syslog(get_class($this)."::create ".$this->error,LOG_ERR); + return -1; + } } else { @@ -213,7 +222,7 @@ class Fichinter extends CommonObject // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); - $result=$interface->run_triggers('FICHEINTER_MODIFY',$this,$user,$langs,$conf); + $result=$interface->run_triggers('FICHINTER_MODIFY',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } @@ -357,14 +366,14 @@ class Fichinter extends CommonObject $sql.= " AND entity = ".$conf->entity; $sql.= " AND fk_statut = 0"; - dol_syslog("Fichinter::setValid sql=".$sql); + dol_syslog(get_class($this)."::setValid sql=".$sql); $resql=$this->db->query($sql); if ($resql) { // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); - $result=$interface->run_triggers('FICHEINTER_VALIDATE',$this,$user,$langs,$conf); + $result=$interface->run_triggers('FICHINTER_VALIDATE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers @@ -377,7 +386,7 @@ class Fichinter extends CommonObject { $this->db->rollback(); $this->error=join(',',$this->errors); - dol_syslog("Fichinter::setValid ".$this->error,LOG_ERR); + dol_syslog(get_class($this)."::setValid ".$this->error,LOG_ERR); return -1; } } @@ -385,7 +394,7 @@ class Fichinter extends CommonObject { $this->db->rollback(); $this->error=$this->db->lasterror(); - dol_syslog("Fichinter::setValid ".$this->error,LOG_ERR); + dol_syslog(get_class($this)."::setValid ".$this->error,LOG_ERR); return -1; } } @@ -675,7 +684,7 @@ class Fichinter extends CommonObject // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); - $result=$interface->run_triggers('FICHEINTER_DELETE',$this,$user,$langs,$conf); + $result=$interface->run_triggers('FICHINTER_DELETE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index e821bc3ab91..a3dca6fa054 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -719,7 +719,7 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($db); - $result=$interface->run_triggers('FICHEINTER_SENTBYMAIL',$object,$user,$langs,$conf); + $result=$interface->run_triggers('FICHINTER_SENTBYMAIL',$object,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers @@ -1387,7 +1387,7 @@ else if ($id > 0 || ! empty($ref)) else print ''.$langs->trans("CreateBill").''; } - if (! empty($conf->global->FICHEINTER_CLASSIFY_BILLED)) + if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED)) { if ($object->statut != 2) { diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index 2c5bb4e60eb..2c7284b0171 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -30,7 +30,7 @@ -- List of all managed triggered events (used for trigger agenda and for notification) -- delete from llx_c_action_trigger; -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (1,'FICHEINTER_VALIDATE','Intervention validated','Executed when a intervention is validated','ficheinter',18); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (1,'FICHINTER_VALIDATE','Intervention validated','Executed when a intervention is validated','ficheinter',18); insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (2,'BILL_VALIDATE','Customer invoice validated','Executed when a customer invoice is approved','facture',6); insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (3,'ORDER_SUPPLIER_APPROVE','Supplier order request approved','Executed when a supplier order is approved','order_supplier',11); insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (4,'ORDER_SUPPLIER_REFUSE','Supplier order request refused','Executed when a supplier order is refused','order_supplier',12);