Fixed stock item image upload bug.
[fa-stable.git] / inventory / manage / items.php
index 486a3d16fd54306922f2a3b0fd695b8808f55544..967cb5e67ec56c400d1e09274d835818c7b05b9e 100644 (file)
@@ -39,12 +39,12 @@ if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
 {
        $result = $_FILES['pic']['error'];
        $upload_file = 'Yes'; //Assume all is well to start off with
-       $filename = $path_to_root . "/inventory/manage/image/$user_comp/";
+       $filename = $comp_path . "/$user_comp/images";
        if (!file_exists($filename))
        {
                mkdir($filename);
        }       
-       $filename .= "$stock_id.jpg";
+       $filename .= "/$stock_id.jpg";
        
         //But check for the worst 
        if (strtoupper(substr(trim($_FILES['pic']['name']), strlen($_FILES['pic']['name']) - 3)) != 'JPG')
@@ -112,11 +112,13 @@ if (isset($_POST['addupdate']))
        {
                $input_error = 1;
                display_error( _('The item name must be entered.'));
+               set_focus('description');
        } 
        elseif (strlen($_POST['NewStockID']) == 0) 
        {
                $input_error = 1;
                display_error( _('The item code cannot be empty'));
+               set_focus('NewStockID');
        }
        elseif (strstr($_POST['NewStockID'], " ") || strstr($_POST['NewStockID'],"'") || 
                strstr($_POST['NewStockID'], "+") || strstr($_POST['NewStockID'], "\"") || 
@@ -124,6 +126,7 @@ if (isset($_POST['addupdate']))
        {
                $input_error = 1;
                display_error( _('The item code cannot contain any of the following characters -  & + OR a space OR quotes'));
+               set_focus('NewStockID');
 
        }
 
@@ -206,7 +209,7 @@ if (isset($_POST['delete']) && strlen($_POST['delete']) > 1)
 
                $stock_id = $_POST['NewStockID'];
                delete_item($stock_id);
-               $filename = $path_to_root . "/inventory/manage/image/$user_comp/$stock_id.jpg";
+               $filename = $comp_path . "/$user_comp/images/$stock_id.jpg";
                if (file_exists($filename))
                        unlink($filename);
                meta_forward($_SERVER['PHP_SELF']);
@@ -300,9 +303,9 @@ start_table("$table_style2 width=40%");
 start_row();
 label_cells(_("Image File (.jpg)") . ":", "<input type='file' id='pic' name='pic'>");
 // Add Image upload for New Item  - by Joe
-if (isset($_POST['NewStockID']) && file_exists("$path_to_root/inventory/manage/image/$user_comp/".$_POST['NewStockID'].".jpg")) 
+if (isset($_POST['NewStockID']) && file_exists("$comp_path/$user_comp/images/".$_POST['NewStockID'].".jpg")) 
 {
-       $stock_img_link = "<img src='$path_to_root/inventory/manage/image/$user_comp/".$_POST['NewStockID'].".jpg' width='$pic_width' height='$pic_height' border='0'>";
+       $stock_img_link = "<img src='$comp_path/$user_comp/images/".$_POST['NewStockID'].".jpg' width='$pic_width' height='$pic_height' border='0'>";
 } 
 else 
 {