Replaced the global variables for table styles to defined CSS classes.
[fa-stable.git] / gl / inquiry / tax_inquiry.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_TAXREP';
13 $path_to_root="../..";
14 include_once($path_to_root . "/includes/session.inc");
15
16
17 include_once($path_to_root . "/includes/date_functions.inc");
18 include_once($path_to_root . "/includes/ui.inc");
19 include_once($path_to_root . "/includes/data_checks.inc");
20
21 include_once($path_to_root . "/gl/includes/gl_db.inc");
22
23 $js = '';
24 set_focus('account');
25 if ($use_popup_windows)
26         $js .= get_js_open_window(800, 500);
27 if ($use_date_picker)
28         $js .= get_js_date_picker();
29
30 page(_($help_context = "Tax Inquiry"), false, false, '', $js);
31
32 //----------------------------------------------------------------------------------------------------
33 // Ajax updates
34 //
35 if (get_post('Show')) 
36 {
37         $Ajax->activate('trans_tbl');
38 }
39
40 if (get_post('TransFromDate') == "" && get_post('TransToDate') == "")
41 {
42         $date = Today();
43         $row = get_company_prefs();
44         $edate = add_months($date, -$row['tax_last']);
45         $edate = end_month($edate);
46         $bdate = begin_month($edate);
47         $bdate = add_months($bdate, -$row['tax_prd'] + 1);
48         $_POST["TransFromDate"] = $bdate;
49         $_POST["TransToDate"] = $edate;
50 }       
51
52 //----------------------------------------------------------------------------------------------------
53
54 function tax_inquiry_controls()
55 {
56     start_form();
57
58     start_table(TABLESTYLE_NOBORDER);
59         start_row();
60
61         date_cells(_("from:"), 'TransFromDate', '', null, -30);
62         date_cells(_("to:"), 'TransToDate');
63         submit_cells('Show',_("Show"),'','', 'default');
64
65     end_row();
66
67         end_table();
68
69     end_form();
70 }
71
72 //----------------------------------------------------------------------------------------------------
73
74 function show_results()
75 {
76         global $path_to_root;
77
78     /*Now get the transactions  */
79         div_start('trans_tbl');
80         start_table(TABLESTYLE);
81
82         $th = array(_("Type"), _("Description"), _("Amount"), _("Outputs")."/"._("Inputs"));
83         table_header($th);
84         $k = 0;
85         $total = 0;
86         $bdate = date2sql($_POST['TransFromDate']);
87         $edate  = date2sql($_POST['TransToDate']);
88
89         $taxes = get_tax_summary($_POST['TransFromDate'], $_POST['TransToDate']);
90
91         while ($tx = db_fetch($taxes))
92         {
93
94                 $payable = $tx['payable'];
95                 $collectible = $tx['collectible'];
96                 $net = $collectible + $payable;
97                 $total += $net;
98                 alt_table_row_color($k);
99                 label_cell($tx['name'] . " " . $tx['rate'] . "%");
100                 label_cell(_("Charged on sales") . " (" . _("Output Tax")."):");
101                 amount_cell($payable);
102                 amount_cell($tx['net_output']);
103                 end_row();
104                 alt_table_row_color($k);
105                 label_cell($tx['name'] . " " . $tx['rate'] . "%");
106                 label_cell(_("Paid on purchases") . " (" . _("Input Tax")."):");
107                 amount_cell($collectible);
108                 amount_cell($tx['net_input']);
109                 end_row();
110                 alt_table_row_color($k);
111                 label_cell("<b>".$tx['name'] . " " . $tx['rate'] . "%</b>");
112                 label_cell("<b>"._("Net payable or collectible") . ":</b>");
113                 amount_cell($net, true);
114                 label_cell("");
115                 end_row();
116         }       
117         alt_table_row_color($k);
118         label_cell("");
119         label_cell("<b>"._("Total payable or refund") . ":</b>");
120         amount_cell($total, true);
121         label_cell("");
122         end_row();
123
124         end_table(2);
125         div_end();
126 }
127
128 //----------------------------------------------------------------------------------------------------
129
130 tax_inquiry_controls();
131
132 show_results();
133
134 //----------------------------------------------------------------------------------------------------
135
136 end_page();
137
138 ?>