[ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 $Id: tax.php 3 2006-05-27 04:59:07Z user $ 4 5 osCMax Power E-Commerce 6 http://oscdox.com 7 8 Copyright 2006 osCMax 9 10 Released under the GNU General Public License 11 12 Mofified by: Chemo 13 Purpose: MS2 backward compatibility 14 Contact: [email protected] 15 */ 16 17 class osC_Tax { 18 var $tax_rates; 19 20 // class constructor 21 function osC_Tax() { 22 $this->tax_rates = array(); 23 } 24 25 // class methods 26 function getTaxRate($class_id, $country_id = -1, $zone_id = -1) { 27 // LINE ADDED: Bugfix 0000036 28 global $customer_zone_id, $customer_country_id; 29 if ( ($country_id == -1) && ($zone_id == -1) ) { 30 if (!tep_session_is_registered('customer_id')) { 31 $country_id = STORE_COUNTRY; 32 $zone_id = STORE_ZONE; 33 } else { 34 $country_id = $customer_country_id; 35 $zone_id = $customer_zone_id; 36 } 37 } 38 39 if (isset($this->tax_rates[$class_id][$country_id][$zone_id]['rate']) == false) { 40 $tax_query = tep_db_query("select sum(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . (int)$country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . (int)$zone_id . "') and tr.tax_class_id = '" . (int)$class_id . "' group by tr.tax_priority"); 41 if (tep_db_num_rows($tax_query)) { 42 $tax_multiplier = 1.0; 43 while ($tax = tep_db_fetch_array($tax_query)) { 44 $tax_multiplier *= 1.0 + ($tax['tax_rate'] / 100); 45 } 46 47 $tax_rate = ($tax_multiplier - 1.0) * 100; 48 } else { 49 $tax_rate = 0; 50 } 51 52 $this->tax_rates[$class_id][$country_id][$zone_id]['rate'] = $tax_rate; 53 } 54 55 return $this->tax_rates[$class_id][$country_id][$zone_id]['rate']; 56 } 57 58 function getTaxRateDescription($class_id, $country_id, $zone_id) { 59 if (isset($this->tax_rates[$class_id][$country_id][$zone_id]['description']) == false) { 60 $tax_query = tep_db_query("select tax_description from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . (int)$country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . (int)$zone_id . "') and tr.tax_class_id = '" . (int)$class_id . "' order by tr.tax_priority"); 61 if (tep_db_num_rows($tax_query)) { 62 $tax_description = ''; 63 64 while ($tax = tep_db_fetch_array($tax_query)) { 65 $tax_description .= $tax['tax_description'] . ' + '; 66 } 67 68 $this->tax_rates[$class_id][$country_id][$zone_id]['description'] = substr($tax_description, 0, -3); 69 } else { 70 $this->tax_rates[$class_id][$country_id][$zone_id]['description'] = TEXT_UNKNOWN_TAX_RATE; 71 } 72 } 73 74 return $this->tax_rates[$class_id][$country_id][$zone_id]['description']; 75 } 76 } 77 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |