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 Payment"), true);
19 include_once($path_to_root . "/includes/date_functions.inc");
20 include_once($path_to_root . "/includes/ui.inc");
22 include_once($path_to_root . "/gl/includes/gl_db.inc");
24 if (isset($_GET["trans_no"]))
26 $trans_no = $_GET["trans_no"];
29 // get the pay-from bank payment info
30 $result = get_bank_trans(ST_BANKPAYMENT, $trans_no);
32 if (db_num_rows($result) != 1)
33 display_db_error("duplicate payment bank transaction found", "");
35 $from_trans = db_fetch($result);
37 $company_currency = get_company_currency();
39 $show_currencies = false;
41 if ($from_trans['bank_curr_code'] != $from_trans['settle_curr'])
43 $show_currencies = true;
46 if (!empty($SysPrefs->prefs['company_logo_on_views']))
47 company_logo_on_view();
49 display_heading(_("GL Payment") . " #$trans_no");
52 start_table(TABLESTYLE, "width='80%'");
65 label_cells(_("From Bank Account"), $from_trans['bank_account_name'], "class='tableheader2'");
67 label_cells(_("Currency"), $from_trans['bank_curr_code'], "class='tableheader2'");
68 label_cells(_("Amount"), number_format2(-$from_trans['amount'], user_price_dec()), "class='tableheader2'", "align=right");
69 label_cells(_("Date"), sql2date($from_trans['trans_date']), "class='tableheader2'");
72 label_cells(_("Pay To"), get_counterparty_name(ST_BANKPAYMENT, $from_trans['trans_no']), "class='tableheader2'", "colspan=$colspan1");
75 label_cells(_("Settle currency"), $from_trans['settle_curr'], "class='tableheader2'");
76 label_cells(_("Settled amount"), number_format2($from_trans['settled_amount'], user_price_dec()), "class='tableheader2'");
78 label_cells(_("Payment Type"), $bank_transfer_types[$from_trans['account_type']], "class='tableheader2'");
81 label_cells(_("Reference"), $from_trans['ref'], "class='tableheader2'", "colspan=$colspan2");
83 comments_display_row(ST_BANKPAYMENT, $trans_no);
87 $voided = is_voided_display(ST_BANKPAYMENT, $trans_no, _("This payment has been voided."));
89 $items = get_gl_trans(ST_BANKPAYMENT, $trans_no);
91 if (db_num_rows($items)==0)
93 display_note(_("There are no items for this payment."));
98 display_heading2(_("Items for this Payment"));
100 display_heading2(_("Item Amounts are Shown in:") . " " . $company_currency);
103 start_table(TABLESTYLE, "width='80%'");
104 $dim = get_company_pref('use_dimension');
106 $th = array(_("Account Code"), _("Account Description"), _("Dimension")." 1", _("Dimension")." 2",
107 _("Amount"), _("Memo"));
109 $th = array(_("Account Code"), _("Account Description"), _("Dimension"),
110 _("Amount"), _("Memo"));
112 $th = array(_("Account Code"), _("Account Description"),
113 _("Amount"), _("Memo"));
116 $k = 0; //row colour counter
119 while ($item = db_fetch($items))
122 if ($item["account"] != $from_trans["account_code"])
124 alt_table_row_color($k);
126 label_cell($item["account"]);
127 label_cell($item["account_name"]);
129 label_cell(get_dimension_string($item['dimension_id'], true));
131 label_cell(get_dimension_string($item['dimension2_id'], true));
132 amount_cell($item["amount"]);
133 label_cell($item["memo_"]);
135 $total_amount += $item["amount"];
139 label_row(_("Total"), number_format2($total_amount, user_price_dec()),"colspan=".(2+$dim)." align=right", "align=right");
144 display_allocations_from($from_trans['person_type_id'], $from_trans['person_id'], 1, $trans_no, $from_trans['settled_amount']);
147 end_page(true, false, false, ST_BANKPAYMENT, $trans_no);