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_Sales extends Mage_Adminhtml_Block_Dashboard_Bar
36: {
37: protected function _construct()
38: {
39: parent::_construct();
40: $this->setTemplate('dashboard/salebar.phtml');
41:
42:
43: }
44:
45: protected function _prepareLayout()
46: {
47: if (!Mage::helper('core')->isModuleEnabled('Mage_Reports')) {
48: return $this;
49: }
50: $isFilter = $this->getRequest()->getParam('store') || $this->getRequest()->getParam('website') || $this->getRequest()->getParam('group');
51:
52: $collection = Mage::getResourceModel('reports/order_collection')
53: ->calculateSales($isFilter);
54:
55: if ($this->getRequest()->getParam('store')) {
56: $collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
57: } else if ($this->getRequest()->getParam('website')){
58: $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
59: $collection->addFieldToFilter('store_id', array('in' => $storeIds));
60: } else if ($this->getRequest()->getParam('group')){
61: $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
62: $collection->addFieldToFilter('store_id', array('in' => $storeIds));
63: }
64:
65: $collection->load();
66: $sales = $collection->getFirstItem();
67:
68: $this->addTotal($this->__('Lifetime Sales'), $sales->getLifetime());
69: $this->addTotal($this->__('Average Orders'), $sales->getAverage());
70: }
71: }
72: