<?php 
class ModelCatalogPriceInputHelper extends Model {
	public function getAllTaxRates() {
		$tax_rates = array();
		
		$store_address = array(
			'country_id' => $this->config->get('config_country_id'),
			'zone_id'    => $this->config->get('config_zone_id')
		);
		$customer_group_id = $this->config->get('config_customer_group_id');
				
		$tax_query = $this->db->query("SELECT tr1.tax_class_id, tr2.tax_rate_id, tr2.name, tr2.rate, tr2.type, tr1.priority FROM " . DB_PREFIX . "tax_rule tr1 LEFT JOIN " . DB_PREFIX . "tax_rate tr2 ON (tr1.tax_rate_id = tr2.tax_rate_id) INNER JOIN " . DB_PREFIX . "tax_rate_to_customer_group tr2cg ON (tr2.tax_rate_id = tr2cg.tax_rate_id) LEFT JOIN " . DB_PREFIX . "zone_to_geo_zone z2gz ON (tr2.geo_zone_id = z2gz.geo_zone_id) LEFT JOIN " . DB_PREFIX . "geo_zone gz ON (tr2.geo_zone_id = gz.geo_zone_id) WHERE tr2cg.customer_group_id = '" . (int)$customer_group_id . "' AND z2gz.country_id = '" . (int)$store_address['country_id'] . "' AND (z2gz.zone_id = '0' OR z2gz.zone_id = '" . (int)$store_address['zone_id'] . "') ORDER BY tr1.priority ASC");
			
		foreach ($tax_query->rows as $result) {
			$tax_rates[$result['tax_class_id']][] = array(
				'tax_rate_id' => $result['tax_rate_id'],
				'name'        => $result['name'],
				'rate'        => (float)$result['rate'],
				'type'        => $result['type'],
				'priority'    => $result['priority']
			);
		}
		return($tax_rates);
			
	}
}
?>
