00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 class Mage_Adminhtml_Block_Tax_Rule_Grid extends Mage_Adminhtml_Block_Widget_Grid
00027 {
00028
00029 public function __construct()
00030 {
00031 parent::__construct();
00032 $this->setDefaultSort('tax_rule_id');
00033 $this->setId('taxRuleGrid');
00034 $this->setDefaultDir('asc');
00035 $this->setSaveParametersInSession(true);
00036 }
00037
00038 protected function _prepareCollection()
00039 {
00040 $collection = Mage::getModel('tax/calculation_rule')
00041 ->getCollection();
00042 $this->setCollection($collection);
00043 parent::_prepareCollection();
00044 if ($this->getCollection()) {
00045 $this->getCollection()
00046 ->addCustomerTaxClassesToResult()
00047 ->addProductTaxClassesToResult()
00048 ->addRatesToResult();
00049 }
00050 return $this;
00051 }
00052
00053 protected function _addColumnFilterToCollection($column)
00054 {
00055 if ($this->getCollection()) {
00056 switch ($column->getId()) {
00057 case 'tax_rates':
00058 $this->getCollection()->joinCalculationData('rate');
00059 break;
00060
00061 case 'customer_tax_classes':
00062 $this->getCollection()->joinCalculationData('ctc');
00063 break;
00064
00065 case 'product_tax_classes':
00066 $this->getCollection()->joinCalculationData('ptc');
00067 break;
00068
00069 }
00070 }
00071 return parent::_addColumnFilterToCollection($column);
00072 }
00073
00074 protected function _prepareColumns()
00075 {
00076 $this->addColumn('code',
00077 array(
00078 'header'=>Mage::helper('tax')->__('Name'),
00079 'align' =>'left',
00080 'index' => 'code',
00081 'filter_index' => 'code',
00082 )
00083 );
00084
00085 $this->addColumn('customer_tax_classes',
00086 array(
00087 'header'=>Mage::helper('tax')->__('Customer Tax Class'),
00088 'sortable' => false,
00089 'align' =>'left',
00090 'index' => 'customer_tax_classes',
00091 'filter_index' => 'ctc.customer_tax_class_id',
00092 'type' => 'options',
00093 'options' => Mage::getModel('tax/class')->getCollection()->setClassTypeFilter('CUSTOMER')->toOptionHash(),
00094 )
00095 );
00096
00097 $this->addColumn('product_tax_classes',
00098 array(
00099 'header'=>Mage::helper('tax')->__('Product Tax Class'),
00100 'sortable' => false,
00101 'align' =>'left',
00102 'index' => 'product_tax_classes',
00103 'filter_index' => 'ptc.product_tax_class_id',
00104 'type' => 'options',
00105 'options' => Mage::getModel('tax/class')->getCollection()->setClassTypeFilter('PRODUCT')->toOptionHash(),
00106 )
00107 );
00108
00109 $this->addColumn('tax_rates',
00110 array(
00111 'sortable' => false,
00112 'header' => Mage::helper('tax')->__('Tax Rate'),
00113 'align' => 'left',
00114 'index' => 'tax_rates',
00115 'filter_index' => 'rate.tax_calculation_rate_id',
00116 'type' => 'options',
00117 'options' => Mage::getModel('tax/calculation_rate')->getCollection()->toOptionHash(),
00118 )
00119 );
00120
00121 $this->addColumn('priority',
00122 array(
00123 'header'=>Mage::helper('tax')->__('Priority'),
00124 'width' => '50px',
00125 'index' => 'priority'
00126 )
00127 );
00128
00129 $this->addColumn('position',
00130 array(
00131 'header'=>Mage::helper('tax')->__('Sort Order'),
00132 'width' => '50px',
00133 'index' => 'position'
00134 )
00135 );
00136
00137 $actionsUrl = $this->getUrl('*/*/');
00138
00139 return parent::_prepareColumns();
00140 }
00141
00142 public function getRowUrl($row)
00143 {
00144 return $this->getUrl('*/*/edit', array('rule' => $row->getId()));
00145 }
00146
00147 }