Allowed multiply bank accounts on same gl account, removed bank trans type.
[fa-stable.git] / gl / view / bank_transfer_view.php
1 <?php
2
3 $page_security = 1;
4 $path_to_root="../..";
5
6 include($path_to_root . "/includes/session.inc");
7
8 page(_("View Bank Transfer"), true);
9
10 include_once($path_to_root . "/includes/date_functions.inc");
11 include_once($path_to_root . "/includes/ui.inc");
12 include_once($path_to_root . "/gl/includes/gl_db.inc");
13
14 if (isset($_GET["trans_no"])){
15
16         $trans_no = $_GET["trans_no"];
17 }
18
19 $result = get_bank_trans(systypes::bank_transfer(), $trans_no);
20
21 if (db_num_rows($result) != 2)
22         display_db_error("Bank transfer does not contain two records", $sql);
23
24 $trans1 = db_fetch($result);
25 $trans2 = db_fetch($result);
26
27 if ($trans1["amount"] < 0) 
28 {
29     $from_trans = $trans1; // from trans is the negative one
30     $to_trans = $trans2;
31
32 else 
33 {
34         $from_trans = $trans2;
35         $to_trans = $trans1;
36 }
37
38 $company_currency = get_company_currency();
39
40 $show_currencies = false;
41 $show_both_amounts = false;
42
43 if (($from_trans['bank_curr_code'] != $company_currency) || ($to_trans['bank_curr_code'] != $company_currency))
44         $show_currencies = true;
45
46 if ($from_trans['bank_curr_code'] != $to_trans['bank_curr_code']) 
47 {
48         $show_currencies = true;
49         $show_both_amounts = true;
50 }
51
52 display_heading(systypes::name(systypes::bank_transfer()) . " #$trans_no");
53
54 echo "<br>";
55 start_table("$table_style width=80%");
56
57 start_row();
58 label_cells(_("From Bank Account"), $from_trans['bank_account_name'], "class='tableheader2'");
59 if ($show_currencies)
60         label_cells(_("Currency"), $from_trans['bank_curr_code'], "class='tableheader2'");
61 label_cells(_("Amount"), number_format2(-$from_trans['amount'], user_price_dec()), "class='tableheader2'", "align=right");
62 if ($show_currencies)
63 {
64         end_row();
65         start_row();
66 }       
67 label_cells(_("To Bank Account"), $to_trans['bank_account_name'], "class='tableheader2'");
68 if ($show_currencies)
69         label_cells(_("Currency"), $to_trans['bank_curr_code'], "class='tableheader2'");
70 if ($show_both_amounts)
71         label_cells(_("Amount"), number_format2($to_trans['amount'], user_price_dec()), "class='tableheader2'", "align=right");
72 end_row();
73 start_row();
74 label_cells(_("Date"), sql2date($from_trans['trans_date']), "class='tableheader2'");
75 label_cells(_("Transfer Type"), bank_account_types::transfer_type($from_trans['account_type']), "class='tableheader2'");
76 label_cells(_("Reference"), $from_trans['ref'], "class='tableheader2'");
77 end_row();
78 comments_display_row(systypes::bank_transfer(), $trans_no);
79
80 end_table(1);
81
82 is_voided_display(systypes::bank_transfer(), $trans_no, _("This transfer has been voided."));
83
84 end_page(true);
85 ?>