Curly braces {} in arrays replaced, by @kvvaradha.
[fa-stable.git] / taxes / db / tax_groups_db.inc
index cb411d54a7d93e12733328d2a40cd6ecc1372922..fb40bf7de1dccd349c24fd98ddd727bd682d64ed 100644 (file)
@@ -9,7 +9,7 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
-function add_tax_group($name, $taxes, $rates, $tax_shippings)
+function add_tax_group($name, $taxes, $tax_shippings)
 {
        begin_transaction();
 
@@ -18,12 +18,12 @@ function add_tax_group($name, $taxes, $rates, $tax_shippings)
        
        $id = db_insert_id();
        
-       add_tax_group_items($id, $taxes, $rates, $tax_shippings);       
+       add_tax_group_items($id, $taxes, $tax_shippings);       
        
        commit_transaction();   
 }
 
-function update_tax_group($id, $name, $taxes, $rates, $tax_shippings)
+function update_tax_group($id, $name, $taxes, $tax_shippings)
 {
        begin_transaction();    
 
@@ -31,7 +31,7 @@ function update_tax_group($id, $name, $taxes, $rates, $tax_shippings)
        db_query($sql, "could not update tax group");
        
        delete_tax_group_items($id);
-       add_tax_group_items($id, $taxes, $rates, $tax_shippings);       
+       add_tax_group_items($id, $taxes, $tax_shippings);       
        
        commit_transaction();                   
 }
@@ -66,12 +66,12 @@ function delete_tax_group($id)
        commit_transaction();
 }
 
-function add_tax_group_items($id, $items, $rates, $tax_shippings)
+function add_tax_group_items($id, $items, $tax_shippings)
 {
        for ($i=0; $i < count($items); $i++) 
        {
-               $sql = "INSERT INTO ".TB_PREF."tax_group_items (tax_group_id, tax_type_id, rate, tax_shipping)
-                       VALUES (".db_escape($id).",  ".db_escape($items[$i]).", " . $rates[$i] .", " . $tax_shippings[$i] .")";
+               $sql = "INSERT INTO ".TB_PREF."tax_group_items (tax_group_id, tax_type_id, tax_shipping)
+                       VALUES (".db_escape($id).",  ".db_escape($items[$i]).", " . $tax_shippings[$i] .")";
                db_query($sql, "could not add item tax group item");                                    
        }               
 }
@@ -89,34 +89,11 @@ function delete_tax_group_items($id)
 //
 function get_tax_group_rates($group_id=null, $tax_shipping=false)
 {
-       global $suppress_tax_rates;
-/*
-       $sql = 
-               "SELECT ";
-       if (!$group_id)
-               $sql .= "DISTINCT ";
-       $sql .= "t.id as tax_type_id,"
-               .(isset($suppress_tax_rates) && $suppress_tax_rates == 1
-                       ? "t.name as tax_type_name,"
-                       : "CONCAT(t.name, ' (', t.rate, '%)') as tax_type_name,")
-               ."t.sales_gl_code,
-                 t.purchasing_gl_code,
-                 t.rate,
-                 g.tax_shipping,
-                 g.tax_group_id
-               FROM ".TB_PREF."tax_types t, ".TB_PREF."tax_group_items g 
-                 WHERE t.id=g.tax_type_id";
-       if ($group_id)
-               $sql .= " AND g.tax_group_id=".db_escape($group_id);
-                       
-       $sql .= " AND t.inactive=0";
-       if ($tax_shipping)
-               $sql .= " AND g.tax_shipping=1";
-*/
+       global $SysPrefs;
+
        $sql = 
        "SELECT t.id as tax_type_id,"
-               .(isset($suppress_tax_rates) && $suppress_tax_rates == 1
-                       ? "t.name as tax_type_name,"
+               .($SysPrefs->suppress_tax_rates() == 1 ? "t.name as tax_type_name,"
                        : "CONCAT(t.name, ' (', t.rate, '%)') as tax_type_name,")
                ."t.sales_gl_code,
                  t.purchasing_gl_code,
@@ -148,7 +125,7 @@ function get_tax_group_items_as_array($id)
        return $ret_tax_array;
 }
 
-function get_shipping_tax_as_array($id)
+function get_shipping_tax_as_array($id=null)
 {
        $ret_tax_array = array();
 
@@ -162,4 +139,3 @@ function get_shipping_tax_as_array($id)
        
        return $ret_tax_array;
 }
-?>
\ No newline at end of file