X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=inventory%2Fincludes%2Fdb%2Fitems_units_db.inc;h=b5c98d9118f7afd5f39d2fcc0f9754618e16a9ed;hb=3ff9ed87cb909f19c8fe3e7dfda5df79d0c01a6c;hp=f755fed51bebde3fc9b152d4abc4862078a2809b;hpb=512f9dbe2a3dc1282358c6641ebd715e1bae5136;p=fa-stable.git diff --git a/inventory/includes/db/items_units_db.inc b/inventory/includes/db/items_units_db.inc index f755fed5..b5c98d91 100644 --- a/inventory/includes/db/items_units_db.inc +++ b/inventory/includes/db/items_units_db.inc @@ -1,43 +1,52 @@ . +***********************************************************************/ function write_item_unit($selected, $abbr, $description, $decimals) { if($selected!='') $sql = "UPDATE ".TB_PREF."item_units SET - abbr = '$abbr', - name = '$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( '$abbr', - '$description', $decimals)"; - - db_query($sql,"an item unit could not be updated"); + (abbr, name, decimals) VALUES( ".db_escape($abbr).", + ".db_escape($description).", $decimals)"; + + db_query($sql,"an item unit could not be updated"); } function delete_item_unit($unit) { - $sql="DELETE FROM ".TB_PREF."item_units WHERE abbr='$unit'"; - - db_query($sql,"an unit of measure could not be deleted"); + $sql="DELETE FROM ".TB_PREF."item_units WHERE abbr='$unit'"; + + db_query($sql,"an unit of measure could not be deleted"); } function get_item_unit($unit) { - $sql="SELECT * FROM ".TB_PREF."item_units WHERE abbr='$unit'"; - + $sql="SELECT * FROM ".TB_PREF."item_units WHERE abbr='$unit'"; + $result = db_query($sql,"an unit of measure could not be retrieved"); - - return db_fetch($result); + + return db_fetch($result); } function get_unit_descr($unit) { - $sql = "SELECT description FROM ".TB_PREF."item_units WHERE abbr='$id'"; - + $sql = "SELECT description FROM ".TB_PREF."item_units WHERE abbr='$unit'"; + $result = db_query($sql, "could not unit description"); - + $row = db_fetch_row($result); return $row[0]; } @@ -49,8 +58,21 @@ function item_unit_used($unit) { return ($myrow[0] > 0); } -function get_all_item_units() { - $sql = "SELECT * FROM ".TB_PREF."item_units ORDER BY name"; +function get_all_item_units($all=false) { + $sql = "SELECT * FROM ".TB_PREF."item_units"; + if (!$all) $sql .= " WHERE !inactive"; + $sql .= " 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