+ if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
+ {
+ $result = $_FILES['pic']['error'];
+ $filename = company_path()."/images";
+ if (!file_exists($filename))
+ {
+ mkdir($filename);
+ }
+ $filename .= "/".$_FILES['pic']['name'];
+
+ //But check for the worst
+ if (!in_array((substr(trim($_FILES['pic']['name']),-3)),
+ 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'] > ($max_image_size * 1024))
+ { //File Size Check
+ display_error(_('The file size is over the maximum allowed. The maximum size allowed in KB is') . ' ' . $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'] = $_FILES['pic']['name'];
+ if(!$result)
+ display_error(_('Error uploading logo file'));
+ }
+ }
+ if (check_value('del_coy_logo'))
+ {
+ $filename = company_path()."/images/".$_POST['coy_logo'];
+ if (file_exists($filename))
+ {
+ $result = unlink($filename);
+ if (!$result)
+ {
+ display_error(_('The existing image could not be removed'));
+ $input_error = 1;
+ }
+ else
+ $_POST['coy_logo'] = "";
+ }
+ }
+ if ($_POST['add_pct'] == "")
+ $_POST['add_pct'] = -1;
+ if ($_POST['round_to'] <= 0)
+ $_POST['round_to'] = 1;