Added text fields sanitization on upgrdae to 2.2.
[fa-stable.git] / gl / includes / db / gl_db_banking.inc
index cc028ac75e0314469ab85a5d6a7aa873595b8814..bbef96d21c4aeb404f8fd28b9c50e584830f5e5c 100644 (file)
@@ -18,7 +18,7 @@ function add_exchange_variation($trans_type, $trans_no, $date_, $acc_id, $accoun
                $date_ = Today();
        $rate = get_exchange_rate_from_home_currency($currency, $date_);
        $result = db_query("SELECT SUM(amount) FROM ".TB_PREF."bank_trans WHERE 
-               bank_act='$acc_id' AND trans_date<='".date2sql($date_)."'", 
+               bank_act=".db_escape($acc_id)." AND trans_date<='".date2sql($date_)."'", 
                "Transactions for account $account could not be calculated");
        $row = db_fetch_row($result);
        $foreign_amount = $row[0];
@@ -41,11 +41,11 @@ function add_exchange_variation($trans_type, $trans_no, $date_, $acc_id, $accoun
 
 function add_exchange_variation_all()
 {
-       $trans_no = get_next_trans_no(0);
+       $trans_no = get_next_trans_no(ST_JOURNAL);
        $sql = "SELECT * FROM ".TB_PREF."bank_accounts";
        $result = db_query($sql, "could not retreive bank accounts");
        while ($myrow = db_fetch($result))
-               add_exchange_variation(0, $trans_no, null, $myrow['id'], $myrow['account_code'],
+               add_exchange_variation(ST_JOURNAL, $trans_no, null, $myrow['id'], $myrow['account_code'],
                        $myrow['currency_code']);
 }
 //----------------------------------------------------------------------------------
@@ -189,7 +189,7 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_,
        {
                $is_bank_to = is_bank_account($gl_item->code_id);
 
-               if ($trans_type == 1 AND $is_bank_to)
+               if ($trans_type == ST_BANKPAYMENT AND $is_bank_to)
                {
                        // we don't allow payments to go to a bank account. use transfer for this !
                        display_db_error("invalid payment entered. Cannot pay to another bank account", "");