Extended email entries.
[fa-stable.git] / admin / company_preferences.php
1 <?php
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';
13 $path_to_root = "..";
14 include($path_to_root . "/includes/session.inc");
15
16 page(_($help_context = "Company Setup"));
17
18 include_once($path_to_root . "/includes/date_functions.inc");
19 include_once($path_to_root . "/includes/ui.inc");
20
21 include_once($path_to_root . "/admin/db/company_db.inc");
22 //-------------------------------------------------------------------------------------------------
23
24 if (isset($_POST['update']) && $_POST['update'] != "")
25 {
26
27         $input_error = 0;
28
29         if (!check_num('login_tout', 10))
30         {
31                 display_error(_("Login timeout must be positive number not less than 10."));
32                 set_focus('login_tout');
33                 $input_error = 1;
34         }
35         if (strlen($_POST['coy_name'])==0)
36         {
37                 $input_error = 1;
38                 display_error(_("The company name must be entered."));
39                 set_focus('coy_name');
40         }
41         if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
42         {
43                 $result = $_FILES['pic']['error'];
44                 $filename = company_path()."/images";
45                 if (!file_exists($filename))
46                 {
47                         mkdir($filename);
48                 }
49                 $filename .= "/".clean_file_name($_FILES['pic']['name']);
50
51                  //But check for the worst
52                 if (!in_array( substr($filename,-4), array('.jpg','.JPG','.png','.PNG')))
53                 {
54                         display_error(_('Only jpg and png files are supported - a file extension of .jpg or .png is expected'));
55                         $input_error = 1;
56                 }
57                 elseif ( $_FILES['pic']['size'] > ($max_image_size * 1024))
58                 { //File Size Check
59                         display_error(_('The file size is over the maximum allowed. The maximum size allowed in KB is') . ' ' . $max_image_size);
60                         $input_error = 1;
61                 }
62                 elseif ( $_FILES['pic']['type'] == "text/plain" )
63                 {  //File type Check
64                         display_error( _('Only graphics files can be uploaded'));
65                         $input_error = 1;
66                 }
67                 elseif (file_exists($filename))
68                 {
69                         $result = unlink($filename);
70                         if (!$result)
71                         {
72                                 display_error(_('The existing image could not be removed'));
73                                 $input_error = 1;
74                         }
75                 }
76
77                 if ($input_error != 1)
78                 {
79                         $result  =  move_uploaded_file($_FILES['pic']['tmp_name'], $filename);
80                         $_POST['coy_logo'] = clean_file_name($_FILES['pic']['name']);
81                         if(!$result) 
82                                 display_error(_('Error uploading logo file'));
83                 }
84         }
85         if (check_value('del_coy_logo'))
86         {
87                 $filename = company_path()."/images/".clean_file_name($_POST['coy_logo']);
88                 if (file_exists($filename))
89                 {
90                         $result = unlink($filename);
91                         if (!$result)
92                         {
93                                 display_error(_('The existing image could not be removed'));
94                                 $input_error = 1;
95                         }
96                 }
97                 $_POST['coy_logo'] = "";
98         }
99         if ($_POST['add_pct'] == "")
100                 $_POST['add_pct'] = -1;
101         if ($_POST['round_to'] <= 0)
102                 $_POST['round_to'] = 1;
103         if ($input_error != 1)
104         {
105                 update_company_prefs(
106                         get_post( array('coy_name','coy_no','gst_no','tax_prd','tax_last',
107                                 'postal_address','phone', 'fax', 'email', 'coy_logo', 'domicile',
108                                 'use_dimension', 'curr_default', 'f_year', 
109                                 'no_item_list' => 0, 'no_customer_list' => 0, 
110                                 'no_supplier_list' =>0, 'base_sales', 
111                                 'time_zone' => 0, 'add_pct', 'round_to', 'login_tout', 'auto_curr_reval',
112                                 'bcc_email'))
113                 );
114
115                 $_SESSION['wa_current_user']->timeout = $_POST['login_tout'];
116                 display_notification_centered(_("Company setup has been updated."));
117         }
118         set_focus('coy_name');
119         $Ajax->activate('_page_body');
120 } /* end of if submit */
121
122 //---------------------------------------------------------------------------------------------
123 if (get_company_pref('bcc_email') === null) { // available from 2.3.14, can be not defined on pre-2.4 installations
124         set_company_pref('bcc_email', 'setup.company', 'varchar', 100, '');
125         refresh_sys_prefs();
126 }
127
128 start_form(true);
129 $myrow = get_company_prefs();
130
131 $_POST['coy_name'] = $myrow["coy_name"];
132 $_POST['gst_no'] = $myrow["gst_no"];
133 $_POST['tax_prd'] = $myrow["tax_prd"];
134 $_POST['tax_last'] = $myrow["tax_last"];
135 $_POST['coy_no']  = $myrow["coy_no"];
136 $_POST['postal_address']  = $myrow["postal_address"];
137 $_POST['phone']  = $myrow["phone"];
138 $_POST['fax']  = $myrow["fax"];
139 $_POST['email']  = $myrow["email"];
140 $_POST['coy_logo']  = $myrow["coy_logo"];
141 $_POST['domicile']  = $myrow["domicile"];
142 $_POST['use_dimension']  = $myrow["use_dimension"];
143 $_POST['base_sales']  = $myrow["base_sales"];
144 $_POST['no_item_list']  = $myrow["no_item_list"];
145 $_POST['no_customer_list']  = $myrow["no_customer_list"];
146 $_POST['no_supplier_list']  = $myrow["no_supplier_list"];
147 $_POST['curr_default']  = $myrow["curr_default"];
148 $_POST['f_year']  = $myrow["f_year"];
149 $_POST['time_zone']  = $myrow["time_zone"];
150 $_POST['version_id']  = $myrow["version_id"];
151 $_POST['add_pct'] = $myrow['add_pct'];
152 $_POST['login_tout'] = $myrow['login_tout'];
153 if ($_POST['add_pct'] == -1)
154         $_POST['add_pct'] = "";
155 $_POST['round_to'] = $myrow['round_to'];        
156 $_POST['auto_curr_reval'] = $myrow['auto_curr_reval'];  
157 $_POST['del_coy_logo']  = 0;
158 $_POST['bcc_email']  = $myrow["bcc_email"];
159
160 start_outer_table(TABLESTYLE2);
161
162 table_section(1);
163
164 text_row_ex(_("Name (to appear on reports):"), 'coy_name', 50, 50);
165 textarea_row(_("Address:"), 'postal_address', $_POST['postal_address'], 34, 6);
166 text_row_ex(_("Domicile:"), 'domicile', 25, 55);
167
168 text_row_ex(_("Phone Number:"), 'phone', 25, 55);
169 text_row_ex(_("Fax Number:"), 'fax', 25);
170 email_row_ex(_("Email Address:"), 'email', 50, 55);
171
172 email_row_ex(_("BCC Address for all outgoing mails:"), 'bcc_email', 50, 55);
173
174 text_row_ex(_("Official Company Number:"), 'coy_no', 25);
175 text_row_ex(_("GSTNo:"), 'gst_no', 25);
176
177 currencies_list_row(_("Home Currency:"), 'curr_default', $_POST['curr_default']);
178 fiscalyears_list_row(_("Fiscal Year:"), 'f_year', $_POST['f_year']);
179 text_row_ex(_("Tax Periods:"), 'tax_prd', 10, 10, '', null, null, _('Months.'));
180 text_row_ex(_("Tax Last Period:"), 'tax_last', 10, 10, '', null, null, _('Months back.'));
181
182 table_section(2);
183
184 label_row(_("Company Logo:"), $_POST['coy_logo']);
185 file_row(_("New Company Logo (.jpg)") . ":", 'pic', 'pic');
186 check_row(_("Delete Company Logo:"), 'del_coy_logo', $_POST['del_coy_logo']);
187
188 number_list_row(_("Use Dimensions:"), 'use_dimension', null, 0, 2);
189 sales_types_list_row(_("Base for auto price calculations:"), 'base_sales', $_POST['base_sales'], false,
190     _('No base price list') );
191 text_row_ex(_("Add Price from Std Cost:"), 'add_pct', 10, 10, '', null, null, "%");
192 $curr = get_currency($_POST['curr_default']);
193 text_row_ex(_("Round to nearest:"), 'round_to', 10, 10, '', null, null, $curr['hundreds_name']);
194 label_row("", "&nbsp;");
195
196 check_row(_("Search Item List"), 'no_item_list', null);
197 check_row(_("Search Customer List"), 'no_customer_list', null);
198 check_row(_("Search Supplier List"), 'no_supplier_list', null);
199 label_row("", "&nbsp;");
200 check_row(_("Automatic Revaluation Currency Accounts"), 'auto_curr_reval', $_POST['auto_curr_reval']);
201 check_row(_("Time Zone on Reports"), 'time_zone', $_POST['time_zone']);
202 text_row_ex(_("Login Timeout:"), 'login_tout', 10, 10, '', null, null, _('seconds'));
203 label_row(_("Version Id"), $_POST['version_id']);
204
205 end_outer_table(1);
206
207 hidden('coy_logo', $_POST['coy_logo']);
208 submit_center('update', _("Update"), true, '',  'default');
209
210 end_form(2);
211 //-------------------------------------------------------------------------------------------------
212
213 end_page();
214
215 ?>