User side percent/qty/amount/exrate input formatting via onblur handler.
[fa-stable.git] / admin / gl_setup.php
1 <?php
2
3 $page_security =10;
4 $path_to_root="..";
5 include($path_to_root . "/includes/session.inc");
6
7 page(_("System and General GL Setup"));
8
9 include_once($path_to_root . "/includes/date_functions.inc");
10 include_once($path_to_root . "/includes/ui.inc");
11 include_once($path_to_root . "/includes/data_checks.inc");
12
13 include_once($path_to_root . "/admin/db/company_db.inc");
14
15 //-------------------------------------------------------------------------------------------------
16
17 function can_process() 
18 {
19         if (!check_num('po_over_receive', 0, 100)) 
20         {
21                 display_error(_("The delivery over-receive allowance must be between 0 and 100."));
22                 return false;
23         }
24
25         if (!check_num('po_over_charge', 0, 100)) 
26         {
27                 display_error(_("The invoice over-charge allowance must be between 0 and 100."));
28                 return false;
29         }
30
31         if (!check_num('past_due_days', 0, 100)) 
32         {
33                 display_error(_("The past due days interval allowance must be between 0 and 100."));
34                 return false;
35         }
36         return true;
37 }
38
39 //-------------------------------------------------------------------------------------------------
40
41 if (isset($_POST['submit']) && can_process()) 
42 {
43         update_company_gl_setup($_POST['debtors_act'], $_POST['pyt_discount_act'],
44                 $_POST['creditors_act'], $_POST['grn_act'],
45                 $_POST['exchange_diff_act'], $_POST['purch_exchange_diff_act'],
46                 $_POST['retained_earnings_act'], $_POST['freight_act'],
47                 $_POST['default_sales_act'],
48                 $_POST['default_sales_discount_act'],
49                 $_POST['default_prompt_payment_act'],
50                 $_POST['default_inventory_act'],
51                 $_POST['default_cogs_act'],
52                 $_POST['default_adj_act'],
53                 $_POST['default_inv_sales_act'],
54                 $_POST['default_assembly_act'], $_POST['payroll_act'],
55                 check_value('allow_negative_stock'),
56                 input_num('po_over_receive'),
57                 input_num('po_over_charge'),
58                 $_POST['past_due_days'],
59                 $_POST['default_credit_limit'],
60                 $_POST['default_workorder_required'],
61                 $_POST['default_dim_required']);
62
63         display_notification(_("The general GL setup has been updated."));
64
65 } /* end of if submit */
66
67 //-------------------------------------------------------------------------------------------------
68
69 start_form();
70 start_table("class='tablestyle'");
71
72 $myrow = get_company_prefs();
73
74 $_POST['debtors_act']  = $myrow["debtors_act"];
75 $_POST['creditors_act']  = $myrow["creditors_act"];
76 $_POST['grn_act'] = $myrow["grn_act"];
77 $_POST['retained_earnings_act'] = $myrow["retained_earnings_act"];
78 $_POST['freight_act'] = $myrow["freight_act"];
79 $_POST['exchange_diff_act']  = $myrow["exchange_diff_act"];
80
81 $_POST['purch_exchange_diff_act']  = $myrow["purch_exchange_diff_act"];
82 $_POST['pyt_discount_act']  = $myrow["pyt_discount_act"];
83
84 $_POST['default_sales_act'] = $myrow["default_sales_act"];
85 $_POST['default_sales_discount_act']  = $myrow["default_sales_discount_act"];
86 $_POST['default_prompt_payment_act']  = $myrow["default_prompt_payment_act"];
87
88 $_POST['default_inventory_act'] = $myrow["default_inventory_act"];
89 $_POST['default_cogs_act'] = $myrow["default_cogs_act"];
90 $_POST['default_adj_act'] = $myrow["default_adj_act"];
91 $_POST['default_inv_sales_act'] = $myrow['default_inv_sales_act'];
92 $_POST['default_assembly_act'] = $myrow['default_assembly_act'];
93 $_POST['payroll_act'] = $myrow['payroll_act'];
94
95 $_POST['allow_negative_stock'] = $myrow['allow_negative_stock'];
96
97 $_POST['po_over_receive'] = percent_format($myrow['po_over_receive']);
98 $_POST['po_over_charge'] = percent_format($myrow['po_over_charge']);
99 $_POST['past_due_days'] = $myrow['past_due_days'];
100
101 $_POST['default_credit_limit'] = $myrow['default_credit_limit'];
102
103 $_POST['default_workorder_required'] = $myrow['default_workorder_required'];
104 $_POST['default_dim_required'] = $myrow['default_dim_required'];
105
106 //echo "<table>";
107
108 //---------------
109
110
111 table_section_title(_("General GL"));
112
113 gl_all_accounts_list_row(_("Retained Earning Clearing Account:"), 'retained_earnings_act', $_POST['retained_earnings_act']);
114 gl_all_accounts_list_row(_("Payroll Account:"), 'payroll_act', $_POST['payroll_act']);
115 text_row(_("Past Due Days Interval:"), 'past_due_days', $_POST['past_due_days'], 6, 6, "", _("days"));
116
117 //---------------
118
119 table_section_title(_("Customers and Sales"));
120
121 text_row(_("Default Credit Limit:"), 'default_credit_limit', $_POST['default_credit_limit'], 12, 12);
122
123 gl_all_accounts_list_row(_("Sales Exchange Variances Account:"), 'exchange_diff_act', $_POST['exchange_diff_act']);
124
125 gl_all_accounts_list_row(_("Shipping Charged Account:"), 'freight_act', $_POST['freight_act']);
126
127 //---------------
128
129 table_section_title(_("Customers and Sales Defaults"));
130
131 gl_all_accounts_list_row(_("Accounts Receivable Account:"), 'debtors_act', $_POST['debtors_act']);
132
133 gl_all_accounts_list_row(_("Sales Account:"), 'default_sales_act', $_POST['default_sales_act']);
134
135 gl_all_accounts_list_row(_("Sales Discount Account:"), 'default_sales_discount_act', $_POST['default_sales_discount_act']);
136
137 gl_all_accounts_list_row(_("Prompt Payment Discount Account:"), 'default_prompt_payment_act', $_POST['default_prompt_payment_act']);
138
139 //---------------
140
141 table_section_title(_("Suppliers and Purchasing"));
142
143 percent_row(_("Delivery Over-Receive Allowance:"), 'po_over_receive');
144
145 percent_row(_("Invoice Over-Charge Allowance:"), 'po_over_charge');
146
147 gl_all_accounts_list_row(_("Purchases Exchange Variances Account:"), 'purch_exchange_diff_act', $_POST['purch_exchange_diff_act']);
148
149 gl_all_accounts_list_row(_("Goods Received Clearing Account:"), 'grn_act', $_POST['grn_act']);
150
151 table_section_title(_("Suppliers and Purchasing Defaults"));
152
153 gl_all_accounts_list_row(_("Accounts Payable Account:"), 'creditors_act', $_POST['creditors_act']);
154
155 gl_all_accounts_list_row(_("Purchase Discount Account:"), 'pyt_discount_act', $_POST['pyt_discount_act']);
156
157 //---------------
158
159 table_section_title(_("Inventory Defaults"));
160
161 check_row(_("Allow Negative Inventory:"), 'allow_negative_stock', null);
162
163 gl_all_accounts_list_row(_("Sales Account:"), 'default_inv_sales_act', $_POST['default_inv_sales_act']);
164
165 gl_all_accounts_list_row(_("Inventory Account:"), 'default_inventory_act', $_POST['default_inventory_act']);
166
167 gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'default_cogs_act', $_POST['default_cogs_act']);
168
169 gl_all_accounts_list_row(_("Inventory Adjustments Account:"), 'default_adj_act', $_POST['default_adj_act']);
170
171 gl_all_accounts_list_row(_("Item Assembly Costs Account:"), 'default_assembly_act', $_POST['default_assembly_act']);
172
173 //----------------
174
175 table_section_title(_("Manufacturing Defaults"));
176
177 text_row(_("Default Work Order Required By After:"), 'default_workorder_required', $_POST['default_workorder_required'], 6, 6, "", _("days"));
178
179 //----------------
180
181 table_section_title(_("Dimension Defaults"));
182
183 text_row(_("Default Dimension Required By After:"), 'default_dim_required', $_POST['default_dim_required'], 6, 6, "", _("days"));
184
185 //----------------
186
187 end_table(1);
188
189 submit_center('submit', _("Update"));
190
191 end_form(2);
192
193 //-------------------------------------------------------------------------------------------------
194
195 end_page();
196
197 ?>