98c34da11e86b525d715fccb2be83b72da41dcdf
[fa-stable.git] / gl / view / gl_deposit_view.php
1 <?php
2 /**********************************************************************
3     Copyright (C) FrontAccounting, LLC.
4         Released under the terms of the GNU Affero General Public License,
5         AGPL, as published by the Free Software Foundation, either version 
6         3 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/agpl-3.0.html>.
11 ***********************************************************************/
12 $page_security = 1;
13 $path_to_root="../..";
14
15 include($path_to_root . "/includes/session.inc");
16
17 page(_("View Bank Deposit"), true);
18
19 include_once($path_to_root . "/includes/date_functions.inc");
20 include_once($path_to_root . "/includes/ui.inc");
21
22 include_once($path_to_root . "/gl/includes/gl_db.inc");
23
24 if (isset($_GET["trans_no"]))
25 {
26         $trans_no = $_GET["trans_no"];
27 }
28
29 // get the pay-to bank payment info
30 $result = get_bank_trans(systypes::bank_deposit(), $trans_no);
31
32 if (db_num_rows($result) != 1)
33         display_db_error("duplicate payment bank transaction found", "");
34
35 $to_trans = db_fetch($result);
36
37 $company_currency = get_company_currency();
38
39 $show_currencies = false;
40
41 if ($to_trans['bank_curr_code'] != $company_currency)
42 {
43         $show_currencies = true;
44 }
45
46 echo "<center>";
47
48 display_heading(_("GL Deposit") . " #$trans_no");
49
50 echo "<br>";
51 start_table("$table_style width=80%");
52
53 if ($show_currencies)
54 {
55         $colspan1 = 5;
56         $colspan2 = 8;
57 }
58 else
59 {
60         $colspan1 = 3;
61         $colspan2 = 6;
62 }
63 start_row();
64 label_cells(_("To Bank Account"), $to_trans['bank_account_name'], "class='tableheader2'");
65 if ($show_currencies)
66         label_cells(_("Currency"), $to_trans['bank_curr_code'], "class='tableheader2'");
67 label_cells(_("Amount"), number_format2($to_trans['amount'], user_price_dec()), "class='tableheader2'", "align=right");
68 label_cells(_("Date"), sql2date($to_trans['trans_date']), "class='tableheader2'");
69 end_row();
70 start_row();
71 label_cells(_("From"), payment_person_types::person_name($to_trans['person_type_id'], $to_trans['person_id']), "class='tableheader2'", "colspan=$colspan1");
72 label_cells(_("Deposit Type"), bank_account_types::transfer_type($to_trans['account_type']), "class='tableheader2'");
73 end_row();
74 start_row();
75 label_cells(_("Reference"), $to_trans['ref'], "class='tableheader2'", "colspan=$colspan2");
76 end_row();
77 comments_display_row(systypes::bank_deposit(), $trans_no);
78
79 end_table(1);
80
81 is_voided_display(systypes::bank_deposit(), $trans_no, _("This deposit has been voided."));
82
83 $items = get_gl_trans(systypes::bank_deposit(), $trans_no);
84
85 if (db_num_rows($items) == 0)
86 {
87         display_note(_("There are no items for this deposit."));
88 }
89 else
90 {
91
92         display_heading2(_("Items for this Deposit"));
93         if ($show_currencies)
94                 display_heading2(_("Item Amounts are Shown in :") . " " . $company_currency);
95
96     start_table("$table_style width=80%");
97     $th = array(_("Account Code"), _("Account Description"),
98         _("Amount"), _("Memo"));
99     table_header($th);
100
101     $k = 0; //row colour counter
102         $total_amount = 0;
103
104     while ($item = db_fetch($items))
105     {
106
107                 if ($item["account"] != $to_trans["account_code"])
108                 {
109                 alt_table_row_color($k);
110
111                 label_cell($item["account"]);
112                 label_cell($item["account_name"]);
113             amount_cell(abs($item["amount"]));
114                 label_cell($item["memo_"]);
115                 end_row();
116                 $total_amount += abs($item["amount"]);
117                 }
118         }
119
120         label_row(_("Total"), number_format2($total_amount, user_price_dec()),"colspan=2 align=right", "align=right");
121
122         end_table(1);
123
124         display_allocations_from($to_trans['person_type_id'], $to_trans['person_id'], 2, $trans_no, $to_trans['amount']);
125 }
126
127 end_page(true);
128 ?>