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_Orders_Grid extends Mage_Adminhtml_Block_Dashboard_Grid
36: {
37:
38: public function __construct()
39: {
40: parent::__construct();
41: $this->setId('lastOrdersGrid');
42: }
43:
44: protected function _prepareCollection()
45: {
46: if (!Mage::helper('core')->isModuleEnabled('Mage_Reports')) {
47: return $this;
48: }
49: $collection = Mage::getResourceModel('reports/order_collection')
50: ->addItemCountExpr()
51: ->joinCustomerName('customer')
52: ->orderByCreatedAt();
53:
54: if($this->getParam('store') || $this->getParam('website') || $this->getParam('group')) {
55: if ($this->getParam('store')) {
56: $collection->addAttributeToFilter('store_id', $this->getParam('store'));
57: } else if ($this->getParam('website')){
58: $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
59: $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
60: } else if ($this->getParam('group')){
61: $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
62: $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
63: }
64:
65: $collection->addRevenueToSelect();
66: } else {
67: $collection->addRevenueToSelect(true);
68: }
69:
70: $this->setCollection($collection);
71:
72: return parent::_prepareCollection();
73: }
74:
75: 76: 77: 78: 79:
80: protected function _preparePage()
81: {
82: $this->getCollection()->setPageSize($this->getParam($this->getVarNameLimit(), $this->_defaultLimit));
83:
84: }
85:
86: protected function _prepareColumns()
87: {
88: $this->addColumn('customer', array(
89: 'header' => $this->__('Customer'),
90: 'sortable' => false,
91: 'index' => 'customer',
92: 'default' => $this->__('Guest'),
93: ));
94:
95: $this->addColumn('items', array(
96: 'header' => $this->__('Items'),
97: 'align' => 'right',
98: 'type' => 'number',
99: 'sortable' => false,
100: 'index' => 'items_count'
101: ));
102:
103: $baseCurrencyCode = Mage::app()->getStore((int)$this->getParam('store'))->getBaseCurrencyCode();
104:
105: $this->addColumn('total', array(
106: 'header' => $this->__('Grand Total'),
107: 'align' => 'right',
108: 'sortable' => false,
109: 'type' => 'currency',
110: 'currency_code' => $baseCurrencyCode,
111: 'index' => 'revenue'
112: ));
113:
114: $this->setFilterVisibility(false);
115: $this->setPagerVisibility(false);
116:
117: return parent::_prepareColumns();
118: }
119:
120: public function getRowUrl($row)
121: {
122: return $this->getUrl('*/sales_order/view', array('order_id'=>$row->getId()));
123: }
124: }
125: