Implemented an Items tab for attachments and modified the existing setup attachments.
[fa-stable.git] / includes / db / inventory_db.inc
index 19f54f2b9802d08cafeba64bc362d9266433cad1..9032e085726120b1789505453ed142f836e5faa0 100644 (file)
@@ -93,7 +93,10 @@ function get_item_edit_info($stock_id)
                ." AND item.units=unit.abbr";
        $result = db_query($sql, "The standard cost cannot be retrieved");
 
-       return db_fetch($result);
+       $row = db_fetch($result);
+       if (is_array($row) && $row['decimals'] == -1)
+               $row['decimals'] = user_qty_dec();
+       return $row;
 }
 
 //--------------------------------------------------------------------------------------
@@ -107,7 +110,21 @@ function get_unit_cost($stock_id)
 
        $myrow = db_fetch_row($result);
 
-       return $myrow[0];
+       return is_array($myrow) ? $myrow[0] : false;
+}
+
+//--------------------------------------------------------------------------------------
+function get_purchase_cost($stock_id)
+{
+       $sql = "SELECT purchase_cost
+               FROM ".TB_PREF."stock_master
+               WHERE stock_id=".db_escape($stock_id);
+       $result = db_query($sql, "The purchase cost cannot be retrieved");
+
+       $myrow = db_fetch_row($result);
+
+       return is_array($myrow) ? $myrow[0] : false;
 }
 
 //--------------------------------------------------------------------------------------
@@ -153,7 +170,7 @@ function get_already_delivered($stock_id, $location, $trans_no)
                AND type=".ST_CUSTDELIVERY." AND trans_no=".db_escape($trans_no);
        $result = db_query($sql, "Could not get stock moves");
        $row = db_fetch_row($result);
-       return $row[0];
+       return is_array($row) ? $row[0] : false;
 }
 /*
        Returns start move_id in latest negative status period for $stock_id
@@ -317,7 +334,7 @@ function get_stock_gl_code($stock_id)
 {
        /*Gets the GL Codes relevant to the item account  */
        $sql = "SELECT mb_flag, inventory_account, cogs_account,
-               adjustment_account, sales_account, assembly_account, dimension_id, dimension2_id FROM
+               adjustment_account, sales_account, wip_account, dimension_id, dimension2_id FROM
                ".TB_PREF."stock_master WHERE stock_id = ".db_escape($stock_id);
 
        $get = db_query($sql,"retreive stock gl code");
@@ -331,7 +348,7 @@ function get_purchase_value($stock_id)
 
        $result = db_query($sql,"retreive stock purchase price");
        $row = db_fetch_row($result);
-       return $row[0];
+       return is_array($row) ? $row[0] : false;
 }
 
 function update_purchase_value($stock_id, $price)