00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Adminhtml_Block_Dashboard_Tab_Customers_Newest extends Mage_Adminhtml_Block_Dashboard_Grid
00036 {
00037
00038 public function __construct()
00039 {
00040 parent::__construct();
00041 $this->setId('customersNewestGrid');
00042 }
00043
00044 protected function _prepareCollection()
00045 {
00046 $collection = Mage::getResourceModel('reports/customer_collection')
00047 ->addCustomerName()
00048 ->joinOrders()
00049 ->addOrdersCount();
00050
00051 $storeFilter = 0;
00052 if ($this->getParam('store')) {
00053 $collection->addAttributeToFilter('store_id', $this->getParam('store'));
00054 $storeFilter = 1;
00055 } else if ($this->getParam('website')){
00056 $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
00057 $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
00058 } else if ($this->getParam('group')){
00059 $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
00060 $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
00061 }
00062
00063 $collection->addSumAvgTotals($storeFilter)
00064 ->orderByCustomerRegistration();
00065
00066 $this->setCollection($collection);
00067
00068 return parent::_prepareCollection();
00069 }
00070
00071 protected function _prepareColumns()
00072 {
00073 $this->addColumn('name', array(
00074 'header' => $this->__('Customer Name'),
00075 'sortable' => false,
00076 'index' => 'name'
00077 ));
00078
00079 $this->addColumn('orders_count', array(
00080 'header' => $this->__('Number of Orders'),
00081 'sortable' => false,
00082 'index' => 'orders_count',
00083 'type' => 'number'
00084 ));
00085
00086 $baseCurrencyCode = (string) Mage::app()->getStore((int)$this->getParam('store'))->getBaseCurrencyCode();
00087
00088 $this->addColumn('orders_avg_amount', array(
00089 'header' => $this->__('Average Order Amount'),
00090 'align' => 'right',
00091 'sortable' => false,
00092 'type' => 'currency',
00093 'currency_code' => $baseCurrencyCode,
00094 'index' => 'orders_avg_amount',
00095 'renderer' =>'adminhtml/report_grid_column_renderer_currency'
00096 ));
00097
00098 $this->addColumn('orders_sum_amount', array(
00099 'header' => $this->__('Total Order Amount'),
00100 'align' => 'right',
00101 'sortable' => false,
00102 'type' => 'currency',
00103 'currency_code' => $baseCurrencyCode,
00104 'index' => 'orders_sum_amount',
00105 'renderer' =>'adminhtml/report_grid_column_renderer_currency'
00106 ));
00107
00108 $this->setFilterVisibility(false);
00109 $this->setPagerVisibility(false);
00110
00111 return parent::_prepareColumns();
00112 }
00113
00114 public function getRowUrl($row)
00115 {
00116 return $this->getUrl('*/customer/edit', array('id'=>$row->getId()));
00117 }
00118 }