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