Fix: [ bug #1463, #1464 ] Proposal triggers problem

This commit is contained in:
KreizIT 2014-07-04 15:15:36 +02:00
parent 3ea52a7967
commit fc6382ea7e
2 changed files with 73 additions and 90 deletions

View File

@ -18,6 +18,7 @@ For users:
- Fix: [ bug #1494 ] CATEGORY_CREATE and CATEGORY_MODIFY triggers do not intercept trigger action - Fix: [ bug #1494 ] CATEGORY_CREATE and CATEGORY_MODIFY triggers do not intercept trigger action
- Fix: [ bug #1502 ] DON_CREATE trigger does not intercept trigger action - Fix: [ bug #1502 ] DON_CREATE trigger does not intercept trigger action
- Fix: [ bug #1505, #1504] Project trigger problem - Fix: [ bug #1505, #1504] Project trigger problem
- Fix: [ bug #1463, #1464 ] Proposal triggers problem
For translators: For translators:

View File

@ -856,24 +856,22 @@ class Propal extends CommonObject
if (! $notrigger) if (! $notrigger)
{ {
// Appel des triggers // Call trigger
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $result=$this->call_trigger('PROPAL_CREATE',$user);
$interface=new Interfaces($this->db); if ($result < 0) { $error++; }
$result=$interface->run_triggers('PROPAL_CREATE',$this,$user,$langs,$conf); // End call triggers
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
} }
} }
else else
{ {
$this->error=$this->db->error();
$error++; $error++;
} }
} }
} }
else else
{ {
$this->error=$this->db->error();
$error++; $error++;
} }
@ -885,7 +883,6 @@ class Propal extends CommonObject
} }
else else
{ {
$this->error=$this->db->error();
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
@ -1006,14 +1003,10 @@ class Propal extends CommonObject
if ($reshook < 0) $error++; if ($reshook < 0) $error++;
} }
// Appel des triggers // Call trigger
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $result=$this->call_trigger('PROPAL_CLONE',$user);
$interface=new Interfaces($this->db); if ($result < 0) { $error++; }
$result=$interface->run_triggers('PROPAL_CLONE',$this,$user,$langs,$conf); // End call triggers
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
} }
// End // End
@ -1326,14 +1319,10 @@ class Propal extends CommonObject
{ {
if (! $notrigger) if (! $notrigger)
{ {
// Appel des triggers // Call trigger
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $result=$this->call_trigger('PROPAL_VALIDATE',$user);
$interface=new Interfaces($this->db); if ($result < 0) { $error++; }
$result=$interface->run_triggers('PROPAL_VALIDATE',$this,$user,$langs,$conf); // End call triggers
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
} }
if (! $error) if (! $error)
@ -1668,25 +1657,24 @@ class Propal extends CommonObject
{ {
if (! $notrigger) if (! $notrigger)
{ {
// Appel des triggers // Call trigger
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $result=$this->call_trigger('PROPAL_REOPEN',$user);
$interface=new Interfaces($this->db); if ($result < 0) { $error++; }
$result=$interface->run_triggers('PROPAL_REOPEN',$this,$user,$langs,$conf); // End call triggers
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
} }
} }
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{
if (!empty($this->errors))
{ {
foreach($this->errors as $errmsg) foreach($this->errors as $errmsg)
{ {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg); $this->error.=($this->error?', '.$errmsg:$errmsg);
} }
}
$this->db->rollback(); $this->db->rollback();
return -1*$error; return -1*$error;
} }
@ -1751,14 +1739,10 @@ class Propal extends CommonObject
propale_pdf_create($this->db, $this, $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL?$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); propale_pdf_create($this->db, $this, $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL?$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
// Appel des triggers // Call trigger
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $result=$this->call_trigger('PROPAL_CLOSE_SIGNED',$user);
$interface=new Interfaces($this->db); if ($result < 0) { $error++; }
$result=$interface->run_triggers('PROPAL_CLOSE_SIGNED',$this,$user,$langs,$conf); // End call triggers
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
} }
else else
{ {
@ -1777,20 +1761,23 @@ class Propal extends CommonObject
propale_pdf_create($this->db, $this, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED?$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED:$this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); propale_pdf_create($this->db, $this, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED?$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED:$this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
// Appel des triggers // Call trigger
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $result=$this->call_trigger('PROPAL_CLOSE_REFUSED',$user);
$interface=new Interfaces($this->db); if ($result < 0) { $error++; }
$result=$interface->run_triggers('PROPAL_CLOSE_REFUSED',$this,$user,$langs,$conf); // End call triggers
if ($result < 0) {
$error++; $this->errors=$interface->errors;
} }
// Fin appel triggers if ( ! $error )
} {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
else else
{
$this->db->rollback();
return -1;
}
}
else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
$this->db->rollback(); $this->db->rollback();
@ -2039,15 +2026,11 @@ class Propal extends CommonObject
$this->db->begin(); $this->db->begin();
if (! $error && ! $notrigger) if (! $notrigger)
{ {
// Call triggers // Call trigger
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $result=$this->call_trigger('PROPAL_DELETE',$user);
$interface=new Interfaces($this->db); if ($result < 0) { $error++; }
$result=$interface->run_triggers('PROPAL_DELETE',$this,$user,$langs,$conf);
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// End call triggers // End call triggers
} }
@ -2145,7 +2128,6 @@ class Propal extends CommonObject
} }
else else
{ {
$this->error=$this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -2931,14 +2913,14 @@ class PropaleLigne extends CommonObject
if (! $notrigger) if (! $notrigger)
{ {
// Appel des triggers // Call trigger
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $result=$this->call_trigger('LINEPROPAL_INSERT',$user);
$interface=new Interfaces($this->db); if ($result < 0)
$result = $interface->run_triggers('LINEPROPAL_INSERT',$this,$user,$langs,$conf); {
if ($result < 0) { $this->db->rollback();
$error++; $this->errors=$interface->errors; return -1;
} }
// Fin appel triggers // End call triggers
} }
$this->db->commit(); $this->db->commit();
@ -2981,14 +2963,14 @@ class PropaleLigne extends CommonObject
} }
} }
// Appel des triggers // Call trigger
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $result=$this->call_trigger('LINEPROPAL_DELETE',$user);
$interface=new Interfaces($this->db); if ($result < 0)
$result = $interface->run_triggers('LINEPROPAL_DELETE',$this,$user,$langs,$conf); {
if ($result < 0) { $this->db->rollback();
$error++; $this->errors=$interface->errors; return -1;
} }
// Fin appel triggers // End call triggers
$this->db->commit(); $this->db->commit();
@ -3091,14 +3073,14 @@ class PropaleLigne extends CommonObject
if (! $notrigger) if (! $notrigger)
{ {
// Appel des triggers // Call trigger
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $result=$this->call_trigger('LINEPROPAL_UPDATE',$user);
$interface=new Interfaces($this->db); if ($result < 0)
$result = $interface->run_triggers('LINEPROPAL_UPDATE',$this,$user,$langs,$conf); {
if ($result < 0) { $this->db->rollback();
$error++; $this->errors=$interface->errors; return -1;
} }
// Fin appel triggers // End call triggers
} }
$this->db->commit(); $this->db->commit();