Advertisement
andhiirawan

Magento Custom Dashboard Tab - DashboardController.php

Feb 24th, 2015
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.90 KB | None | 0 0
  1. <?php
  2.  
  3. //Path : app\code\local\KS\Dashboard\controllers\DashboardController.php
  4.  
  5. include_once("Mage/Adminhtml/controllers/DashboardController.php");
  6.  
  7. class KS_Dashboard_DashboardController extends Mage_Adminhtml_Controller_Action
  8. {
  9.     public function indexAction()
  10.     {
  11.         $this->_title($this->__('Dashboard'));
  12.  
  13.         $this->loadLayout();
  14.         $this->_setActiveMenu('dashboard');
  15.         $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Dashboard'), Mage::helper('adminhtml')->__('Dashboard'));
  16.         $this->renderLayout();
  17.     }
  18.  
  19.     /**
  20.      * Gets most viewed products list
  21.      *
  22.      */
  23.     public function productsViewedAction()
  24.     {
  25.         $this->loadLayout();
  26.         $this->renderLayout();
  27.     }
  28.  
  29.     /**
  30.      * Gets latest customers list
  31.      *
  32.      */
  33.     public function customersNewestAction()
  34.     {
  35.         $this->loadLayout();
  36.         $this->renderLayout();
  37.     }
  38.  
  39.     /**
  40.      * Gets the list of most active customers
  41.      *
  42.      */
  43.     public function customersMostAction()
  44.     {
  45.         $this->loadLayout();
  46.         $this->renderLayout();
  47.     }
  48.  
  49.     //Get Latest Members List
  50.     public function membersNewAction()
  51.     {
  52.         $this->loadLayout();
  53.         $this->renderLayout();
  54.     }
  55.  
  56.     //Get All Members List
  57.     public function membersAllAction()
  58.     {
  59.         $this->loadLayout();
  60.         $this->renderLayout();
  61.     }
  62.  
  63.     public function ajaxBlockAction()
  64.     {
  65.         $output   = '';
  66.         $blockTab = $this->getRequest()->getParam('block');
  67.         if (in_array($blockTab, array('tab_orders', 'tab_amounts', 'totals'))) {
  68.             $output = $this->getLayout()->createBlock('adminhtml/dashboard_' . $blockTab)->toHtml();
  69.         }
  70.         $this->getResponse()->setBody($output);
  71.         return;
  72.     }
  73.  
  74.     public function tunnelAction()
  75.     {
  76.         $httpClient = new Varien_Http_Client();
  77.         $gaData = $this->getRequest()->getParam('ga');
  78.         $gaHash = $this->getRequest()->getParam('h');
  79.         if ($gaData && $gaHash) {
  80.             $newHash = Mage::helper('adminhtml/dashboard_data')->getChartDataHash($gaData);
  81.             if ($newHash == $gaHash) {
  82.                 if ($params = unserialize(base64_decode(urldecode($gaData)))) {
  83.                     $response = $httpClient->setUri(Mage_Adminhtml_Block_Dashboard_Graph::API_URL)
  84.                             ->setParameterGet($params)
  85.                             ->setConfig(array('timeout' => 5))
  86.                             ->request('GET');
  87.  
  88.                     $headers = $response->getHeaders();
  89.  
  90.                     $this->getResponse()
  91.                         ->setHeader('Content-type', $headers['Content-type'])
  92.                         ->setBody($response->getBody());
  93.                 }
  94.             }
  95.         }
  96.     }
  97.  
  98.     protected function _isAllowed()
  99.     {
  100.         return Mage::getSingleton('admin/session')->isAllowed('dashboard');
  101.     }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement