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:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Adminhtml_Block_Report_Sales_Tax_Grid extends Mage_Adminhtml_Block_Report_Grid_Abstract
35: {
36: protected $_columnGroupBy = 'period';
37:
38: public function __construct()
39: {
40: parent::__construct();
41: $this->setCountTotals(true);
42: $this->setCountSubTotals(true);
43: }
44:
45: public function getResourceCollectionName()
46: {
47: return ($this->getFilterData()->getData('report_type') == 'updated_at_order')
48: ? 'tax/report_updatedat_collection'
49: : 'tax/report_collection';
50: }
51:
52: protected function _prepareColumns()
53: {
54: $this->addColumn('period', array(
55: 'header' => Mage::helper('sales')->__('Period'),
56: 'index' => 'period',
57: 'width' => '100',
58: 'sortable' => false,
59: 'period_type' => $this->getPeriodType(),
60: 'renderer' => 'adminhtml/report_sales_grid_column_renderer_date',
61: 'totals_label' => Mage::helper('sales')->__('Total'),
62: 'subtotals_label' => Mage::helper('sales')->__('Subtotal'),
63: 'html_decorators' => array('nobr'),
64: ));
65:
66: $this->addColumn('code', array(
67: 'header' => Mage::helper('sales')->__('Tax'),
68: 'index' => 'code',
69: 'type' => 'string',
70: 'sortable' => false
71: ));
72:
73: $this->addColumn('percent', array(
74: 'header' => Mage::helper('sales')->__('Rate'),
75: 'index' => 'percent',
76: 'type' => 'number',
77: 'width' => '100',
78: 'sortable' => false
79: ));
80:
81: $this->addColumn('orders_count', array(
82: 'header' => Mage::helper('sales')->__('Number of Orders'),
83: 'index' => 'orders_count',
84: 'total' => 'sum',
85: 'type' => 'number',
86: 'width' => '100',
87: 'sortable' => false
88: ));
89:
90: if ($this->getFilterData()->getStoreIds()) {
91: $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds()));
92: }
93: $currencyCode = $this->getCurrentCurrencyCode();
94:
95: $this->addColumn('tax_base_amount_sum', array(
96: 'header' => Mage::helper('sales')->__('Tax Amount'),
97: 'type' => 'currency',
98: 'currency_code' => $currencyCode,
99: 'index' => 'tax_base_amount_sum',
100: 'total' => 'sum',
101: 'sortable' => false,
102: 'rate' => $this->getRate($currencyCode),
103: ));
104:
105: $this->addExportType('*/*/exportTaxCsv', Mage::helper('adminhtml')->__('CSV'));
106: $this->addExportType('*/*/exportTaxExcel', Mage::helper('adminhtml')->__('Excel XML'));
107:
108: return parent::_prepareColumns();
109: }
110:
111: 112: 113: 114: 115: 116:
117: protected function _prepareCollection()
118: {
119: $filterData = $this->getFilterData();
120: if(!$filterData->hasData('order_statuses')) {
121: $orderConfig = Mage::getModel('sales/order_config');
122: $statusValues = array();
123: $canceledStatuses = $orderConfig->getStateStatuses(Mage_Sales_Model_Order::STATE_CANCELED);
124: foreach ($orderConfig->getStatuses() as $code => $label) {
125: if (!isset($canceledStatuses[$code])) {
126: $statusValues[] = $code;
127: }
128: }
129: $filterData->setOrderStatuses($statusValues);
130: }
131: return parent::_prepareCollection();
132: }
133: }
134: