From fd96fd639c6572958c6a199bf95455c2f16b0b62 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 May 2008 19:54:22 +0000 Subject: [PATCH] Fix: Avoid to set invoice payed twice --- htdocs/facture.class.php | 47 +++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index f704e28eaa4..94332f42ded 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -870,28 +870,35 @@ class Facture extends CommonObject { global $conf,$langs; - dolibarr_syslog("Facture::set_payed rowid=".$this->id, LOG_DEBUG); - $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) + if ($this->paye != 1) { - $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 + dolibarr_syslog("Facture::set_payed rowid=".$this->id, LOG_DEBUG); + $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); + + // 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; }