Fixed error during new category addition.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 13 May 2009 12:41:59 +0000 (12:41 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 13 May 2009 12:41:59 +0000 (12:41 +0000)
inventory/includes/db/items_category_db.inc
inventory/includes/db/items_db.inc

index 71e9af348f8d33623084f496ced914ca81cb4cd2..2d3cefd1daead70c02768a1fc51823b21bed9e30 100644 (file)
@@ -16,7 +16,7 @@ function add_item_category($description, $tax_type_id, $sales_account,
        $sql = "INSERT INTO ".TB_PREF."stock_category (description, dflt_tax_type,
                        dflt_units, dflt_mb_flag, dflt_sales_act, dflt_cogs_act, 
                        dflt_inventory_act, dflt_adjustment_act, dflt_assembly_act, 
-                       dflt_dim1, flt_dim2)
+                       dflt_dim1, dflt_dim2)
                VALUES ("
                .db_escape($description).","
                .db_escape($tax_type_id).","
index e336155254177289c0af78e8a2ac0448287beda6..dae24ac7d75ab1b7a2ffeb75adc5d0085895cff1 100644 (file)
@@ -9,9 +9,10 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
-function update_item($stock_id, $description, $long_description, $category_id, $tax_type_id,
-       $sales_account, $inventory_account, $cogs_account, $adjustment_account,
-       $assembly_account, $dimension_id, $dimension2_id)
+function update_item($stock_id, $description, $long_description, $category_id, 
+       $tax_type_id, $units='', $mb_flag='', $sales_account, $inventory_account, 
+       $cogs_account,  $adjustment_account, $assembly_account, $dimension_id, 
+       $dimension2_id)
 {
        $sql = "UPDATE ".TB_PREF."stock_master SET long_description=".db_escape($long_description).",
                description=".db_escape($description).",
@@ -23,17 +24,25 @@ function update_item($stock_id, $description, $long_description, $category_id, $
                assembly_account='$assembly_account',
                dimension_id=$dimension_id,
                dimension2_id=$dimension2_id,
-               tax_type_id=$tax_type_id
-               WHERE stock_id='$stock_id'";
+               tax_type_id=$tax_type_id";
+
+       if ($units != '')
+               $sql .= ", units=$units";
+
+       if ($mb_flag != '')
+               $sql .= ", mb_flag=$mb_flag";
+
+       $sql .= " WHERE stock_id='$stock_id'";
 
        db_query($sql, "The item could not be updated");
 
        update_item_code(-1, $stock_id, $stock_id, $description, $category_id, 1, 0);
 }
 
-function add_item($stock_id, $description, $long_description, $category_id, $tax_type_id, $units, $mb_flag,
-       $sales_account, $inventory_account, $cogs_account, $adjustment_account,
-       $assembly_account, $dimension_id, $dimension2_id)
+function add_item($stock_id, $description, $long_description, $category_id, 
+       $tax_type_id, $units, $mb_flag, $sales_account, $inventory_account, 
+       $cogs_account, $adjustment_account,     $assembly_account, $dimension_id, 
+       $dimension2_id)
 {
        $sql = "INSERT INTO ".TB_PREF."stock_master (stock_id, description, long_description, category_id,
                tax_type_id, units, mb_flag, sales_account, inventory_account, cogs_account,