Updated version for 2.3beta
[fa-stable.git] / inventory / manage / items.php
index 872dc5b9e2ed2fe605c6e38156c75db712fef92c..0793bb38a82c9d630965215d01d2ead3c770e356 100644 (file)
@@ -56,7 +56,7 @@ if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
        $stock_id = $_POST['NewStockID'];
        $result = $_FILES['pic']['error'];
        $upload_file = 'Yes'; //Assume all is well to start off with
-       $filename = $comp_path . "/$user_comp/images";
+       $filename = company_path().'/images';
        if (!file_exists($filename))
        {
                mkdir($filename);
@@ -155,7 +155,7 @@ if (isset($_POST['addupdate']))
        {
                if (check_value('del_image'))
                {
-                       $filename = $comp_path . "/$user_comp/images/".item_img_name($_POST['NewStockID']).".jpg";
+                       $filename = company_path().'/images/'.item_img_name($_POST['NewStockID']).".jpg";
                        if (file_exists($filename))
                                unlink($filename);
                }
@@ -228,7 +228,7 @@ if (isset($_POST['delete']) && strlen($_POST['delete']) > 1)
 
                $stock_id = $_POST['NewStockID'];
                delete_item($stock_id);
-               $filename = $comp_path . "/$user_comp/images/".item_img_name($stock_id).".jpg";
+               $filename = company_path().'/images/'.item_img_name($stock_id).".jpg";
                if (file_exists($filename))
                        unlink($filename);
                display_notification(_("Selected item has been deleted."));
@@ -245,7 +245,7 @@ start_form(true);
 
 if (db_has_stock_items()) 
 {
-       start_table("class='tablestyle_noborder'");
+       start_table(TABLESTYLE_NOBORDER);
        start_row();
     stock_items_list_cells(_("Select an item:"), 'stock_id', null,
          _('New item'), true, check_value('show_inactive'));
@@ -261,7 +261,7 @@ if (db_has_stock_items())
 }
 
 div_start('details');
-start_outer_table($table_style2, 5);
+start_outer_table(TABLESTYLE2);
 
 table_section(1);
 
@@ -276,6 +276,7 @@ if ($new_item)
 } 
 else 
 { // Must be modifying an existing item
+       if (!isset($_POST['NewStockID'])) {
                $_POST['NewStockID'] = $_POST['stock_id'];
 
                $myrow = get_item($_POST['NewStockID']);
@@ -298,9 +299,10 @@ else
                $_POST['del_image'] = 0;        
                $_POST['inactive'] = $myrow["inactive"];
                $_POST['editable'] = $myrow["editable"];
-               label_row(_("Item Code:"),$_POST['NewStockID']);
-               hidden('NewStockID', $_POST['NewStockID']);
-               set_focus('description');
+       }
+       label_row(_("Item Code:"),$_POST['NewStockID']);
+       hidden('NewStockID', $_POST['NewStockID']);
+       set_focus('description');
 }
 
 text_row(_("Name:"), 'description', null, 52, 50);
@@ -382,18 +384,18 @@ else
 table_section_title(_("Other"));
 
 // Add image upload for New Item  - by Joe
-label_row(_("Image File (.jpg)") . ":", "<input type='file' id='pic' name='pic'>");
+file_row(_("Image File (.jpg)") . ":", 'pic', 'pic');
 // Add Image upload for New Item  - by Joe
 $stock_img_link = "";
 $check_remove_image = false;
-if (isset($_POST['NewStockID']) && file_exists("$comp_path/$user_comp/images/"
+if (isset($_POST['NewStockID']) && file_exists(company_path().'/images/'
        .item_img_name($_POST['NewStockID']).".jpg")) 
 {
  // 31/08/08 - rand() call is necessary here to avoid caching problems. Thanks to Peter D.
        $stock_img_link .= "<img id='item_img' alt = '[".$_POST['NewStockID'].".jpg".
-               "]' src='$comp_path/$user_comp/images/".item_img_name($_POST['NewStockID']).".jpg?nocache=".rand()."'".
-               " height='$pic_height' border='0'>";
-       $check_remove_image = true;     
+               "]' src='".company_path().'images/'.item_img_name($_POST['NewStockID']).
+               ".jpg?nocache=".rand()."'"." height='$pic_height' border='0'>";
+       $check_remove_image = true;
 } 
 else 
 {