3 function add_tax_group($name, $tax_shipping, $taxes, $rates, $included)
7 $sql = "INSERT INTO ".TB_PREF."tax_groups (name, tax_shipping) VALUES ('$name', $tax_shipping)";
8 db_query($sql, "could not add tax group");
12 add_tax_group_items($id, $taxes, $rates, $included);
17 function update_tax_group($id, $name, $tax_shipping, $taxes, $rates, $included)
21 $sql = "UPDATE ".TB_PREF."tax_groups SET name='$name',tax_shipping=$tax_shipping WHERE id=$id";
23 db_query($sql, "could not update tax group");
25 delete_tax_group_items($id);
26 add_tax_group_items($id, $taxes, $rates, $included);
31 function get_all_tax_groups()
33 $sql = "SELECT * FROM ".TB_PREF."tax_groups";
35 return db_query($sql, "could not get all tax group");
38 function get_tax_group($type_id)
40 $sql = "SELECT * FROM ".TB_PREF."tax_groups WHERE id=$type_id";
42 $result = db_query($sql, "could not get tax group");
44 return db_fetch($result);
47 function delete_tax_group($id)
51 $sql = "DELETE FROM ".TB_PREF."tax_groups WHERE id=$id";
53 db_query($sql, "could not delete tax group");
55 delete_tax_group_items($id);
60 function add_tax_group_items($id, $items, $rates, $included)
62 for ($i=0; $i < count($items); $i++)
64 $sql = "INSERT INTO ".TB_PREF."tax_group_items (tax_group_id, tax_type_id, rate, included_in_price)
65 VALUES ($id, " . $items[$i] . ", " . $rates[$i] . ", " . $included[$i] .")";
66 db_query($sql, "could not add item tax group item");
70 function delete_tax_group_items($id)
72 $sql = "DELETE FROM ".TB_PREF."tax_group_items WHERE tax_group_id=$id";
74 db_query($sql, "could not delete item tax group items");
77 function get_tax_group_items($id)
79 $sql = "SELECT ".TB_PREF."tax_group_items.*, ".TB_PREF."tax_types.name AS tax_type_name,
80 ".TB_PREF."tax_types.sales_gl_code, ".TB_PREF."tax_types.purchasing_gl_code
81 FROM ".TB_PREF."tax_group_items, ".TB_PREF."tax_types
82 WHERE tax_group_id=$id
83 AND ".TB_PREF."tax_types.id=tax_type_id";
85 return db_query($sql, "could not get item tax type group items");
88 function get_tax_group_items_as_array($id)
90 $ret_tax_array = array();
92 $tax_group_items = get_tax_group_items($id);
94 while ($tax_group_item = db_fetch($tax_group_items))
96 $index = $tax_group_item['tax_type_id'];
97 $ret_tax_array[$index]['tax_type_id'] = $tax_group_item['tax_type_id'];
98 $ret_tax_array[$index]['tax_type_name'] = $tax_group_item['tax_type_name'];
99 $ret_tax_array[$index]['sales_gl_code'] = $tax_group_item['sales_gl_code'];
100 $ret_tax_array[$index]['purchasing_gl_code'] = $tax_group_item['purchasing_gl_code'];
101 $ret_tax_array[$index]['rate'] = $tax_group_item['rate'];
102 $ret_tax_array[$index]['included_in_price'] = $tax_group_item['included_in_price'];
103 $ret_tax_array[$index]['Value'] = 0;
106 return $ret_tax_array;