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_Orders_Grid extends Mage_Adminhtml_Block_Dashboard_Grid
00036 {
00037
00038 public function __construct()
00039 {
00040 parent::__construct();
00041 $this->setId('lastOrdersGrid');
00042 }
00043
00044 protected function _prepareCollection()
00045 {
00046
00047 $collection = Mage::getResourceModel('reports/order_collection')
00048 ->addItemCountExpr()
00049 ->addExpressionAttributeToSelect('customer',
00050 "IFNULL(CONCAT({{customer_firstname}},' ',{{customer_lastname}}), '{$this->__('Guest')}')",
00051 array('customer_firstname','customer_lastname')
00052 )
00053 ->setOrder('created_at');
00054
00055 if($this->getParam('store') || $this->getParam('website') || $this->getParam('group')) {
00056 if ($this->getParam('store')) {
00057 $collection->addAttributeToFilter('store_id', $this->getParam('store'));
00058 } else if ($this->getParam('website')){
00059 $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
00060 $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
00061 } else if ($this->getParam('group')){
00062 $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
00063 $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
00064 }
00065
00066 $collection->addExpressionAttributeToSelect('revenue',
00067 '({{base_grand_total}})',
00068 array('base_grand_total'));
00069 } else {
00070 $collection->addExpressionAttributeToSelect('revenue',
00071 '({{base_grand_total}}/{{store_to_base_rate}})',
00072 array('base_grand_total', 'store_to_base_rate'));
00073 }
00074
00075 $this->setCollection($collection);
00076
00077 return parent::_prepareCollection();
00078 }
00079
00080 protected function _prepareColumns()
00081 {
00082 $this->addColumn('customer', array(
00083 'header' => $this->__('Customer'),
00084 'sortable' => false,
00085 'index' => 'customer'
00086 ));
00087
00088 $this->addColumn('items', array(
00089 'header' => $this->__('Items'),
00090 'align' => 'right',
00091 'sortable' => false,
00092 'index' => 'items_count'
00093 ));
00094
00095 $baseCurrencyCode = Mage::app()->getStore((int)$this->getParam('store'))->getBaseCurrencyCode();
00096
00097 $this->addColumn('total', array(
00098 'header' => $this->__('Grand Total'),
00099 'align' => 'right',
00100 'sortable' => false,
00101 'type' => 'currency',
00102 'currency_code' => $baseCurrencyCode,
00103 'index' => 'revenue'
00104 ));
00105
00106 $this->setFilterVisibility(false);
00107 $this->setPagerVisibility(false);
00108
00109 return parent::_prepareColumns();
00110 }
00111
00112 public function getRowUrl($row)
00113 {
00114 return $this->getUrl('*/sales_order/view', array('order_id'=>$row->getId()));
00115 }
00116 }