From: Janusz Dobrowolski Date: Fri, 8 Jul 2011 09:13:01 +0000 (+0200) Subject: Added checks on bank account creation to avoid selection of already used GL account. X-Git-Tag: 2.3-final~603 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;ds=sidebyside;h=938f8bff59d5a8a31fb0ef71636abb6abb324365;p=fa-stable.git Added checks on bank account creation to avoid selection of already used GL account. --- diff --git a/gl/includes/db/gl_db_accounts.inc b/gl/includes/db/gl_db_accounts.inc index f085cfe8..f97b713e 100644 --- a/gl/includes/db/gl_db_accounts.inc +++ b/gl/includes/db/gl_db_accounts.inc @@ -179,4 +179,14 @@ function gl_account_in_quick_entry_lines($acc) $myrow = db_fetch_row($result); return ($myrow[0] > 0); } + +function gl_account_in_bank_accounts($acc) +{ + $sql= "SELECT COUNT(*) FROM ".TB_PREF."bank_accounts WHERE + account_code=".db_escape($acc); + $result = db_query($sql,"Couldn't test bank account GL codes"); + + $myrow = db_fetch_row($result); + return ($myrow[0] > 0); +} ?> \ No newline at end of file diff --git a/gl/manage/bank_accounts.php b/gl/manage/bank_accounts.php index 634283b4..d8d02ab2 100644 --- a/gl/manage/bank_accounts.php +++ b/gl/manage/bank_accounts.php @@ -33,7 +33,12 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') display_error(_("The bank account name cannot be empty.")); set_focus('bank_account_name'); } - + if ($Mode=='ADD_ITEM' && (gl_account_in_bank_accounts(get_post('account_code')) + || key_in_foreign_table(get_post('account_code'), 'gl_trans', 'account', true))) { + $input_error = 1; + display_error(_("The GL account selected is already in use. Select another GL account.")); + set_focus('account_code'); + } if ($input_error != 1) { if ($selected_id != -1)