+ if (!check_num('tax_last', 1))
+ {
+ display_error(_("Tax Last Periods must be positive number."));
+ set_focus('tax_last');
+ $input_error = 1;
+ }
+ if (!check_num('round_to', 1))
+ {
+ display_error(_("Round Calculated field must be a positive number."));
+ set_focus('round_to');
+ $input_error = 1;
+ }
+ if ($_POST['add_pct'] != "" && !is_numeric($_POST['add_pct']))
+ {
+ display_error(_("Add Price from Std Cost field must be number."));
+ set_focus('add_pct');
+ $input_error = 1;
+ }
+ if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
+ {
+ if ($_FILES['pic']['error'] == UPLOAD_ERR_INI_SIZE) {
+ display_error(_('The file size is over the maximum allowed.'));
+ $input_error = 1;
+ }
+ elseif ($_FILES['pic']['error'] > 0) {
+ display_error(_('Error uploading logo file.'));
+ $input_error = 1;
+ }
+ $result = $_FILES['pic']['error'];
+ $filename = company_path()."/images";
+ if (!file_exists($filename))
+ {
+ mkdir($filename);
+ }
+ $filename .= "/".clean_file_name($_FILES['pic']['name']);
+
+ //But check for the worst
+ if (!in_array( substr($filename,-4), array('.jpg','.JPG','.png','.PNG')))
+ {
+ display_error(_('Only jpg and png files are supported - a file extension of .jpg or .png is expected'));
+ $input_error = 1;
+ }
+ elseif ( $_FILES['pic']['size'] > ($SysPrefs->max_image_size * 1024))
+ { //File Size Check
+ display_error(_('The file size is over the maximum allowed. The maximum size allowed in KB is') . ' ' . $SysPrefs->max_image_size);
+ $input_error = 1;
+ }
+ elseif ( $_FILES['pic']['type'] == "text/plain" )
+ { //File type Check
+ display_error( _('Only graphics files can be uploaded'));
+ $input_error = 1;
+ }
+ elseif (file_exists($filename))
+ {
+ $result = unlink($filename);
+ if (!$result)
+ {
+ display_error(_('The existing image could not be removed'));
+ $input_error = 1;
+ }
+ }
+
+ if ($input_error != 1)
+ {
+ $result = move_uploaded_file($_FILES['pic']['tmp_name'], $filename);
+ $_POST['coy_logo'] = clean_file_name($_FILES['pic']['name']);
+ if(!$result)
+ display_error(_('Error uploading logo file'));
+ }
+ }
+ if (check_value('del_coy_logo'))
+ {
+ $filename = company_path()."/images/".clean_file_name($_POST['coy_logo']);
+ if (file_exists($filename))
+ {
+ $result = unlink($filename);
+ if (!$result)
+ {
+ display_error(_('The existing image could not be removed'));
+ $input_error = 1;
+ }
+ }
+ $_POST['coy_logo'] = "";
+ }
+ if ($_POST['add_pct'] == "")
+ $_POST['add_pct'] = -1;
+ if ($_POST['round_to'] <= 0)
+ $_POST['round_to'] = 1;