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:
35: class Mage_Adminhtml_Block_Dashboard_Tab_Customers_Newest extends Mage_Adminhtml_Block_Dashboard_Grid
36: {
37:
38: public function __construct()
39: {
40: parent::__construct();
41: $this->setId('customersNewestGrid');
42: }
43:
44: protected function _prepareCollection()
45: {
46: $collection = Mage::getResourceModel('reports/customer_collection')
47: ->addCustomerName();
48:
49: $storeFilter = 0;
50: if ($this->getParam('store')) {
51: $collection->addAttributeToFilter('store_id', $this->getParam('store'));
52: $storeFilter = 1;
53: } else if ($this->getParam('website')){
54: $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
55: $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
56: } else if ($this->getParam('group')){
57: $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
58: $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
59: }
60:
61: $collection->addOrdersStatistics($storeFilter)
62: ->orderByCustomerRegistration();
63:
64: $this->setCollection($collection);
65:
66: return parent::_prepareCollection();
67: }
68:
69: protected function _prepareColumns()
70: {
71: $this->addColumn('name', array(
72: 'header' => $this->__('Customer Name'),
73: 'sortable' => false,
74: 'index' => 'name'
75: ));
76:
77: $this->addColumn('orders_count', array(
78: 'header' => $this->__('Number of Orders'),
79: 'sortable' => false,
80: 'index' => 'orders_count',
81: 'type' => 'number'
82: ));
83:
84: $baseCurrencyCode = (string) Mage::app()->getStore((int)$this->getParam('store'))->getBaseCurrencyCode();
85:
86: $this->addColumn('orders_avg_amount', array(
87: 'header' => $this->__('Average Order Amount'),
88: 'align' => 'right',
89: 'sortable' => false,
90: 'type' => 'currency',
91: 'currency_code' => $baseCurrencyCode,
92: 'index' => 'orders_avg_amount',
93: 'renderer' =>'adminhtml/report_grid_column_renderer_currency'
94: ));
95:
96: $this->addColumn('orders_sum_amount', array(
97: 'header' => $this->__('Total Order Amount'),
98: 'align' => 'right',
99: 'sortable' => false,
100: 'type' => 'currency',
101: 'currency_code' => $baseCurrencyCode,
102: 'index' => 'orders_sum_amount',
103: 'renderer' =>'adminhtml/report_grid_column_renderer_currency'
104: ));
105:
106: $this->setFilterVisibility(false);
107: $this->setPagerVisibility(false);
108:
109: return parent::_prepareColumns();
110: }
111:
112: public function getRowUrl($row)
113: {
114: return $this->getUrl('*/customer/edit', array('id'=>$row->getId()));
115: }
116: }
117: