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 ***********************************************************************/
14 include($path_to_root . "/includes/session.inc");
16 page(_("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 //-------------------------------------------------------------------------------------------------
24 if (isset($_POST['update']) && $_POST['update'] != "")
29 if (strlen($_POST['coy_name'])==0)
32 display_error(_("The company name must be entered."));
33 set_focus('coy_name');
35 if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
37 $user_comp = user_company();
38 $result = $_FILES['pic']['error'];
39 $filename = $comp_path . "/$user_comp/images";
40 if (!file_exists($filename))
44 $filename .= "/".$_FILES['pic']['name'];
46 //But check for the worst
47 if (strtoupper(substr(trim($_FILES['pic']['name']), strlen($_FILES['pic']['name']) - 3)) != 'JPG')
49 display_error(_('Only jpg files are supported - a file extension of .jpg is expected'));
52 elseif ( $_FILES['pic']['size'] > ($max_image_size * 1024))
54 display_error(_('The file size is over the maximum allowed. The maximum size allowed in KB is') . ' ' . $max_image_size);
57 elseif ( $_FILES['pic']['type'] == "text/plain" )
59 display_error( _('Only graphics files can be uploaded'));
62 elseif (file_exists($filename))
64 $result = unlink($filename);
67 display_error(_('The existing image could not be removed'));
72 if ($input_error != 1)
74 $result = move_uploaded_file($_FILES['pic']['tmp_name'], $filename);
75 $_POST['coy_logo'] = $_FILES['pic']['name'];
77 display_error(_('Error uploading logo file'));
80 if (check_value('del_coy_logo'))
82 $user_comp = user_company();
83 $filename = $comp_path . "/$user_comp/images/".$_POST['coy_logo'];
84 if (file_exists($filename))
86 $result = unlink($filename);
89 display_error(_('The existing image could not be removed'));
93 $_POST['coy_logo'] = "";
96 if ($input_error != 1)
98 update_company_setup($_POST['coy_name'], $_POST['coy_no'],
99 $_POST['gst_no'], $_POST['tax_prd'], $_POST['tax_last'],
100 $_POST['postal_address'], $_POST['phone'], $_POST['fax'],
101 $_POST['email'], $_POST['coy_logo'], $_POST['domicile'],
102 $_POST['use_dimension'], $_POST['curr_default'], $_POST['f_year'],
103 check_value('no_item_list'), check_value('no_customer_list'),
104 check_value('no_supplier_list'), $_POST['base_sales'], check_value('time_zone'));
106 display_notification_centered(_("Company setup has been updated."));
108 set_focus('coy_name');
109 $Ajax->activate('_page_body');
110 } /* end of if submit */
112 //---------------------------------------------------------------------------------------------
117 $myrow = get_company_prefs();
119 $_POST['coy_name'] = $myrow["coy_name"];
120 $_POST['gst_no'] = $myrow["gst_no"];
121 $_POST['tax_prd'] = $myrow["tax_prd"];
122 $_POST['tax_last'] = $myrow["tax_last"];
123 $_POST['coy_no'] = $myrow["coy_no"];
124 $_POST['postal_address'] = $myrow["postal_address"];
125 $_POST['phone'] = $myrow["phone"];
126 $_POST['fax'] = $myrow["fax"];
127 $_POST['email'] = $myrow["email"];
128 $_POST['coy_logo'] = $myrow["coy_logo"];
129 $_POST['domicile'] = $myrow["domicile"];
130 $_POST['use_dimension'] = $myrow["use_dimension"];
131 $_POST['base_sales'] = $myrow["base_sales"];
132 $_POST['no_item_list'] = $myrow["no_item_list"];
133 $_POST['no_customer_list'] = $myrow["no_customer_list"];
134 $_POST['no_supplier_list'] = $myrow["no_supplier_list"];
135 $_POST['curr_default'] = $myrow["curr_default"];
136 $_POST['f_year'] = $myrow["f_year"];
137 $_POST['time_zone'] = $myrow["time_zone"];
138 $_POST['version_id'] = $myrow["version_id"];
139 $_POST['del_coy_logo'] = 0;
141 start_outer_table($table_style2);
145 text_row_ex(_("Name (to appear on reports):"), 'coy_name', 42, 50);
146 textarea_row(_("Address:"), 'postal_address', $_POST['postal_address'], 35, 6);
148 text_row_ex(_("Phone Number:"), 'phone', 25, 55);
149 text_row_ex(_("Fax Number:"), 'fax', 25);
150 email_row_ex(_("Email Address:"), 'email', 25, 55);
152 text_row_ex(_("Official Company Number:"), 'coy_no', 25);
153 text_row_ex(_("GSTNo:"), 'gst_no', 25);
155 currencies_list_row(_("Home Currency:"), 'curr_default', $_POST['curr_default']);
156 fiscalyears_list_row(_("Fiscal Year:"), 'f_year', $_POST['f_year']);
160 text_row_ex(_("Tax Periods:"), 'tax_prd', 10, 10, '', null, null, _('Months.'));
161 text_row_ex(_("Tax Last Period:"), 'tax_last', 10, 10, '', null, null, _('Months back.'));
163 label_row(_("Company Logo:"), $_POST['coy_logo']);
164 label_row(_("New Company Logo (.jpg)") . ":", "<input type='file' id='pic' name='pic'>");
165 check_row(_("Delete Company Logo:"), 'del_coy_logo', $_POST['del_coy_logo']);
166 text_row_ex(_("Domicile:"), 'domicile', 25, 55);
168 number_list_row(_("Use Dimensions:"), 'use_dimension', null, 0, 2);
169 sales_types_list_row(_("Base for auto price calculations:"), 'base_sales', $_POST['base_sales'], false,
170 _('No base price list') );
172 check_row(_("Search Item List"), 'no_item_list', $_POST['no_item_list']);
173 check_row(_("Search Customer List"), 'no_customer_list', $_POST['no_customer_list']);
174 check_row(_("Search Supplier List"), 'no_supplier_list', $_POST['no_supplier_list']);
175 label_row("", " ");
176 check_row(_("Time Zone on Reports"), 'time_zone', $_POST['time_zone']);
177 label_row(_("Version Id"), $_POST['version_id']);
181 hidden('coy_logo', $_POST['coy_logo']);
182 submit_center('update', _("Update"), true, '', 'default');
185 //-------------------------------------------------------------------------------------------------