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_SETUPCOMPANY';
14 include($path_to_root . "/includes/session.inc");
16 page(_($help_context = "Company Setup"));
18 include_once($path_to_root . "/includes/date_functions.inc");
19 include_once($path_to_root . "/includes/ui.inc");
21 include_once($path_to_root . "/admin/db/company_db.inc");
22 include_once($path_to_root . "/reporting/includes/tcpdf.php");
23 //-------------------------------------------------------------------------------------------------
25 if (isset($_POST['update']) && $_POST['update'] != "")
29 if (!check_num('login_tout', 10))
31 display_error(_("Login timeout must be positive number not less than 10."));
32 set_focus('login_tout');
35 if (strlen($_POST['coy_name'])==0)
38 display_error(_("The company name must be entered."));
39 set_focus('coy_name');
41 if (!check_num('tax_prd', 1))
43 display_error(_("Tax Periods must be positive number."));
47 if (!check_num('tax_last', 1))
49 display_error(_("Tax Last Periods must be positive number."));
50 set_focus('tax_last');
53 if (!check_num('round_to', 1))
55 display_error(_("Round Calculated field must be a positive number."));
56 set_focus('round_to');
59 if (!check_num('max_days_in_docs', 1))
61 display_error(_("Max day range in Documents must be a positive number."));
62 set_focus('max_days_in_docs');
65 if ($_POST['add_pct'] != "" && !is_numeric($_POST['add_pct']))
67 display_error(_("Add Price from Std Cost field must be number."));
71 if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
73 if ($_FILES['pic']['error'] == UPLOAD_ERR_INI_SIZE) {
74 display_error(_('The file size is over the maximum allowed.'));
77 elseif ($_FILES['pic']['error'] > 0) {
78 display_error(_('Error uploading logo file.'));
81 $result = $_FILES['pic']['error'];
82 $filename = company_path()."/images";
83 if (!file_exists($filename))
87 $filename .= "/".clean_file_name($_FILES['pic']['name']);
89 //But check for the worst
90 if (!in_array( substr($filename,-4), array('.jpg','.JPG','.png','.PNG')))
92 display_error(_('Only jpg and png files are supported - a file extension of .jpg or .png is expected'));
95 elseif ( $_FILES['pic']['size'] > ($SysPrefs->max_image_size * 1024))
97 display_error(_('The file size is over the maximum allowed. The maximum size allowed in KB is') . ' ' . $SysPrefs->max_image_size);
100 elseif ( $_FILES['pic']['type'] == "text/plain" )
102 display_error( _('Only graphics files can be uploaded'));
105 elseif (file_exists($filename))
107 $result = unlink($filename);
110 display_error(_('The existing image could not be removed'));
115 if ($input_error != 1) {
116 $result = move_uploaded_file($_FILES['pic']['tmp_name'], $filename);
117 $_POST['coy_logo'] = clean_file_name($_FILES['pic']['name']);
119 display_error(_('Error uploading logo file'));
122 $msg = check_image_file($filename);
124 display_error( $msg);
131 if (check_value('del_coy_logo'))
133 $filename = company_path()."/images/".clean_file_name($_POST['coy_logo']);
134 if (file_exists($filename))
136 $result = unlink($filename);
139 display_error(_('The existing image could not be removed'));
143 $_POST['coy_logo'] = "";
145 if ($_POST['add_pct'] == "")
146 $_POST['add_pct'] = -1;
147 if ($_POST['round_to'] <= 0)
148 $_POST['round_to'] = 1;
149 if ($input_error != 1)
151 update_company_prefs(
152 get_post( array('coy_name','coy_no','gst_no','tax_prd','tax_last',
153 'postal_address','phone', 'fax', 'email', 'coy_logo', 'domicile',
154 'use_dimension', 'curr_default', 'f_year', 'shortname_name_in_list',
155 'no_item_list' => 0, 'no_customer_list' => 0, 'no_supplier_list' => 0,
156 'base_sales', 'ref_no_auto_increase' => 0, 'dim_on_recurrent_invoice' => 0, 'long_description_invoice' => 0, 'max_days_in_docs' => 180, 'company_logo_on_views' => 0,
157 'time_zone' => 0, 'company_logo_report' => 0, 'barcodes_on_stock' => 0, 'print_dialog_direct' => 0,
158 'add_pct', 'round_to', 'login_tout', 'auto_curr_reval', 'bcc_email', 'alternative_tax_include_on_docs',
159 'suppress_tax_rates', 'use_manufacturing', 'use_fixed_assets'))
162 $_SESSION['wa_current_user']->timeout = $_POST['login_tout'];
163 display_notification_centered(_("Company setup has been updated."));
164 set_focus('coy_name');
165 $Ajax->activate('_page_body');
167 } /* end of if submit */
171 $myrow = get_company_prefs();
173 $_POST['coy_name'] = $myrow["coy_name"];
174 $_POST['gst_no'] = $myrow["gst_no"];
175 $_POST['tax_prd'] = $myrow["tax_prd"];
176 $_POST['tax_last'] = $myrow["tax_last"];
177 $_POST['coy_no'] = $myrow["coy_no"];
178 $_POST['postal_address'] = $myrow["postal_address"];
179 $_POST['phone'] = $myrow["phone"];
180 $_POST['fax'] = $myrow["fax"];
181 $_POST['email'] = $myrow["email"];
182 $_POST['coy_logo'] = $myrow["coy_logo"];
183 $_POST['domicile'] = $myrow["domicile"];
184 $_POST['use_dimension'] = $myrow["use_dimension"];
185 $_POST['base_sales'] = $myrow["base_sales"];
186 if (!isset($myrow["shortname_name_in_list"]))
188 set_company_pref("shortname_name_in_list", "setup.company", "tinyint", 1, '0');
189 $myrow["shortname_name_in_list"] = get_company_pref("shortname_name_in_list");
191 $_POST['shortname_name_in_list'] = $myrow["shortname_name_in_list"];
192 $_POST['no_item_list'] = $myrow["no_item_list"];
193 $_POST['no_customer_list'] = $myrow["no_customer_list"];
194 $_POST['no_supplier_list'] = $myrow["no_supplier_list"];
195 $_POST['curr_default'] = $myrow["curr_default"];
196 $_POST['f_year'] = $myrow["f_year"];
197 $_POST['time_zone'] = $myrow["time_zone"];
198 if (!isset($myrow["max_days_in_docs"]))
200 set_company_pref("max_days_in_docs", "setup.company", "smallint", 5, '180');
201 $myrow["max_days_in_docs"] = get_company_pref("max_days_in_docs");
203 $_POST['max_days_in_docs'] = $myrow["max_days_in_docs"];
204 if (!isset($myrow["company_logo_report"]))
206 set_company_pref("company_logo_report", "setup.company", "tinyint", 1, '0');
207 $myrow["company_logo_report"] = get_company_pref("company_logo_report");
209 $_POST['company_logo_report'] = $myrow["company_logo_report"];
210 if (!isset($myrow["ref_no_auto_increase"]))
212 set_company_pref("ref_no_auto_increase", "setup.company", "tinyint", 1, '0');
213 $myrow["ref_no_auto_increase"] = get_company_pref("ref_no_auto_increase");
215 $_POST['ref_no_auto_increase'] = $myrow["ref_no_auto_increase"];
216 if (!isset($myrow["barcodes_on_stock"]))
218 set_company_pref("barcodes_on_stock", "setup.company", "tinyint", 1, '0');
219 $myrow["barcodes_on_stock"] = get_company_pref("barcodes_on_stock");
221 $_POST['barcodes_on_stock'] = $myrow["barcodes_on_stock"];
222 if (!isset($myrow["print_dialog_direct"]))
224 set_company_pref("print_dialog_direct", "setup.company", "tinyint", 1, '0');
225 $myrow["print_dialog_direct"] = get_company_pref("print_dialog_direct");
227 $_POST['print_dialog_direct'] = $myrow["print_dialog_direct"];
228 if (!isset($myrow["dim_on_recurrent_invoice"]))
230 set_company_pref("dim_on_recurrent_invoice", "setup.company", "tinyint", 1, '0');
231 $myrow["dim_on_recurrent_invoice"] = get_company_pref("dim_on_recurrent_invoice");
233 $_POST['dim_on_recurrent_invoice'] = $myrow["dim_on_recurrent_invoice"];
234 if (!isset($myrow["long_description_invoice"]))
236 set_company_pref("long_description_invoice", "setup.company", "tinyint", 1, '0');
237 $myrow["long_description_invoice"] = get_company_pref("long_description_invoice");
239 $_POST['long_description_invoice'] = $myrow["long_description_invoice"];
240 if (!isset($myrow["company_logo_on_views"]))
242 set_company_pref("company_logo_on_views", "setup.company", "tinyint", 1, '0');
243 $myrow["company_logo_on_views"] = get_company_pref("company_logo_on_views");
245 $_POST['company_logo_on_views'] = $myrow["company_logo_on_views"];
246 $_POST['version_id'] = $myrow["version_id"];
247 $_POST['add_pct'] = $myrow['add_pct'];
248 $_POST['login_tout'] = $myrow['login_tout'];
249 if ($_POST['add_pct'] == -1)
250 $_POST['add_pct'] = "";
251 $_POST['round_to'] = $myrow['round_to'];
252 $_POST['auto_curr_reval'] = $myrow['auto_curr_reval'];
253 $_POST['del_coy_logo'] = 0;
254 $_POST['bcc_email'] = $myrow["bcc_email"];
255 $_POST['alternative_tax_include_on_docs'] = $myrow["alternative_tax_include_on_docs"];
256 $_POST['suppress_tax_rates'] = $myrow["suppress_tax_rates"];
257 $_POST['use_manufacturing'] = $myrow["use_manufacturing"];
258 $_POST['use_fixed_assets'] = $myrow["use_fixed_assets"];
260 start_outer_table(TABLESTYLE2);
263 table_section_title(_("General settings"));
265 text_row_ex(_("Name (to appear on reports):"), 'coy_name', 50, 50);
266 textarea_row(_("Address:"), 'postal_address', $_POST['postal_address'], 34, 5);
267 text_row_ex(_("Domicile:"), 'domicile', 25, 55);
269 text_row_ex(_("Phone Number:"), 'phone', 25, 55);
270 text_row_ex(_("Fax Number:"), 'fax', 25);
271 email_row_ex(_("Email Address:"), 'email', 50, 55);
273 email_row_ex(_("BCC Address for all outgoing mails:"), 'bcc_email', 50, 55);
275 text_row_ex(_("Official Company Number:"), 'coy_no', 25);
276 text_row_ex(_("GSTNo:"), 'gst_no', 25);
277 currencies_list_row(_("Home Currency:"), 'curr_default', $_POST['curr_default']);
279 label_row(_("Company Logo:"), $_POST['coy_logo']);
280 file_row(_("New Company Logo (.jpg)") . ":", 'pic', 'pic');
281 check_row(_("Delete Company Logo:"), 'del_coy_logo', $_POST['del_coy_logo']);
283 check_row(_("Time Zone on Reports"), 'time_zone', $_POST['time_zone']);
284 check_row(_("Company Logo on Reports"), 'company_logo_report', $_POST['company_logo_report']);
285 check_row(_("Use Barcodes on Stocks"), 'barcodes_on_stock', $_POST['barcodes_on_stock']);
286 check_row(_("Auto Increase of Document References"), 'ref_no_auto_increase', $_POST['ref_no_auto_increase']);
287 check_row(_("Use Dimensions on Recurrent Invoices"), 'dim_on_recurrent_invoice', $_POST['dim_on_recurrent_invoice']);
288 check_row(_("Use Long Descriptions on Invoices"), 'long_description_invoice', $_POST['long_description_invoice']);
289 check_row(_("Company Logo on Views"), 'company_logo_on_views', $_POST['company_logo_on_views']);
290 label_row(_("Database Scheme Version"), $_POST['version_id']);
294 table_section_title(_("General Ledger Settings"));
295 fiscalyears_list_row(_("Fiscal Year:"), 'f_year', $_POST['f_year']);
296 text_row_ex(_("Tax Periods:"), 'tax_prd', 10, 10, '', null, null, _('Months.'));
297 text_row_ex(_("Tax Last Period:"), 'tax_last', 10, 10, '', null, null, _('Months back.'));
298 check_row(_("Put alternative Tax Include on Docs"), 'alternative_tax_include_on_docs', null);
299 check_row(_("Suppress Tax Rates on Docs"), 'suppress_tax_rates', null);
300 check_row(_("Automatic Revaluation Currency Accounts"), 'auto_curr_reval', $_POST['auto_curr_reval']);
302 table_section_title(_("Sales Pricing"));
303 sales_types_list_row(_("Base for auto price calculations:"), 'base_sales', $_POST['base_sales'], false,
304 _('No base price list') );
306 text_row_ex(_("Add Price from Std Cost:"), 'add_pct', 10, 10, '', null, null, "%");
307 $curr = get_currency($_POST['curr_default']);
308 text_row_ex(_("Round calculated prices to nearest:"), 'round_to', 10, 10, '', null, null, $curr['hundreds_name']);
309 label_row("", " ");
312 table_section_title(_("Optional Modules"));
313 check_row(_("Manufacturing"), 'use_manufacturing', null);
314 check_row(_("Fixed Assets"), 'use_fixed_assets', null);
315 number_list_row(_("Use Dimensions:"), 'use_dimension', null, 0, 2);
317 table_section_title(_("User Interface Options"));
319 check_row(_("Short Name and Name in List"), 'shortname_name_in_list', $_POST['shortname_name_in_list']);
320 check_row(_("Open Print Dialog Direct on Reports"), 'print_dialog_direct', null);
321 check_row(_("Search Item List"), 'no_item_list', null);
322 check_row(_("Search Customer List"), 'no_customer_list', null);
323 check_row(_("Search Supplier List"), 'no_supplier_list', null);
324 text_row_ex(_("Login Timeout:"), 'login_tout', 10, 10, '', null, null, _('seconds'));
325 text_row_ex(_("Max day range in documents"), 'max_days_in_docs', 10, 10, '', null, null, _('days.'));
329 hidden('coy_logo', $_POST['coy_logo']);
330 submit_center('update', _("Update"), true, '', 'default');
333 //-------------------------------------------------------------------------------------------------