From d06e47956108baba1bf9849e130044cbd4017a3e Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 9 Oct 2008 20:19:18 +0000 Subject: [PATCH] IMPROVE QuickWriting check if account exist --- include/class_acc_account_ledger.php | 8 ++++++++ include/class_acc_ledger.php | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/class_acc_account_ledger.php b/include/class_acc_account_ledger.php index 528089752..79d855dd5 100644 --- a/include/class_acc_account_ledger.php +++ b/include/class_acc_account_ledger.php @@ -97,6 +97,14 @@ class Acc_Account_Ledger { } return $this->name; } + /*!\brief check if the poste exist in the tmp_pcmn + *\return the number of line (normally 1 or 0) + */ + function do_exist() { + $sql="select pcm_val from tmp_pcmn where pcm_val= $1"; + $ret=ExecSqlParam($this->db,$sql,array($this->id)); + return pg_NumRows($ret) ; + } /*!\brief Get all the value for this object from the database * the data member are set * \return false if this account doesn't exist otherwise true diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index e6d3d9fad..de5a8d0a5 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -1083,9 +1083,9 @@ class Acc_Ledger { if ( $p->belong_ledger ($p_jrn) < 0 ) throw new AcException("Le poste ".$p->id." n\'est pas dans ce journal",5); if ( strlen(trim(${'poste'.$i}))!=0 && isNumber(${'amount'.$i} ) == 0 ) - throw new AcException('Montant invalide',3); - - + throw new AcException('Poste invalide',3); + if ( $p->do_exist() == 0 ) + throw new AcException('Poste Inexistant',4); }