0); } //---------------------------------------------------------------------------------------- function get_bank_trans($type, $trans_no=null, $person_type_id=null, $person_id=null) { $sql = "SELECT *, bank_account_name, account_code, bank_curr_code, name AS BankTransType FROM ".TB_PREF."bank_trans, ".TB_PREF."bank_accounts, ".TB_PREF."bank_trans_types WHERE ".TB_PREF."bank_trans_types.id = ".TB_PREF."bank_trans.bank_trans_type_id AND ".TB_PREF."bank_accounts.account_code=".TB_PREF."bank_trans.bank_act "; if ($type != null) $sql .= " AND type=$type "; if ($trans_no != null) $sql .= " AND ".TB_PREF."bank_trans.trans_no = $trans_no "; if ($person_type_id != null) $sql .= " AND ".TB_PREF."bank_trans.person_type_id = $person_type_id "; if ($person_id != null) $sql .= " AND ".TB_PREF."bank_trans.person_id = '$person_id'"; $sql .= " ORDER BY trans_date, ".TB_PREF."bank_trans.id"; return db_query($sql, "query for bank transaction"); } //---------------------------------------------------------------------------------------- function get_gl_trans_value($account, $type, $trans_no) { $sql = "SELECT SUM(amount) FROM ".TB_PREF."gl_trans WHERE account=$account AND type=$type AND type_no=$trans_no"; $result = db_query($sql, "query for gl trans value"); $row = db_fetch_row($result); return $row[0]; } //---------------------------------------------------------------------------------------- function void_bank_trans($type, $type_no, $nested=false) { if (!$nested) begin_transaction(); $sql = "UPDATE ".TB_PREF."bank_trans SET amount=0 WHERE type=$type AND trans_no=$type_no"; $result = db_query($sql, "could not void bank transactions for type=$type and trans_no=$type_no"); void_gl_trans($type, $type_no, true); // in case it's a customer trans - probably better to check first void_cust_allocations($type, $type_no); void_customer_trans($type, $type_no); // in case it's a supplier trans - probably better to check first void_supp_allocations($type, $type_no); void_supp_trans($type, $type_no); if (!$nested) commit_transaction(); } //---------------------------------------------------------------------------------- ?>