2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 $page_security = 'SA_BANKTRANSVIEW';
13 $path_to_root="../..";
15 include($path_to_root . "/includes/session.inc");
17 page(_($help_context = "View Bank Transfer"), true);
19 include_once($path_to_root . "/includes/date_functions.inc");
20 include_once($path_to_root . "/includes/ui.inc");
21 include_once($path_to_root . "/gl/includes/gl_db.inc");
23 if (isset($_GET["trans_no"])){
25 $trans_no = $_GET["trans_no"];
28 $result = get_bank_trans(ST_BANKTRANSFER, $trans_no);
30 if (db_num_rows($result) != 2)
31 display_db_error("Bank transfer does not contain two records");
33 $trans1 = db_fetch($result);
34 $trans2 = db_fetch($result);
36 if ($trans1["amount"] < 0)
38 $from_trans = $trans1; // from trans is the negative one
43 $from_trans = $trans2;
47 $company_currency = get_company_currency();
49 $show_currencies = false;
50 $show_both_amounts = false;
52 if (($from_trans['bank_curr_code'] != $company_currency) || ($to_trans['bank_curr_code'] != $company_currency))
53 $show_currencies = true;
55 if ($from_trans['bank_curr_code'] != $to_trans['bank_curr_code'])
57 $show_currencies = true;
58 $show_both_amounts = true;
61 display_heading($systypes_array[ST_BANKTRANSFER] . " #$trans_no");
64 start_table("$table_style width=80%");
67 label_cells(_("From Bank Account"), $from_trans['bank_account_name'], "class='tableheader2'");
69 label_cells(_("Currency"), $from_trans['bank_curr_code'], "class='tableheader2'");
70 label_cells(_("Amount"), number_format2(-$from_trans['amount'], user_price_dec()), "class='tableheader2'", "align=right");
76 label_cells(_("To Bank Account"), $to_trans['bank_account_name'], "class='tableheader2'");
78 label_cells(_("Currency"), $to_trans['bank_curr_code'], "class='tableheader2'");
79 if ($show_both_amounts)
80 label_cells(_("Amount"), number_format2($to_trans['amount'], user_price_dec()), "class='tableheader2'", "align=right");
83 label_cells(_("Date"), sql2date($from_trans['trans_date']), "class='tableheader2'");
84 label_cells(_("Transfer Type"), $bank_transfer_types[$from_trans['account_type']],
85 "class='tableheader2'");
86 label_cells(_("Reference"), $from_trans['ref'], "class='tableheader2'");
88 comments_display_row(ST_BANKTRANSFER, $trans_no);
92 is_voided_display(ST_BANKTRANSFER, $trans_no, _("This transfer has been voided."));