PageRenderTime 27ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/magento/app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php

https://bitbucket.org/jit_bec/shopifine
PHP | 166 lines | 97 code | 16 blank | 53 comment | 1 complexity | 3f19e5385ef5cb69f43e15aeef74173f MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_Adminhtml
  23. * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26. /**
  27. * Adminhtml customer grid block
  28. *
  29. * @category Mage
  30. * @package Mage_Adminhtml
  31. * @author Magento Core Team <core@magentocommerce.com>
  32. */
  33. class Mage_Adminhtml_Block_Customer_Online_Grid extends Mage_Adminhtml_Block_Widget_Grid
  34. {
  35. /**
  36. * Initialize Grid block
  37. *
  38. */
  39. public function __construct()
  40. {
  41. parent::__construct();
  42. $this->setId('onlineGrid');
  43. $this->setSaveParametersInSession(true);
  44. $this->setDefaultSort('last_activity');
  45. $this->setDefaultDir('DESC');
  46. }
  47. /**
  48. * Prepare collection for grid
  49. *
  50. * @return Mage_Adminhtml_Block_Customer_Online_Grid
  51. */
  52. protected function _prepareCollection()
  53. {
  54. $collection = Mage::getModel('log/visitor_online')
  55. ->prepare()
  56. ->getCollection();
  57. /* @var $collection Mage_Log_Model_Mysql4_Visitor_Online_Collection */
  58. $collection->addCustomerData();
  59. $this->setCollection($collection);
  60. parent::_prepareCollection();
  61. return $this;
  62. }
  63. /**
  64. * Prepare columns
  65. *
  66. * @return Mage_Adminhtml_Block_Customer_Online_Grid
  67. */
  68. protected function _prepareColumns()
  69. {
  70. $this->addColumn('customer_id', array(
  71. 'header' => Mage::helper('customer')->__('ID'),
  72. 'width' => '40px',
  73. 'align' => 'right',
  74. 'type' => 'number',
  75. 'default' => Mage::helper('customer')->__('n/a'),
  76. 'index' => 'customer_id'
  77. ));
  78. $this->addColumn('firstname', array(
  79. 'header' => Mage::helper('customer')->__('First Name'),
  80. 'default' => Mage::helper('customer')->__('Guest'),
  81. 'index' => 'customer_firstname'
  82. ));
  83. $this->addColumn('lastname', array(
  84. 'header' => Mage::helper('customer')->__('Last Name'),
  85. 'default' => Mage::helper('customer')->__('n/a'),
  86. 'index' => 'customer_lastname'
  87. ));
  88. $this->addColumn('email', array(
  89. 'header' => Mage::helper('customer')->__('Email'),
  90. 'default' => Mage::helper('customer')->__('n/a'),
  91. 'index' => 'customer_email'
  92. ));
  93. $this->addColumn('ip_address', array(
  94. 'header' => Mage::helper('customer')->__('IP Address'),
  95. 'default' => Mage::helper('customer')->__('n/a'),
  96. 'index' => 'remote_addr',
  97. 'renderer' => 'adminhtml/customer_online_grid_renderer_ip',
  98. 'filter' => false,
  99. 'sort' => false
  100. ));
  101. $this->addColumn('session_start_time', array(
  102. 'header' => Mage::helper('customer')->__('Session Start Time'),
  103. 'align' => 'left',
  104. 'width' => '200px',
  105. 'type' => 'datetime',
  106. 'default' => Mage::helper('customer')->__('n/a'),
  107. 'index' =>'first_visit_at'
  108. ));
  109. $this->addColumn('last_activity', array(
  110. 'header' => Mage::helper('customer')->__('Last Activity'),
  111. 'align' => 'left',
  112. 'width' => '200px',
  113. 'type' => 'datetime',
  114. 'default' => Mage::helper('customer')->__('n/a'),
  115. 'index' => 'last_visit_at'
  116. ));
  117. $typeOptions = array(
  118. Mage_Log_Model_Visitor::VISITOR_TYPE_CUSTOMER => Mage::helper('customer')->__('Customer'),
  119. Mage_Log_Model_Visitor::VISITOR_TYPE_VISITOR => Mage::helper('customer')->__('Visitor'),
  120. );
  121. $this->addColumn('type', array(
  122. 'header' => Mage::helper('customer')->__('Type'),
  123. 'index' => 'type',
  124. 'type' => 'options',
  125. 'options' => $typeOptions,
  126. // 'renderer' => 'adminhtml/customer_online_grid_renderer_type',
  127. 'index' => 'visitor_type'
  128. ));
  129. $this->addColumn('last_url', array(
  130. 'header' => Mage::helper('customer')->__('Last URL'),
  131. 'type' => 'wrapline',
  132. 'lineLength' => '60',
  133. 'default' => Mage::helper('customer')->__('n/a'),
  134. 'renderer' => 'adminhtml/customer_online_grid_renderer_url',
  135. 'index' => 'last_url'
  136. ));
  137. return parent::_prepareColumns();
  138. }
  139. /**
  140. * Retrieve Row URL
  141. *
  142. * @param Mage_Core_Model_Abstract
  143. * @return string
  144. */
  145. public function getRowUrl($row)
  146. {
  147. return (Mage::getSingleton('admin/session')->isAllowed('customer/manage') && $row->getCustomerId())
  148. ? $this->getUrl('*/customer/edit', array('id' => $row->getCustomerId())) : '';
  149. }
  150. }