From 74c8bbbe7f750bd34262cf6ad0dff0ce592c0b2d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Nov 2007 22:10:19 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20La=20suppression=20d'une=20adh=E9sion=20?= =?UTF-8?q?n'effa=E7ait=20pas=20l'=E9criture=20bancaire.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/adherents/cotisation.class.php | 45 ++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/cotisation.class.php b/htdocs/adherents/cotisation.class.php index 216dfe1fa33..b7cc1b1edee 100644 --- a/htdocs/adherents/cotisation.class.php +++ b/htdocs/adherents/cotisation.class.php @@ -182,26 +182,61 @@ class Cotisation extends CommonObject \param rowid Id cotisation \return int <0 si KO, 0 si OK mais non trouve, >0 si OK */ - function delete($rowid) + function delete() { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."cotisation WHERE rowid = ".$rowid; + // Verification + if ($this->fk_bank) + { + require_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php"); + $accountline=new AccountLine($this->db); + $result=$accountline->fetch($this->fk_bank); + if ($accountline->rappro) + { + $this->error="ErrorBankRecordConcialiated"; + return -1; + } + } + $this->db->begin(); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."cotisation WHERE rowid = ".$this->id; dolibarr_syslog("Cotisation::delete sql=".$sql); $resql=$this->db->query($sql); if ($resql) { - if ( $this->db->affected_rows($resql)) + $num=$this->db->affected_rows($resql); + if ($num) { - return 1; + if ($this->fk_bank) + { + $result=$accountline->delete(); + if ($result > 0) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + else + { + $this->db->commit(); + return 1; + } } else { + $this->db->commit(); return 0; } } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); + $this->db->rollback(); return -1; } }