X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fincludes%2Fdb%2Fgl_db_accounts.inc;h=00b8fbe34698076501bd17479bf01c3a7ddda7ea;hb=c164d1f25c5258939976042fa8796b71ac54c188;hp=ce11a325607e6bfb2807ec86cc991f371e714de0;hpb=3f3cfa578adbc2b71f4fd9c8d0f5536d26af43d8;p=fa-stable.git diff --git a/gl/includes/db/gl_db_accounts.inc b/gl/includes/db/gl_db_accounts.inc index ce11a325..00b8fbe3 100644 --- a/gl/includes/db/gl_db_accounts.inc +++ b/gl/includes/db/gl_db_accounts.inc @@ -227,4 +227,22 @@ function gl_account_in_bank_accounts($acc) $myrow = db_fetch_row($result); return ($myrow[0] > 0); } -?> \ No newline at end of file + +//---------------------------------------------------------------------------------- +// Check if given account is used by any bank_account. +// Returns id of first bank_account using account_code, null otherwise. +// +// Keep in mind that direct posting to bank account is depreciated +// because we have no way to select right bank account if +// there is more than one using given gl account. +// +function is_bank_account($account_code) +{ + $sql= "SELECT id FROM ".TB_PREF."bank_accounts WHERE account_code=".db_escape($account_code); + $result = db_query($sql, "checking account is bank account"); + if (db_num_rows($result) > 0) { + $acct = db_fetch($result); + return $acct['id']; + } else + return false; +}