0d7c51e789cd936d96561a2f6e5020c5609df5ef
[fa-stable.git] / gl / view / gl_payment_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 Payment"), true);
9
10 include_once($path_to_root . "/includes/date_functions.inc");
11 include_once($path_to_root . "/includes/ui.inc");
12
13 include_once($path_to_root . "/gl/includes/gl_db.inc");
14
15 if (isset($_GET["trans_no"]))
16 {
17         $trans_no = $_GET["trans_no"];
18 }
19
20 // get the pay-from bank payment info
21 $result = get_bank_trans(systypes::bank_payment(), $trans_no);
22
23 if (db_num_rows($result) != 1)
24         display_db_error("duplicate payment bank transaction found", "");
25
26 $from_trans = db_fetch($result);
27
28 $company_currency = get_company_currency();
29
30 $show_currencies = false;
31
32 if ($from_trans['bank_curr_code'] != $company_currency) 
33 {
34         $show_currencies = true;
35 }
36
37 display_heading(_("GL Payment") . " #$trans_no");
38
39 echo "<br>";
40 start_table("$table_style width=80%");
41
42 if ($show_currencies)
43 {
44         $colspan1 = 5;
45         $colspan2 = 8;
46 }
47 else
48 {
49         $colspan1 = 3;
50         $colspan2 = 6;
51 }
52 start_row();
53 label_cells(_("From Bank Account"), $from_trans['bank_account_name'], "class='tableheader2'");
54 if ($show_currencies)
55         label_cells(_("Currency"), $from_trans['bank_curr_code'], "class='tableheader2'");
56 label_cells(_("Amount"), number_format2(-$from_trans['amount'], user_price_dec()), "class='tableheader2'", "align=right");
57 label_cells(_("Date"), sql2date($from_trans['trans_date']), "class='tableheader2'");
58 end_row();
59 start_row();
60 label_cells(_("Pay To"), payment_person_types::person_name($from_trans['person_type_id'], $from_trans['person_id']), "class='tableheader2'", "colspan=$colspan1");
61 label_cells(_("Payment Type"), $from_trans['BankTransType'], "class='tableheader2'");
62 end_row();
63 start_row();
64 label_cells(_("Reference"), $from_trans['ref'], "class='tableheader2'", "colspan=$colspan2");
65 end_row();
66 comments_display_row(systypes::bank_payment(), $trans_no);
67
68 end_table(1);
69
70 $voided = is_voided_display(systypes::bank_payment(), $trans_no, _("This payment has been voided."));
71
72 $items = get_gl_trans(systypes::bank_payment(), $trans_no);
73
74 if (db_num_rows($items)==0)
75 {
76         echo "<br>" . _("There are no items for this payment.");
77
78 else 
79 {
80
81         display_heading2(_("Items for this Payment"));
82         if ($show_currencies)
83                 display_heading2(_("Item Amounts are Shown in :") . " " . $company_currency);
84
85     echo "<br>";
86     start_table("$table_style width=80%");
87     $th = array(_("Account Code"), _("Account Description"),
88         _("Amount"), _("Memo"));
89         table_header($th);
90
91     $k = 0; //row colour counter
92         $totalAmount = 0;
93
94     while ($item = db_fetch($items)) 
95     {
96
97                 if ($item["account"] != $from_trans["account_code"]) 
98                 {
99                 alt_table_row_color($k);
100
101                 label_cell($item["account"]);
102                 label_cell($item["account_name"]);
103                 amount_cell($item["amount"]);
104                 label_cell($item["memo_"]);
105                 end_row();
106                 $totalAmount += $item["amount"];
107                 }
108         }
109
110         label_row(_("Total"), number_format2($totalAmount, user_price_dec()),"colspan=2 align=right", "align=right");
111
112         end_table(1);
113
114         if (!$voided)
115                 display_allocations_from($from_trans['person_type_id'], $from_trans['person_id'], 1, $trans_no, -$from_trans['amount']);
116 }
117
118 end_page(true);
119 ?>