Added company switch for placing company logo on certain views.
[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 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 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(ST_BANKDEPOSIT, $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'] != $to_trans['settle_curr'])
42 {
43         $show_currencies = true;
44 }
45
46 if (!empty($SysPrefs->prefs['company_logo_on_views']))
47         company_logo_on_view();
48
49 echo "<center>";
50
51 display_heading(_("GL Deposit") . " #$trans_no");
52
53 echo "<br>";
54 start_table(TABLESTYLE, "width='80%'");
55
56 if ($show_currencies)
57 {
58         $colspan1 = 1;
59         $colspan2 = 7;
60 }
61 else
62 {
63         $colspan1 = 3;
64         $colspan2 = 5;
65 }
66 start_row();
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 label_cells(_("Amount"), number_format2($to_trans['amount'], user_price_dec()), "class='tableheader2'", "align=right");
71 label_cells(_("Date"), sql2date($to_trans['trans_date']), "class='tableheader2'");
72 end_row();
73 start_row();
74 label_cells(_("From"), get_counterparty_name(ST_BANKDEPOSIT, $to_trans['trans_no']), "class='tableheader2'", "colspan=$colspan1");
75 if ($show_currencies)
76 {
77         label_cells(_("Settle currency"), $to_trans['settle_curr'], "class='tableheader2'");
78         label_cells(_("Settled amount"),  number_format2($to_trans['settled_amount'], user_price_dec()), "class='tableheader2'");
79 }
80 label_cells(_("Deposit Type"), $bank_transfer_types[$to_trans['account_type']], "class='tableheader2'");
81 end_row();
82 start_row();
83 label_cells(_("Reference"), $to_trans['ref'], "class='tableheader2'", "colspan=$colspan2");
84 end_row();
85 comments_display_row(ST_BANKDEPOSIT, $trans_no);
86
87 end_table(1);
88
89 is_voided_display(ST_BANKDEPOSIT, $trans_no, _("This deposit has been voided."));
90
91 $items = get_gl_trans(ST_BANKDEPOSIT, $trans_no);
92
93 if (db_num_rows($items) == 0)
94 {
95         display_note(_("There are no items for this deposit."));
96 }
97 else
98 {
99
100         display_heading2(_("Items for this Deposit"));
101         if ($show_currencies)
102                 display_heading2(_("Item Amounts are Shown in:") . " " . $company_currency);
103
104     start_table(TABLESTYLE, "width='80%'");
105     $dim = get_company_pref('use_dimension');
106     if ($dim == 2)
107         $th = array(_("Account Code"), _("Account Description"), _("Dimension")." 1", _("Dimension")." 2",
108             _("Amount"), _("Memo"));
109     elseif ($dim == 1)
110         $th = array(_("Account Code"), _("Account Description"), _("Dimension"),
111             _("Amount"), _("Memo"));
112     else
113         $th = array(_("Account Code"), _("Account Description"),
114             _("Amount"), _("Memo"));
115     table_header($th);
116
117     $k = 0; //row colour counter
118         $total_amount = 0;
119
120     while ($item = db_fetch($items))
121     {
122
123                 if ($item["account"] != $to_trans["account_code"])
124                 {
125                 alt_table_row_color($k);
126
127                 label_cell($item["account"]);
128                 label_cell($item["account_name"]);
129             if ($dim >= 1)
130                 label_cell(get_dimension_string($item['dimension_id'], true));
131             if ($dim > 1)
132                 label_cell(get_dimension_string($item['dimension2_id'], true));
133             amount_cell(-$item["amount"]);
134                 label_cell($item["memo_"]);
135                 end_row();
136                 $total_amount += $item["amount"];
137                 }
138         }
139
140         label_row(_("Total"), number_format2(-$total_amount, user_price_dec()),"colspan=".(2+$dim)." align=right", "align=right");
141
142         end_table(1);
143
144         display_allocations_from($to_trans['person_type_id'], $to_trans['person_id'], 2, $trans_no, $to_trans['settled_amount']);
145 }
146
147 end_page(true, false, false, ST_BANKDEPOSIT, $trans_no);