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_Customer_Orders_Grid extends Mage_Adminhtml_Block_Report_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('gridOrdersCustomer');
41: }
42:
43: protected function _prepareCollection()
44: {
45: parent::_prepareCollection();
46: $this->getCollection()->initReport('reports/customer_orders_collection');
47: }
48:
49: protected function _prepareColumns()
50: {
51: $this->addColumn('name', array(
52: 'header' => $this->__('Customer Name'),
53: 'sortable' => false,
54: 'index' => 'name'
55: ));
56:
57: $this->addColumn('orders_count', array(
58: 'header' => $this->__('Number of Orders'),
59: 'width' => '100px',
60: 'sortable' => false,
61: 'index' => 'orders_count',
62: 'total' => 'sum',
63: 'type' => 'number'
64: ));
65:
66: $baseCurrencyCode = $this->getCurrentCurrencyCode();
67:
68: $this->addColumn('orders_avg_amount', array(
69: 'header' => $this->__('Average Order Amount'),
70: 'width' => '200px',
71: 'align' => 'right',
72: 'sortable' => false,
73: 'type' => 'currency',
74: 'currency_code' => $baseCurrencyCode,
75: 'index' => 'orders_avg_amount',
76: 'total' => 'orders_sum_amount/orders_count',
77: 'renderer' =>'adminhtml/report_grid_column_renderer_currency'
78: ));
79:
80: $this->addColumn('orders_sum_amount', array(
81: 'header' => $this->__('Total Order Amount'),
82: 'width' => '200px',
83: 'align' => 'right',
84: 'sortable' => false,
85: 'type' => 'currency',
86: 'currency_code' => $baseCurrencyCode,
87: 'index' => 'orders_sum_amount',
88: 'total' => 'sum',
89: 'renderer' => 'adminhtml/report_grid_column_renderer_currency',
90: ));
91:
92: $this->addExportType('*/*/exportOrdersCsv', Mage::helper('reports')->__('CSV'));
93: $this->addExportType('*/*/exportOrdersExcel', Mage::helper('reports')->__('Excel XML'));
94:
95: return parent::_prepareColumns();
96: }
97:
98: }
99: