From d54d2bcdb65dfc1fa4a75d1a03a5227396fbcf88 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Tue, 23 Nov 2021 19:40:57 +0100 Subject: [PATCH] =?UTF-8?q?Bug=20#2098:=20Les=20fiches=20utilis=C3=A9es=20?= =?UTF-8?q?dans=20le=20suivi=20ne=20peuvent=20pas=20=C3=AAtre=20effac?= =?UTF-8?q?=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class/fiche.class.php | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php index 6a12dd01f..79b263aaa 100644 --- a/include/class/fiche.class.php +++ b/include/class/fiche.class.php @@ -540,31 +540,23 @@ class Fiche $this->quick_code=$this->strAttribut(ATTR_DEF_QUICKCODE); } - /*!\brief remove a card + /*!\brief remove a card, check if not used first, must be synchro with is_used */ function remove($silent=false) { if ( $this->id==0 ) return; - // verify if that card has not been used is a ledger + // verify if that card has not been used is a ledger nor in the followup // if the card has its own account in PCMN // Get the fiche_def.fd_id from fiche.f_id - $this->Get(); - $fiche_def=new Fiche_Def($this->cn,$this->fiche_def); - $fiche_def->get(); - - // if the card is used do not removed it - $qcode=$this->strAttribut(ATTR_DEF_QUICKCODE); - - if ( $this->cn->count_sql("select * from jrnx where j_qcode='".Database::escape_string($qcode)."'") != 0) - { - if ( ! $silent ) { - alert(_('Impossible cette fiche est utilisée dans un journal')); - } - return 1; + if ( $this->is_used() == FALSE) { + $this->delete(); + return 0; } - - $this->delete(); - return 0; + + if ( ! $silent ) { + alert(_('Impossible cette fiche est utilisée dans un journal')); + } + return 1; }