Old ineffective sql_trail superseded by new improved db_trail logging only calls...
[fa-stable.git] / inventory / includes / db / items_units_db.inc
index b3df604a14c40902f1d9a9ce5bf466680e86529e..ee9f17464cfc363330d0832a6bb7a4bebc766e50 100644 (file)
@@ -11,6 +11,8 @@
 ***********************************************************************/
 function write_item_unit($selected, $abbr, $description, $decimals)
 {
+       begin_transaction(__FUNCTION__, func_get_args());
+
     if($selected!='')
                $sql = "UPDATE ".TB_PREF."item_units SET
                abbr = ".db_escape($abbr).",
@@ -23,13 +25,16 @@ function write_item_unit($selected, $abbr, $description, $decimals)
                        ".db_escape($description).", ".db_escape($decimals).")";
 
        db_query($sql,"an item unit could not be updated");
+       commit_transaction();
 }
 
 function delete_item_unit($unit)
 {
+       begin_transaction(__FUNCTION__, func_get_args());
        $sql="DELETE FROM ".TB_PREF."item_units WHERE abbr=".db_escape($unit);
 
        db_query($sql,"an unit of measure could not be deleted");
+       commit_transaction();
 }
 
 function get_item_unit($unit)
@@ -43,9 +48,9 @@ function get_item_unit($unit)
 
 function get_unit_descr($unit)
 {
-       $sql = "SELECT description FROM ".TB_PREF."item_units WHERE abbr=".db_escape($unit);
+       $sql = "SELECT name FROM ".TB_PREF."item_units WHERE abbr=".db_escape($unit);
 
-       $result = db_query($sql, "could not unit description");
+       $result = db_query($sql, "could not retrieve unit description");
 
        $row = db_fetch_row($result);
        return $row[0];
@@ -58,11 +63,13 @@ 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
+// 2008-06-15. Added 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
@@ -73,4 +80,3 @@ function get_unit_dec($stock_id)
        return $row[0];
 }
 
-?>
\ No newline at end of file