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 class Mage_Adminhtml_Block_Customer_Online_Grid extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036
00037
00038
00039
00040 public function __construct()
00041 {
00042 parent::__construct();
00043 $this->setId('onlineGrid');
00044 $this->setSaveParametersInSession(true);
00045 $this->setDefaultSort('last_activity');
00046 $this->setDefaultDir('DESC');
00047 }
00048
00049
00050
00051
00052
00053
00054 protected function _prepareCollection()
00055 {
00056 $collection = Mage::getModel('log/visitor_online')
00057 ->prepare()
00058 ->getCollection();
00059
00060 $collection->addCustomerData();
00061
00062 $this->setCollection($collection);
00063 parent::_prepareCollection();
00064
00065 return $this;
00066 }
00067
00068
00069
00070
00071
00072
00073 protected function _prepareColumns()
00074 {
00075 $this->addColumn('customer_id', array(
00076 'header' => Mage::helper('customer')->__('ID'),
00077 'width' => '40px',
00078 'align' => 'right',
00079 'type' => 'number',
00080 'default' => Mage::helper('customer')->__('n/a'),
00081 'index' => 'customer_id'
00082 ));
00083
00084 $this->addColumn('firstname', array(
00085 'header' => Mage::helper('customer')->__('First Name'),
00086 'default' => Mage::helper('customer')->__('Guest'),
00087 'index' => 'customer_firstname'
00088 ));
00089
00090 $this->addColumn('lastname', array(
00091 'header' => Mage::helper('customer')->__('Last Name'),
00092 'default' => Mage::helper('customer')->__('n/a'),
00093 'index' => 'customer_lastname'
00094 ));
00095
00096 $this->addColumn('email', array(
00097 'header' => Mage::helper('customer')->__('Email'),
00098 'default' => Mage::helper('customer')->__('n/a'),
00099 'index' => 'customer_email'
00100 ));
00101
00102 $this->addColumn('ip_address', array(
00103 'header' => Mage::helper('customer')->__('IP Address'),
00104 'default' => Mage::helper('customer')->__('n/a'),
00105 'index' => 'remote_addr',
00106 'renderer' => 'adminhtml/customer_online_grid_renderer_ip',
00107 'filter' => false,
00108 'sort' => false
00109 ));
00110
00111 $this->addColumn('session_start_time', array(
00112 'header' => Mage::helper('customer')->__('Session Start Time'),
00113 'align' => 'left',
00114 'width' => '200px',
00115 'type' => 'datetime',
00116 'default' => Mage::helper('customer')->__('n/a'),
00117 'index' =>'first_visit_at'
00118 ));
00119
00120 $this->addColumn('last_activity', array(
00121 'header' => Mage::helper('customer')->__('Last Activity'),
00122 'align' => 'left',
00123 'width' => '200px',
00124 'type' => 'datetime',
00125 'default' => Mage::helper('customer')->__('n/a'),
00126 'index' => 'last_visit_at'
00127 ));
00128
00129 $typeOptions = array(
00130 Mage_Log_Model_Visitor::VISITOR_TYPE_CUSTOMER => Mage::helper('customer')->__('Customer'),
00131 Mage_Log_Model_Visitor::VISITOR_TYPE_VISITOR => Mage::helper('customer')->__('Visitor'),
00132 );
00133
00134 $this->addColumn('type', array(
00135 'header' => Mage::helper('customer')->__('Type'),
00136 'index' => 'type',
00137 'type' => 'options',
00138 'options' => $typeOptions,
00139
00140 'index' => 'visitor_type'
00141 ));
00142
00143 $this->addColumn('last_url', array(
00144 'header' => Mage::helper('customer')->__('Last Url'),
00145 'type' => 'wrapline',
00146 'lineLength' => '60',
00147 'default' => Mage::helper('customer')->__('n/a'),
00148 'renderer' => 'adminhtml/customer_online_grid_renderer_url',
00149 'index' => 'last_url'
00150 ));
00151
00152 return parent::_prepareColumns();
00153 }
00154
00155
00156
00157
00158
00159
00160
00161 public function getRowUrl($row)
00162 {
00163 return $row->getCustomerId() ? $this->getUrl('*/customer/edit', array('id' => $row->getCustomerId())) : '';
00164 }
00165 }