Items: fixed item tax type selector to exclude inactive item tax types.
[fa-stable.git] / taxes / db / item_tax_types_db.inc
index 7e034e4b746242bd4f3abd47bf770726128d877a..446a5dc7cb99ffe5839ccebe0f0929070206c1da 100644 (file)
@@ -42,10 +42,12 @@ function update_item_tax_type($id, $name, $exempt, $exempt_from)
        commit_transaction();   
 }
 
-function get_all_item_tax_types()
+function get_all_item_tax_types($also_inactive=false)
 {
        $sql = "SELECT * FROM ".TB_PREF."item_tax_types";
-       
+       if (!$also_inactive)
+               $sql .= " WHERE !inactive";
+
        return db_query($sql, "could not get all item tax type");
 } 
 
@@ -60,9 +62,11 @@ function get_item_tax_type($id)
 
 function get_item_tax_type_for_item($stock_id)
 {
-       $sql = "SELECT ".TB_PREF."item_tax_types.* FROM ".TB_PREF."item_tax_types,".TB_PREF."stock_master WHERE 
-               ".TB_PREF."stock_master.stock_id=".db_escape($stock_id)."
-               AND ".TB_PREF."item_tax_types.id=".TB_PREF."stock_master.tax_type_id";
+       $sql = "SELECT item_tax_type.*
+               FROM ".TB_PREF."item_tax_types item_tax_type,"
+                       .TB_PREF."stock_master item
+               WHERE item.stock_id=".db_escape($stock_id)."
+               AND item_tax_type.id=item.tax_type_id";
        
        $result = db_query($sql, "could not get item tax type");
        
@@ -106,4 +110,8 @@ function get_item_tax_type_exemptions($id)
        return db_query($sql, "could not get item tax type exemptions");
 }
 
-?>
\ No newline at end of file
+function item_type_inactive($id)
+{
+       $type = get_item_tax_type($id);
+       return @$type['inactive'];
+}