{
if($selected!='')
$sql = "UPDATE ".TB_PREF."item_units SET
- abbr = ".db_quote($abbr).",
- name = ".db_quote($description).",
+ abbr = ".db_escape($abbr).",
+ name = ".db_escape($description).",
decimals = $decimals
WHERE abbr = '$selected'";
else
$sql = "INSERT INTO ".TB_PREF."item_units
- (abbr, name, decimals) VALUES( ".db_quote($abbr).",
- ".db_quote($description).", $decimals)";
+ (abbr, name, decimals) VALUES( ".db_escape($abbr).",
+ ".db_escape($description).", $decimals)";
db_query($sql,"an item unit could not be updated");
}
$sql = "SELECT * FROM ".TB_PREF."item_units ORDER BY name";
return db_query($sql, "could not get stock categories");
}
+// 2008-06-15. Added Joe Hunt to get a measure of unit by given stock_id
+function get_unit_dec($stock_id)
+{
+ $sql = "SELECT decimals FROM ".TB_PREF."item_units, ".TB_PREF."stock_master
+ WHERE abbr=units AND stock_id='$stock_id' LIMIT 1";
+ $result = db_query($sql, "could not get unit decimals");
+
+ $row = db_fetch_row($result);
+ return $row[0];
+}
+
?>
\ No newline at end of file