Added company switch for placing company logo on certain views.
[fa-stable.git] / gl / view / bank_transfer_view.php
1 <?php
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="../..";
14
15 include($path_to_root . "/includes/session.inc");
16
17 page(_($help_context = "View Bank Transfer"), true);
18
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");
22
23 if (isset($_GET["trans_no"])){
24
25         $trans_no = $_GET["trans_no"];
26 }
27
28 $result = get_bank_trans(ST_BANKTRANSFER, $trans_no);
29
30 if (db_num_rows($result) != 2)
31         display_db_error("Bank transfer does not contain two records");
32
33 $trans1 = db_fetch($result);
34 $trans2 = db_fetch($result);
35
36 if ($trans1["amount"] < 0) 
37 {
38     $from_trans = $trans1; // from trans is the negative one
39     $to_trans = $trans2;
40
41 else 
42 {
43         $from_trans = $trans2;
44         $to_trans = $trans1;
45 }
46
47 $company_currency = get_company_currency();
48
49 $show_currencies = false;
50 $show_both_amounts = false;
51
52 if (($from_trans['bank_curr_code'] != $company_currency) || ($to_trans['bank_curr_code'] != $company_currency))
53         $show_currencies = true;
54
55 if ($from_trans['bank_curr_code'] != $to_trans['bank_curr_code']) 
56 {
57         $show_currencies = true;
58         $show_both_amounts = true;
59 }
60
61 if (!empty($SysPrefs->prefs['company_logo_on_views']))
62         company_logo_on_view();
63
64 display_heading($systypes_array[ST_BANKTRANSFER] . " #$trans_no");
65
66 echo "<br>";
67 start_table(TABLESTYLE, "width='80%'");
68
69 start_row();
70 label_cells(_("From Bank Account"), $from_trans['bank_account_name'], "class='tableheader2'");
71 if ($show_currencies)
72         label_cells(_("Currency"), $from_trans['bank_curr_code'], "class='tableheader2'");
73 label_cells(_("Amount"), number_format2(-$from_trans['amount'], user_price_dec()), "class='tableheader2'", "align=right");
74 if ($show_currencies)
75 {
76         end_row();
77         start_row();
78 }       
79 label_cells(_("To Bank Account"), $to_trans['bank_account_name'], "class='tableheader2'");
80 if ($show_currencies)
81         label_cells(_("Currency"), $to_trans['bank_curr_code'], "class='tableheader2'");
82 if ($show_both_amounts)
83         label_cells(_("Amount"), number_format2($to_trans['amount'], user_price_dec()), "class='tableheader2'", "align=right");
84 end_row();
85 start_row();
86 label_cells(_("Date"), sql2date($from_trans['trans_date']), "class='tableheader2'");
87 label_cells(_("Transfer Type"), $bank_transfer_types[$from_trans['account_type']],
88          "class='tableheader2'");
89 label_cells(_("Reference"), $from_trans['ref'], "class='tableheader2'");
90 end_row();
91 comments_display_row(ST_BANKTRANSFER, $trans_no);
92
93 end_table(1);
94
95 is_voided_display(ST_BANKTRANSFER, $trans_no, _("This transfer has been voided."));
96
97 end_page(true, false, false, ST_BANKTRANSFER, $trans_no);