From 1b1cd2a1d25f90b1b19aaf5b0383e7afb63a3e41 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Sun, 27 Dec 2009 08:44:25 +0000 Subject: [PATCH] Minor fix --- gl/manage/bank_accounts.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/gl/manage/bank_accounts.php b/gl/manage/bank_accounts.php index 97a5dbba..09f07b04 100644 --- a/gl/manage/bank_accounts.php +++ b/gl/manage/bank_accounts.php @@ -26,19 +26,18 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') //initialise no input errors assumed initially before we test $input_error = 0; $curr = get_company_currency(); - if ($curr != $_POST['BankAccountCurrency']) + $sql = "SELECT account_code FROM ".TB_PREF."bank_accounts + WHERE account_code = '".$_POST['account_code']."'"; + if ($curr == $_POST['BankAccountCurrency']) + $sql .= " AND bank_curr_code <> '".$_POST['BankAccountCurrency']."'"; + $sql .= " AND id <> $selected_id"; + $result = db_query($sql,"could not get bank accounts"); + if (db_num_rows($result) > 0) { - $sql = "SELECT account_code FROM ".TB_PREF."bank_accounts - WHERE account_code = '".$_POST['account_code']."' - AND id <> $selected_id"; - $result = db_query($sql,"could not get bank accounts"); - if (db_num_rows($result) > 0) - { - $input_error = 1; - display_error(_("The GL account is already in use.")); - set_focus('account_code'); - } - } + $input_error = 1; + display_error(_("The GL account is already in use.")); + set_focus('account_code'); + } //first off validate inputs sensible if ($input_error == 0 && strlen($_POST['bank_account_name']) == 0) { -- 2.30.2