1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26: class Mage_Adminhtml_Block_Tax_Rate_Grid extends Mage_Adminhtml_Block_Widget_Grid
27: {
28:
29: public function __construct()
30: {
31: parent::__construct();
32: $this->setDefaultSort('region_name');
33: $this->setDefaultDir('asc');
34: $this->setId('tax_rate_grid');
35: $this->setSaveParametersInSession(true);
36: }
37:
38: protected function _prepareCollection()
39: {
40: $rateCollection = Mage::getModel('tax/calculation_rate')->getCollection()
41: ->joinRegionTable();
42:
43: $this->setCollection($rateCollection);
44: return parent::_prepareCollection();
45: }
46:
47: protected function _prepareColumns()
48: {
49: $this->addColumn('code', array(
50: 'header' => Mage::helper('tax')->__('Tax Identifier'),
51: 'header_export' => Mage::helper('tax')->__('Code'),
52: 'align' =>'left',
53: 'index' => 'code',
54: 'filter_index' => 'main_table.code',
55: ));
56:
57: $this->addColumn('tax_country_id', array(
58: 'header' => Mage::helper('tax')->__('Country'),
59: 'type' => 'country',
60: 'align' => 'left',
61: 'index' => 'tax_country_id',
62: 'filter_index' => 'main_table.tax_country_id',
63: 'renderer' => 'adminhtml/tax_rate_grid_renderer_country',
64: 'sortable' => false
65: ));
66:
67: $this->addColumn('region_name', array(
68: 'header' => Mage::helper('tax')->__('State/Region'),
69: 'header_export' => Mage::helper('tax')->__('State'),
70: 'align' =>'left',
71: 'index' => 'region_name',
72: 'filter_index' => 'region_table.code',
73: 'default' => '*',
74: ));
75:
76: $this->addColumn('tax_postcode', array(
77: 'header' => Mage::helper('tax')->__('Zip/Post Code'),
78: 'align' =>'left',
79: 'index' => 'tax_postcode',
80: 'default' => '*',
81: ));
82:
83: $this->addColumn('rate', array(
84: 'header' => Mage::helper('tax')->__('Rate'),
85: 'align' =>'right',
86: 'index' => 'rate',
87: 'type' => 'number',
88: 'default' => '0.00',
89: 'renderer' => 'adminhtml/tax_rate_grid_renderer_data',
90: ));
91:
92: $this->addExportType('*/*/exportCsv', Mage::helper('tax')->__('CSV'));
93: $this->addExportType('*/*/exportXml', Mage::helper('tax')->__('Excel XML'));
94:
95: return parent::_prepareColumns();
96: }
97:
98: public function getRowUrl($row)
99: {
100: return $this->getUrl('*/*/edit', array('rate' => $row->getTaxCalculationRateId()));
101: }
102:
103: }
104:
105: