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_Sales_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: }
43:
44: public function getResourceCollectionName()
45: {
46: return ($this->getFilterData()->getData('report_type') == 'updated_at_order')
47: ? 'sales/report_order_updatedat_collection'
48: : 'sales/report_order_collection';
49: }
50:
51: protected function _prepareColumns()
52: {
53: $this->addColumn('period', array(
54: 'header' => Mage::helper('sales')->__('Period'),
55: 'index' => 'period',
56: 'width' => 100,
57: 'sortable' => false,
58: 'period_type' => $this->getPeriodType(),
59: 'renderer' => 'adminhtml/report_sales_grid_column_renderer_date',
60: 'totals_label' => Mage::helper('sales')->__('Total'),
61: 'html_decorators' => array('nobr'),
62: ));
63:
64: $this->addColumn('orders_count', array(
65: 'header' => Mage::helper('sales')->__('Orders'),
66: 'index' => 'orders_count',
67: 'type' => 'number',
68: 'total' => 'sum',
69: 'sortable' => false
70: ));
71:
72: $this->addColumn('total_qty_ordered', array(
73: 'header' => Mage::helper('sales')->__('Sales Items'),
74: 'index' => 'total_qty_ordered',
75: 'type' => 'number',
76: 'total' => 'sum',
77: 'sortable' => false
78: ));
79:
80: $this->addColumn('total_qty_invoiced', array(
81: 'header' => Mage::helper('sales')->__('Items'),
82: 'index' => 'total_qty_invoiced',
83: 'type' => 'number',
84: 'total' => 'sum',
85: 'sortable' => false,
86: 'visibility_filter' => array('show_actual_columns')
87: ));
88:
89: if ($this->getFilterData()->getStoreIds()) {
90: $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds()));
91: }
92: $currencyCode = $this->getCurrentCurrencyCode();
93: $rate = $this->getRate($currencyCode);
94:
95: $this->addColumn('total_income_amount', array(
96: 'header' => Mage::helper('sales')->__('Sales Total'),
97: 'type' => 'currency',
98: 'currency_code' => $currencyCode,
99: 'index' => 'total_income_amount',
100: 'total' => 'sum',
101: 'sortable' => false,
102: 'rate' => $rate,
103: ));
104:
105: $this->addColumn('total_revenue_amount', array(
106: 'header' => Mage::helper('sales')->__('Revenue'),
107: 'type' => 'currency',
108: 'currency_code' => $currencyCode,
109: 'index' => 'total_revenue_amount',
110: 'total' => 'sum',
111: 'sortable' => false,
112: 'visibility_filter' => array('show_actual_columns'),
113: 'rate' => $rate,
114: ));
115:
116: $this->addColumn('total_profit_amount', array(
117: 'header' => Mage::helper('sales')->__('Profit'),
118: 'type' => 'currency',
119: 'currency_code' => $currencyCode,
120: 'index' => 'total_profit_amount',
121: 'total' => 'sum',
122: 'sortable' => false,
123: 'visibility_filter' => array('show_actual_columns'),
124: 'rate' => $rate,
125: ));
126:
127: $this->addColumn('total_invoiced_amount', array(
128: 'header' => Mage::helper('sales')->__('Invoiced'),
129: 'type' => 'currency',
130: 'currency_code' => $currencyCode,
131: 'index' => 'total_invoiced_amount',
132: 'total' => 'sum',
133: 'sortable' => false,
134: 'rate' => $rate,
135: ));
136:
137: $this->addColumn('total_paid_amount', array(
138: 'header' => Mage::helper('sales')->__('Paid'),
139: 'type' => 'currency',
140: 'currency_code' => $currencyCode,
141: 'index' => 'total_paid_amount',
142: 'total' => 'sum',
143: 'sortable' => false,
144: 'visibility_filter' => array('show_actual_columns'),
145: 'rate' => $rate,
146: ));
147:
148: $this->addColumn('total_refunded_amount', array(
149: 'header' => Mage::helper('sales')->__('Refunded'),
150: 'type' => 'currency',
151: 'currency_code' => $currencyCode,
152: 'index' => 'total_refunded_amount',
153: 'total' => 'sum',
154: 'sortable' => false,
155: 'rate' => $rate,
156: ));
157:
158: $this->addColumn('total_tax_amount', array(
159: 'header' => Mage::helper('sales')->__('Sales Tax'),
160: 'type' => 'currency',
161: 'currency_code' => $currencyCode,
162: 'index' => 'total_tax_amount',
163: 'total' => 'sum',
164: 'sortable' => false,
165: 'rate' => $rate,
166: ));
167:
168: $this->addColumn('total_tax_amount_actual', array(
169: 'header' => Mage::helper('sales')->__('Tax'),
170: 'type' => 'currency',
171: 'currency_code' => $currencyCode,
172: 'index' => 'total_tax_amount_actual',
173: 'total' => 'sum',
174: 'sortable' => false,
175: 'visibility_filter' => array('show_actual_columns'),
176: 'rate' => $rate,
177: ));
178:
179: $this->addColumn('total_shipping_amount', array(
180: 'header' => Mage::helper('sales')->__('Sales Shipping'),
181: 'type' => 'currency',
182: 'currency_code' => $currencyCode,
183: 'index' => 'total_shipping_amount',
184: 'total' => 'sum',
185: 'sortable' => false,
186: 'rate' => $rate,
187: ));
188:
189: $this->addColumn('total_shipping_amount_actual', array(
190: 'header' => Mage::helper('sales')->__('Shipping'),
191: 'type' => 'currency',
192: 'currency_code' => $currencyCode,
193: 'index' => 'total_shipping_amount_actual',
194: 'total' => 'sum',
195: 'sortable' => false,
196: 'visibility_filter' => array('show_actual_columns'),
197: 'rate' => $rate,
198: ));
199:
200: $this->addColumn('total_discount_amount', array(
201: 'header' => Mage::helper('sales')->__('Sales Discount'),
202: 'type' => 'currency',
203: 'currency_code' => $currencyCode,
204: 'index' => 'total_discount_amount',
205: 'total' => 'sum',
206: 'sortable' => false,
207: 'rate' => $rate,
208: ));
209:
210: $this->addColumn('total_discount_amount_actual', array(
211: 'header' => Mage::helper('sales')->__('Discount'),
212: 'type' => 'currency',
213: 'currency_code' => $currencyCode,
214: 'index' => 'total_discount_amount_actual',
215: 'total' => 'sum',
216: 'sortable' => false,
217: 'visibility_filter' => array('show_actual_columns'),
218: 'rate' => $rate,
219: ));
220:
221: $this->addColumn('total_canceled_amount', array(
222: 'header' => Mage::helper('sales')->__('Canceled'),
223: 'type' => 'currency',
224: 'currency_code' => $currencyCode,
225: 'index' => 'total_canceled_amount',
226: 'total' => 'sum',
227: 'sortable' => false,
228: 'rate' => $rate,
229: ));
230:
231:
232: $this->addExportType('*/*/exportSalesCsv', Mage::helper('adminhtml')->__('CSV'));
233: $this->addExportType('*/*/exportSalesExcel', Mage::helper('adminhtml')->__('Excel XML'));
234:
235: return parent::_prepareColumns();
236: }
237: }
238: