clearCache(); $config = fetchDbConfig("config"); $msg = writeDbConf($_POST['config'],"config", $config, "config"); } $config = fetchDbConfig("config"); // start: Flexible Taxes, by Estelle Winterflood function selected($var,$val){ if ($var==$val){ echo "selected"; } } $config_tax_mod = fetchDbConfig("Multiple_Tax_Mod"); if (!$config_tax_mod){ $cache = new cache(); $cache->clearCache(); // setup default values for initial install $config_tax_mod['status']=0; $config_tax_mod['debug']=0; writeDbConf($config_tax_mod, "Multiple_Tax_Mod", $config_tax_mod); } // end: Flexible Taxes if(isset($_POST['taxId'])){ $cache = new cache(); $cache->clearCache(); $record["taxName"] = $db->mySQLSafe($_POST['taxName']); $record["percent"] = $db->mySQLSafe($_POST['percent']); if($_POST['taxId']>0){ $where = "id = ".$db->mySQLSafe($_POST['taxId']); $update =$db->update($glob['dbprefix']."CubeCart_taxes", $record, $where); if($update){ $msgTaxType = "
'".$_POST['taxName']."' ".$lang['admin']['settings_update_success']."
"; } else { $msgTaxType = "'".$_POST['taxName']."' ".$lang['admin']['settings_update_fail']."
"; } } else { $insert =$db->insert($glob['dbprefix']."CubeCart_taxes", $record); if($insert){ $msgTaxType = "'".$_POST['taxName']."' ".$lang['admin']['settings_add_success']."
"; } else { $msgTaxType = "'".$_POST['taxName']."' ".$lang['admin']['settings_add_fail']."
"; } } } elseif(isset($_GET['delete'])) { $cache = new cache(); $cache->clearCache(); $where = "id = ".$db->mySQLSafe($_GET['delete']); $delete = $db->delete($glob['dbprefix']."CubeCart_taxes", $where, ""); if($delete == TRUE) { $msgTaxType = "".$lang['admin']['settings_delete_success']."
"; } else { $msgTaxType = "".$lang['admin']['settings_delete_failed']."
"; } } // start: Flexible Taxes, by Estelle Winterflood // Config elseif(isset($_POST['config_tax_mod'])) { $cache = new cache(); $cache->clearCache(); $msg = writeDbConf($_POST['config_tax_mod'], "Multiple_Tax_Mod", $config_tax_mod); $config_tax_mod = $_POST['config_tax_mod']; } // Update Tax Details elseif(isset($_POST['details'])) { $cache = new cache(); $cache->clearCache(); $detailsArray = $_POST['details']; $update = 0; $error = 0; foreach ($detailsArray as $details) { $record["name"] = $db->mySQLSafe($details['name']); $record["display"] = $db->mySQLSafe($details['display']); $record["reg_number"] = $db->mySQLSafe($details['reg_number']); $record["status"] = $db->mySQLSafe($details['status']); $where = "id = ".$db->mySQLSafe($details['id']); $check = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_tax_details WHERE name=".$record['name']." AND id<>".$db->mySQLSafe($details['id'])); if ($check) { $error++; } else { $res = $db->update($glob['dbprefix']."CubeCart_tax_details", $record, $where); if ($res) { $update++; } } } $msgTaxType = ""; if($update) { $msgTaxType = "".$update." ".$lang['admin']['settings_tax_details_upd_success']."
"; } elseif (!$error) { $msgTaxType = "".$lang['admin']['settings_tax_details_upd_failure']."
"; } if ($error) { $msgTaxType .= "".$error." ".$lang['admin']['settings_tax_details_upd_error']."
"; } } // Add Tax Details elseif(isset($_POST['new_details'])) { $cache = new cache(); $cache->clearCache(); $details = $_POST['new_details']; $record["name"] = $db->mySQLSafe($details['name']); $record["display"] = $db->mySQLSafe($details['display']); $record["reg_number"] = $db->mySQLSafe($details['reg_number']); $record["status"] = $db->mySQLSafe($details['status']); $check = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_tax_details WHERE name=".$record['name']); if($check) { $insert = false; } else { $insert = $db->insert($glob['dbprefix']."CubeCart_tax_details", $record); } if($insert) { $msgTaxType = "'".$details['name']."' ".$lang['admin']['settings_add_success']."
"; } else { $msgTaxType = "'".$details['name']."' ".$lang['admin']['settings_add_fail']."
"; } } // Delete Tax Details elseif(isset($_GET['delete_details'])) { $where = "id = ".$db->mySQLSafe($_GET['delete_details']); $delete = $db->delete($glob['dbprefix']."CubeCart_tax_details", $where, ""); if($delete){ $msgTaxType = "".$lang['admin']['settings_tax_details_del_success']."
"; } else { $msgTaxType = "".$lang['admin']['settings_tax_details_del_failure']."
"; } } // Lookup Existing Taxes/Config if ($config_tax_mod['status']) { $taxDetails = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_tax_details ORDER BY id"); $taxRates = $db->select("SELECT r.id, type_id, t.taxName, details_id, d.name, country_id, county_id, tax_percent, goods, shipping, active, status FROM ".$glob['dbprefix']."CubeCart_tax_rates AS r LEFT JOIN ".$glob['dbprefix']."CubeCart_tax_details AS d ON r.details_id = d.id LEFT JOIN ".$glob['dbprefix']."CubeCart_taxes AS t ON r.type_id = t.id ORDER BY type_id, country_id, county_id, d.id"); $country_names = array(); $all_countries = $db->select("SELECT id, iso, printable_name FROM ".$glob['dbprefix']."CubeCart_iso_countries"); if($taxRates) { foreach ($taxRates as $rate) { $id = $rate['country_id']; foreach ($all_countries as $country) { if ($id == $country['id']){ $country_names[$id] = $country['printable_name']; break; } } } } $taxTypes = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_taxes"); $defaultCountry = $db->select("SELECT id FROM ".$glob['dbprefix']."CubeCart_iso_countries WHERE iso='US'"); if (is_array($defaultCountry)){ $defaultCountry = $defaultCountry[0]['id']; } else { $defaultCountry = 1; } } // end: Flexible Taxes $jsScript = jsGeoLocation("taxCountry", "taxCounty", "-- ".$lang['admin_common']['all']." --"); require($glob['adminFolder'].CC_DS."includes".CC_DS."header.inc.php"); ?> ".$lang['admin']['settings_tax_warn_testing'].""; } else { echo "1.
select("SELECT * FROM ".$glob['dbprefix']."CubeCart_taxes "); ?>3.