Fixed SQL quotation.
[fa-stable.git] / inventory / includes / db / items_db.inc
index 9e2b5f2621d403b8e053e1882c7e6ca67aade877..410ed9904d972178c69820c7eb3263b89ff95d98 100644 (file)
@@ -1,17 +1,18 @@
 <?php
 /**********************************************************************
     Copyright (C) FrontAccounting, LLC.
-       Released under the terms of the GNU Affero General Public License,
-       AGPL, as published by the Free Software Foundation, either version 
-       of the License, or (at your option) any later version.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
-    See the License here <http://www.gnu.org/licenses/agpl-3.0.html>.
+    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,