X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fmanage%2Fbank_accounts.php;h=fa441ef09435628b56a9e24924f7540971b92e33;hb=bb991dc5b071e966b39954bb53d3b0efe8420938;hp=ae1dc41e6f8cc7e924b4a1bc0ef88397afa17286;hpb=d2cc0860eccf02eaefcd90731ac3af141a841529;p=fa-stable.git diff --git a/gl/manage/bank_accounts.php b/gl/manage/bank_accounts.php index ae1dc41e..fa441ef0 100644 --- a/gl/manage/bank_accounts.php +++ b/gl/manage/bank_accounts.php @@ -66,18 +66,13 @@ elseif( $Mode == 'Delete') $acc = db_escape($selected_id); // PREVENT DELETES IF DEPENDENT RECORDS IN 'bank_trans' - $sql= "SELECT COUNT(*) FROM ".TB_PREF."bank_trans WHERE bank_act=$acc"; - $result = db_query($sql,"check failed"); - $myrow = db_fetch_row($result); - if ($myrow[0] > 0) + if (key_in_foreign_table($acc, 'bank_trans', 'bank_act', true)) { $cancel_delete = 1; display_error(_("Cannot delete this bank account because transactions have been created using this account.")); } - $sql= "SELECT COUNT(*) FROM ".TB_PREF."sales_pos WHERE pos_account=$acc"; - $result = db_query($sql,"check failed"); - $myrow = db_fetch_row($result); - if ($myrow[0] > 0) + + if (key_in_foreign_table($acc, 'sales_pos', 'pos_account', true)) { $cancel_delete = 1; display_error(_("Cannot delete this bank account because POS definitions have been created using this account.")); @@ -99,18 +94,10 @@ if ($Mode == 'RESET') /* Always show the list of accounts */ -$sql = "SELECT account.*, gl_account.account_name - FROM ".TB_PREF."bank_accounts account, ".TB_PREF."chart_master gl_account - WHERE account.account_code = gl_account.account_code"; -if (!check_value('show_inactive')) $sql .= " AND !account.inactive"; -$sql .= " ORDER BY account_code, bank_curr_code"; - -$result = db_query($sql,"could not get bank accounts"); - -check_db_error("The bank accounts set up could not be retreived", $sql); +$result = get_bank_accounts(check_value('show_inactive')); start_form(); -start_table("$table_style width='80%'"); +start_table(TABLESTYLE, "width='80%'"); $th = array(_("Account Name"), _("Type"), _("Currency"), _("GL Account"), _("Bank"), _("Number"), _("Bank Address"), _("Dflt"), '',''); @@ -146,7 +133,7 @@ end_table(1); $is_editing = $selected_id != -1; -start_table($table_style2); +start_table(TABLESTYLE2); if ($is_editing) {