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