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_Sales extends Mage_Adminhtml_Block_Dashboard_Bar
00036 {
00037 protected function _construct()
00038 {
00039 parent::_construct();
00040 $this->setTemplate('dashboard/salebar.phtml');
00041
00042
00043 }
00044
00045 protected function _prepareLayout()
00046 {
00047 $isFilter = $this->getRequest()->getParam('store') || $this->getRequest()->getParam('website') || $this->getRequest()->getParam('group');
00048
00049 $collection = Mage::getResourceModel('reports/order_collection')
00050 ->calculateSales($isFilter);
00051
00052 if ($this->getRequest()->getParam('store')) {
00053 $collection->addAttributeToFilter('store_id', $this->getRequest()->getParam('store'));
00054 } else if ($this->getRequest()->getParam('website')){
00055 $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
00056 $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
00057 } else if ($this->getRequest()->getParam('group')){
00058 $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
00059 $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
00060 }
00061
00062 $collection->load();
00063 $collectionArray = $collection->toArray();
00064 $sales = array_pop($collectionArray);
00065
00066 $this->addTotal($this->__('Lifetime Sales'), $sales['lifetime']);
00067 $this->addTotal($this->__('Average Orders'), $sales['average']);
00068 }
00069 }