References saved in refs table for all documents for easy access.
[fa-stable.git] / inventory / includes / db / items_codes_db.inc
index a5946c6475bc897abd9538e49e23383d936185be..d262ee7120f954ea0a09893c99243f5e2c7ee242 100644 (file)
@@ -1,4 +1,14 @@
 <?php
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       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/gpl-3.0.html>.
+***********************************************************************/
 /*
        item_codes table is used to store both multiply foreign codes and 
        sale kits definition.
@@ -15,7 +25,7 @@ function update_item_code($id, $item_code, $stock_id, $description, $category, $
                WHERE ";
                        
        if ($id == -1) // update with unknown $id i.e. from items table editor
-               "item_code = ".db_escape($item_code)
+               $sql .= "item_code = ".db_escape($item_code)
                ." AND stock_id = ".db_escape($stock_id);
        else
                $sql .= "id = $id";
@@ -35,7 +45,7 @@ function add_item_code($item_code, $stock_id, $description, $category, $qty, $fo
 
 function delete_item_code($id)
 {
-       $sql="DELETE FROM ".TB_PREF."item_codes WHERE id=$id";
+       $sql="DELETE FROM ".TB_PREF."item_codes WHERE id='$id'";
        db_query($sql,"an item code could not be deleted");
 }
 
@@ -145,8 +155,7 @@ function get_where_used($item_code)
        $sql = "SELECT item_code, description FROM "
                .TB_PREF."item_codes "
                . " WHERE stock_id='$item_code'
-                       AND item_
-                       code!='$item_code'";
+                       AND item_code!='$item_code'";
        return db_query($sql, "where used query failed");
 }
 ?>
\ No newline at end of file