From ddcdaf8739143ead33ea644a4956fdb183ef61dd Mon Sep 17 00:00:00 2001 From: sparkyx Date: Fri, 9 Mar 2007 18:50:54 +0000 Subject: [PATCH] Fix: not allowed to delete an card used in a journal --- include/class_fiche.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/include/class_fiche.php b/include/class_fiche.php index 795e7c48b..700456422 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -631,20 +631,31 @@ class fiche { $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 ( CountSql($this->cn,"select * from jrnx where j_qcode='$qcode'") != 0) + { + echo ""; + return; + } + if ( $fiche_def->create_account=='t' ) { // Retrieve the 'poste comptable' $class=$this->strAttribut(ATTR_DEF_ACCOUNT); - + $is_used_jrnx= CountSql($this->cn,"select * from jrnx where j_poste=$class"); // if class is not NULL and if we use it before, we can't remove it - if (FormatString($class) != null && - CountSql($this->cn,"select * from jrnx where j_poste=$class") != 0 ) { - echo ""; - return; - } else { + if (FormatString($class) != null && $is_used_jrnx != 0 ) + { + echo ""; + return; + } + else // Remove in PCMN - if ( trim(strlen($class)) != 0 and isNumber($class) == 1) - ExecSql($this->cn,"delete from tmp_pcmn where pcm_val=".$class); - } + if ( trim(strlen($class)) != 0 && isNumber($class) == 1 && $is_used_jrnx == 0) + { + ExecSql($this->cn,"delete from tmp_pcmn where pcm_val=".$class); + } } // Remove from attr_value