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_Totals_Grid extends Mage_Adminhtml_Block_Report_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('gridTotalsCustomer');
41: }
42:
43: protected function _prepareCollection()
44: {
45: parent::_prepareCollection();
46: $this->getCollection()->initReport('reports/customer_totals_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: $rate = $this->getRate($baseCurrencyCode);
68:
69: $this->addColumn('orders_avg_amount', array(
70: 'header' => $this->__('Average Order Amount'),
71: 'width' => '200px',
72: 'align' => 'right',
73: 'sortable' => false,
74: 'type' => 'currency',
75: 'currency_code' => $baseCurrencyCode,
76: 'index' => 'orders_avg_amount',
77: 'total' => 'orders_sum_amount/orders_count',
78: 'renderer' => 'adminhtml/report_grid_column_renderer_currency',
79: 'rate' => $rate,
80: ));
81:
82: $this->addColumn('orders_sum_amount', array(
83: 'header' => $this->__('Total Order Amount'),
84: 'width' => '200px',
85: 'align' => 'right',
86: 'sortable' => false,
87: 'type' => 'currency',
88: 'currency_code' => $baseCurrencyCode,
89: 'index' => 'orders_sum_amount',
90: 'total' => 'sum',
91: 'renderer' => 'adminhtml/report_grid_column_renderer_currency',
92: 'rate' => $rate,
93: ));
94:
95: $this->addExportType('*/*/exportTotalsCsv', Mage::helper('reports')->__('CSV'));
96: $this->addExportType('*/*/exportTotalsExcel', Mage::helper('reports')->__('Excel XML'));
97:
98: return parent::_prepareColumns();
99: }
100:
101: }
102: