5 include($path_to_root . "/includes/session.inc");
7 page(_("Company Setup"));
9 include_once($path_to_root . "/includes/date_functions.inc");
10 include_once($path_to_root . "/includes/ui.inc");
12 include_once($path_to_root . "/admin/db/company_db.inc");
13 //-------------------------------------------------------------------------------------------------
15 if (isset($_POST['update']) && $_POST['update'] != "")
20 if (strlen($_POST['coy_name'])==0)
23 display_error(_("The company name must be entered."));
24 set_focus('coy_name');
26 if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
28 $user_comp = user_company();
29 $result = $_FILES['pic']['error'];
30 $filename = $comp_path . "/$user_comp/images";
31 if (!file_exists($filename))
35 $filename .= "/".$_FILES['pic']['name'];
37 //But check for the worst
38 if (strtoupper(substr(trim($_FILES['pic']['name']), strlen($_FILES['pic']['name']) - 3)) != 'JPG')
40 display_notification(_('Only jpg files are supported - a file extension of .jpg is expected'));
43 elseif ( $_FILES['pic']['size'] > ($max_image_size * 1024))
45 display_notification(_('The file size is over the maximum allowed. The maximum size allowed in KB is') . ' ' . $max_image_size);
48 elseif ( $_FILES['pic']['type'] == "text/plain" )
50 display_notification( _('Only graphics files can be uploaded'));
53 elseif (file_exists($filename))
55 $result = unlink($filename);
58 display_error(_('The existing image could not be removed'));
63 if ($input_error != 1)
65 $result = move_uploaded_file($_FILES['pic']['tmp_name'], $filename);
66 $_POST['coy_logo'] = $_FILES['pic']['name'];
68 display_error(_('Error uploading logo file'));
71 if ($input_error != 1)
73 update_company_setup($_POST['coy_name'], $_POST['coy_no'], $_POST['gst_no'], $_POST['tax_prd'], $_POST['tax_last'],
74 $_POST['postal_address'], $_POST['phone'], $_POST['fax'], $_POST['email'], $_POST['coy_logo'], $_POST['domicile'],
75 $_POST['use_dimension'], $_POST['custom1_name'], $_POST['custom2_name'], $_POST['custom3_name'],
76 $_POST['custom1_value'], $_POST['custom2_value'], $_POST['custom3_value'],
77 $_POST['curr_default'], $_POST['f_year'], check_value('no_item_list'), check_value('no_customer_list'),
78 check_value('no_supplier_list'), $_POST['base_sales']);
80 display_notification_centered(_("Company setup has been updated."));
82 set_focus('coy_name');
83 $Ajax->activate('_page_body');
84 } /* end of if submit */
86 //---------------------------------------------------------------------------------------------
91 $myrow = get_company_prefs();
93 $_POST['coy_name'] = $myrow["coy_name"];
94 $_POST['gst_no'] = $myrow["gst_no"];
95 $_POST['tax_prd'] = $myrow["tax_prd"];
96 $_POST['tax_last'] = $myrow["tax_last"];
97 $_POST['coy_no'] = $myrow["coy_no"];
98 $_POST['postal_address'] = $myrow["postal_address"];
99 $_POST['phone'] = $myrow["phone"];
100 $_POST['fax'] = $myrow["fax"];
101 $_POST['email'] = $myrow["email"];
102 $_POST['coy_logo'] = $myrow["coy_logo"];
103 $_POST['domicile'] = $myrow["domicile"];
104 $_POST['use_dimension'] = $myrow["use_dimension"];
105 $_POST['base_sales'] = $myrow["base_sales"];
106 $_POST['no_item_list'] = $myrow["no_item_list"];
107 $_POST['no_customer_list'] = $myrow["no_customer_list"];
108 $_POST['no_supplier_list'] = $myrow["no_supplier_list"];
109 $_POST['custom1_name'] = $myrow["custom1_name"];
110 $_POST['custom2_name'] = $myrow["custom2_name"];
111 $_POST['custom3_name'] = $myrow["custom3_name"];
112 $_POST['custom1_value'] = $myrow["custom1_value"];
113 $_POST['custom2_value'] = $myrow["custom2_value"];
114 $_POST['custom3_value'] = $myrow["custom3_value"];
115 $_POST['curr_default'] = $myrow["curr_default"];
116 $_POST['f_year'] = $myrow["f_year"];
118 start_table($table_style2);
120 text_row_ex(_("Name (to appear on reports):"), 'coy_name', 42, 50);
121 text_row_ex(_("Official Company Number:"), 'coy_no', 25);
122 text_row_ex(_("Tax Authority Reference:"), 'gst_no', 25);
124 text_row_ex(_("Tax Periods:"), 'tax_prd', 10, 10, '', null, null, _('Months.'));
125 text_row_ex(_("Tax Last Period:"), 'tax_last', 10, 10, '', null, null, _('Months back.'));
127 currencies_list_row(_("Home Currency:"), 'curr_default', $_POST['curr_default']);
128 fiscalyears_list_row(_("Fiscal Year:"), 'f_year', $_POST['f_year']);
130 textarea_row(_("Address:"), 'postal_address', $_POST['postal_address'], 35, 5);
132 text_row_ex(_("Telephone Number:"), 'phone', 25, 55);
133 text_row_ex(_("Facsimile Number:"), 'fax', 25);
134 text_row_ex(_("Email Address:"), 'email', 25, 55);
135 label_row(_("Company Logo:"), $_POST['coy_logo']);
136 label_row(_("New Company Logo (.jpg)") . ":", "<input type='file' id='pic' name='pic'>");
138 text_row_ex(_("Domicile:"), 'domicile', 25, 55);
140 number_list_row(_("Use Dimensions:"), 'use_dimension', null, 0, 2);
141 sales_types_list_row(_("Base for auto price calculations:"), 'base_sales', $_POST['base_sales'], false,
142 _('No base price list') );
144 check_row(_("Search Item List"), 'no_item_list', $_POST['no_item_list']);
145 check_row(_("Search Customer List"), 'no_customer_list', $_POST['no_customer_list']);
146 check_row(_("Search Supplier List"), 'no_supplier_list', $_POST['no_supplier_list']);
150 label_row(_("Custom Field Name"), _("Custom Field Value"));
153 text_cells(null, 'custom1_name', $_POST['custom1_name'], 25, 25);
154 text_cells(null, 'custom1_value', $_POST['custom1_value'], 30, 30);
158 text_cells(null, 'custom2_name', $_POST['custom2_name'], 25, 25);
159 text_cells(null, 'custom2_value', $_POST['custom2_value'], 30, 30);
163 text_cells(null, 'custom3_name', $_POST['custom3_name'], 25, 25);
164 text_cells(null, 'custom3_value', $_POST['custom3_value'], 30, 30);
168 hidden('coy_logo', $_POST['coy_logo']);
169 submit_center('update', _("Update"), true, '', true);
172 //-------------------------------------------------------------------------------------------------