Skip to content

Commit 7eca113

Browse files
feat: dashboard charts - bar/line option (#4775)
* feat: dashboard charts - bar/line option * update --------- Co-authored-by: Colin Mollenhour <colin@mollenhour.com>
1 parent 1447794 commit 7eca113

File tree

20 files changed

+174
-36
lines changed

20 files changed

+174
-36
lines changed

app/code/core/Mage/Adminhtml/Block/Dashboard/Bar.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,19 @@ public function setCurrency($currency)
8181
* Retrieve currency model if not set then return currency model for current store
8282
*
8383
* @return Mage_Directory_Model_Currency
84+
* @throws Mage_Core_Model_Store_Exception
85+
* @throws Mage_Core_Exception
8486
*/
8587
public function getCurrency()
8688
{
8789
if (is_null($this->_currentCurrencyCode)) {
88-
if ($this->getRequest()->getParam('store')) {
89-
$this->_currentCurrencyCode = Mage::app()->getStore($this->getRequest()->getParam('store'))->getBaseCurrency();
90-
} elseif ($this->getRequest()->getParam('website')) {
91-
$this->_currentCurrencyCode = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getBaseCurrency();
92-
} elseif ($this->getRequest()->getParam('group')) {
93-
$this->_currentCurrencyCode = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getWebsite()->getBaseCurrency();
90+
$request = $this->getRequest();
91+
if ($request->getParam('store')) {
92+
$this->_currentCurrencyCode = Mage::app()->getStore($request->getParam('store'))->getBaseCurrency();
93+
} elseif ($request->getParam('website')) {
94+
$this->_currentCurrencyCode = Mage::app()->getWebsite($request->getParam('website'))->getBaseCurrency();
95+
} elseif ($request->getParam('group')) {
96+
$this->_currentCurrencyCode = Mage::app()->getGroup($request->getParam('group'))->getWebsite()->getBaseCurrency();
9497
} else {
9598
$this->_currentCurrencyCode = Mage::app()->getStore()->getBaseCurrency();
9699
}

app/code/core/Mage/Adminhtml/Block/Dashboard/Diagrams.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public function __construct()
3030
$this->setTemplate('widget/tabshoriz.phtml');
3131
}
3232

33+
/**
34+
* @throws Exception
35+
*/
3336
protected function _prepareLayout()
3437
{
3538
$this->addTab('orders', [
@@ -42,6 +45,7 @@ protected function _prepareLayout()
4245
'label' => $this->__('Amounts'),
4346
'content' => $this->getLayout()->createBlock('adminhtml/dashboard_tab_amounts')->toHtml(),
4447
]);
48+
4549
return parent::_prepareLayout();
4650
}
4751
}

app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class Mage_Adminhtml_Block_Dashboard_Graph extends Mage_Adminhtml_Block_Dashboar
7878

7979
/**
8080
* Initialize object
81+
* @throws Exception
8182
*/
8283
public function __construct()
8384
{
@@ -232,6 +233,9 @@ public function generateChart(): array
232233
return $params;
233234
}
234235

236+
/**
237+
* @throws Mage_Core_Model_Store_Exception
238+
*/
235239
private function getChartDatasAndDates(): array
236240
{
237241
$timezoneLocal = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
@@ -497,7 +501,9 @@ public function getChartLabels(): string
497501

498502
public function getChartType(): string
499503
{
500-
return 'bar';
504+
/** @var Mage_Adminhtml_Helper_Dashboard_Data $helper */
505+
$helper = $this->helper('adminhtml/dashboard_data');
506+
return $helper->getChartType();
501507
}
502508

503509
public function getChartId(): string

app/code/core/Mage/Adminhtml/Block/Dashboard/Grid.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class Mage_Adminhtml_Block_Dashboard_Grid extends Mage_Adminhtml_Block_Widget_Gr
2424
{
2525
/**
2626
* Setting default for every grid on dashboard
27-
*
2827
*/
2928
public function __construct()
3029
{

app/code/core/Mage/Adminhtml/Block/Dashboard/Grids.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function __construct()
4343
* 3) specify class 'ajax'
4444
*
4545
* @return $this
46+
* @throws Exception
4647
*/
4748
protected function _prepareLayout()
4849
{

app/code/core/Mage/Adminhtml/Block/Dashboard/Orders/Grid.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ protected function _preparePage()
7070

7171
/**
7272
* @inheritDoc
73+
* @throws Exception
7374
*/
7475
protected function _prepareColumns()
7576
{
@@ -104,7 +105,7 @@ protected function _prepareColumns()
104105
}
105106

106107
/**
107-
* @param Varien_Object $row
108+
* @param Mage_Sales_Model_Order $row
108109
* @return string
109110
*/
110111
public function getRowUrl($row)

app/code/core/Mage/Adminhtml/Block/Dashboard/Sales.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,29 @@ protected function _construct()
2828
$this->setTemplate('dashboard/salebar.phtml');
2929
}
3030

31+
/**
32+
* @throws Mage_Core_Exception
33+
*/
3134
protected function _prepareLayout()
3235
{
3336
if (!$this->isModuleEnabled('Mage_Reports')) {
3437
return $this;
3538
}
36-
$isFilter = $this->getRequest()->getParam('store') || $this->getRequest()->getParam('website') || $this->getRequest()->getParam('group');
39+
40+
$request = $this->getRequest();
41+
42+
$isFilter = $request->getParam('store') || $request->getParam('website') || $request->getParam('group');
3743

3844
$collection = Mage::getResourceModel('reports/order_collection')
3945
->calculateSales($isFilter);
4046

41-
if ($this->getRequest()->getParam('store')) {
42-
$collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
43-
} elseif ($this->getRequest()->getParam('website')) {
44-
$storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
47+
if ($request->getParam('store')) {
48+
$collection->addFieldToFilter('store_id', $request->getParam('store'));
49+
} elseif ($request->getParam('website')) {
50+
$storeIds = Mage::app()->getWebsite($request->getParam('website'))->getStoreIds();
4551
$collection->addFieldToFilter('store_id', ['in' => $storeIds]);
46-
} elseif ($this->getRequest()->getParam('group')) {
47-
$storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
52+
} elseif ($request->getParam('group')) {
53+
$storeIds = Mage::app()->getGroup($request->getParam('group'))->getStoreIds();
4854
$collection->addFieldToFilter('store_id', ['in' => $storeIds]);
4955
}
5056

app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Last.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ protected function _prepareCollection()
3939
->getResourceCollection();
4040
$this->_collection->setRecentQueryFilter();
4141

42-
if ($this->getRequest()->getParam('store')) {
43-
$this->_collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
44-
} elseif ($this->getRequest()->getParam('website')) {
45-
$storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
42+
$request = $this->getRequest();
43+
if ($request->getParam('store')) {
44+
$this->_collection->addFieldToFilter('store_id', $request->getParam('store'));
45+
} elseif ($request->getParam('website')) {
46+
$storeIds = Mage::app()->getWebsite($request->getParam('website'))->getStoreIds();
4647
$this->_collection->addFieldToFilter('store_id', ['in' => $storeIds]);
47-
} elseif ($this->getRequest()->getParam('group')) {
48-
$storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
48+
} elseif ($request->getParam('group')) {
49+
$storeIds = Mage::app()->getGroup($request->getParam('group'))->getStoreIds();
4950
$this->_collection->addFieldToFilter('store_id', ['in' => $storeIds]);
5051
}
5152

@@ -54,6 +55,9 @@ protected function _prepareCollection()
5455
return parent::_prepareCollection();
5556
}
5657

58+
/**
59+
* @throws Exception
60+
*/
5761
protected function _prepareColumns()
5862
{
5963
$this->addColumn('search_query', [
@@ -83,6 +87,10 @@ protected function _prepareColumns()
8387
return parent::_prepareColumns();
8488
}
8589

90+
/**
91+
* @param Mage_CatalogSearch_Model_Query $row
92+
* @return string
93+
*/
8694
public function getRowUrl($row)
8795
{
8896
return $this->getUrl('*/catalog_search/edit', ['id' => $row->getId()]);

app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Top.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ protected function _prepareCollection()
3838
$this->_collection = Mage::getModel('catalogsearch/query')
3939
->getResourceCollection();
4040

41-
if ($this->getRequest()->getParam('store')) {
42-
$storeIds = $this->getRequest()->getParam('store');
43-
} elseif ($this->getRequest()->getParam('website')) {
44-
$storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
45-
} elseif ($this->getRequest()->getParam('group')) {
46-
$storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
41+
$request = $this->getRequest();
42+
if ($request->getParam('store')) {
43+
$storeIds = $request->getParam('store');
44+
} elseif ($request->getParam('website')) {
45+
$storeIds = Mage::app()->getWebsite($request->getParam('website'))->getStoreIds();
46+
} elseif ($request->getParam('group')) {
47+
$storeIds = Mage::app()->getGroup($request->getParam('group'))->getStoreIds();
4748
} else {
4849
$storeIds = '';
4950
}
@@ -56,6 +57,9 @@ protected function _prepareCollection()
5657
return parent::_prepareCollection();
5758
}
5859

60+
/**
61+
* @throws Exception
62+
*/
5963
protected function _prepareColumns()
6064
{
6165
$this->addColumn('search_query', [
@@ -85,6 +89,10 @@ protected function _prepareColumns()
8589
return parent::_prepareColumns();
8690
}
8791

92+
/**
93+
* @param Mage_CatalogSearch_Model_Query $row
94+
* @return string
95+
*/
8896
public function getRowUrl($row)
8997
{
9098
return $this->getUrl('*/catalog_search/edit', ['id' => $row->getId()]);

app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Amounts.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Mage_Adminhtml_Block_Dashboard_Tab_Amounts extends Mage_Adminhtml_Block_Da
2929

3030
/**
3131
* Initialize object
32+
* @throws Exception
3233
*/
3334
public function __construct()
3435
{
@@ -40,6 +41,7 @@ public function __construct()
4041
* Prepare chart data
4142
*
4243
* @return void
44+
* @throws Exception
4345
*/
4446
protected function _prepareData()
4547
{

0 commit comments

Comments
 (0)