Fix: Avoid to set invoice payed twice
This commit is contained in:
parent
25427f77f3
commit
fd96fd639c
@ -870,28 +870,35 @@ class Facture extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
dolibarr_syslog("Facture::set_payed rowid=".$this->id, LOG_DEBUG);
|
if ($this->paye != 1)
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET';
|
|
||||||
$sql.= ' fk_statut=2';
|
|
||||||
if (! $close_code) $sql.= ', paye=1';
|
|
||||||
if ($close_code) $sql.= ", close_code='".addslashes($close_code)."'";
|
|
||||||
if ($close_note) $sql.= ", close_note='".addslashes($close_note)."'";
|
|
||||||
$sql.= ' WHERE rowid = '.$this->id;
|
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
{
|
||||||
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
|
dolibarr_syslog("Facture::set_payed rowid=".$this->id, LOG_DEBUG);
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET';
|
||||||
// Appel des triggers
|
$sql.= ' fk_statut=2';
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
if (! $close_code) $sql.= ', paye=1';
|
||||||
$interface=new Interfaces($this->db);
|
if ($close_code) $sql.= ", close_code='".addslashes($close_code)."'";
|
||||||
$result=$interface->run_triggers('BILL_PAYED',$this,$user,$langs,$conf);
|
if ($close_note) $sql.= ", close_note='".addslashes($close_note)."'";
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
$sql.= ' WHERE rowid = '.$this->id;
|
||||||
// Fin appel triggers
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
|
||||||
|
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('BILL_PAYED',$this,$user,$langs,$conf);
|
||||||
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
|
// Fin appel triggers
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user