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_Report_Shopcart_Abandoned_Grid extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036
00037 public function __construct()
00038 {
00039 parent::__construct();
00040 $this->setId('gridAbandoned');
00041 }
00042
00043 protected function _prepareCollection()
00044 {
00045 if ($this->getRequest()->getParam('website')) {
00046 $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
00047 } else if ($this->getRequest()->getParam('group')) {
00048 $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
00049 } else if ($this->getRequest()->getParam('store')) {
00050 $storeIds = array((int)$this->getRequest()->getParam('store'));
00051 } else {
00052 $storeIds = '';
00053 }
00054
00055 $collection = Mage::getResourceModel('reports/quote_collection');
00056
00057 $filter = $this->getParam($this->getVarNameFilter(), array());
00058 if ($filter) {
00059 $filter = base64_decode($filter);
00060 parse_str(urldecode($filter), $data);
00061 }
00062
00063 if (!empty($data)) {
00064 $collection->prepareForAbandonedReport($storeIds, $data);
00065 } else {
00066 $collection->prepareForAbandonedReport($storeIds);
00067 }
00068
00069 $this->setCollection($collection);
00070 return parent::_prepareCollection();
00071 }
00072
00073 protected function _addColumnFilterToCollection($column)
00074 {
00075 $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
00076 $skip = array('subtotal', 'customer_name', 'email');
00077
00078 if (in_array($field, $skip)) {
00079 return $this;
00080 }
00081
00082 parent::_addColumnFilterToCollection($column);
00083 return $this;
00084 }
00085
00086 protected function _prepareColumns()
00087 {
00088 $this->addColumn('customer_name', array(
00089 'header' =>Mage::helper('reports')->__('Customer Name'),
00090 'index' =>'customer_name',
00091 'sortable' =>false
00092 ));
00093
00094 $this->addColumn('email', array(
00095 'header' =>Mage::helper('reports')->__('Email'),
00096 'index' =>'email',
00097 'sortable' =>false
00098 ));
00099
00100 $this->addColumn('items_count', array(
00101 'header' =>Mage::helper('reports')->__('Number of Items'),
00102 'width' =>'80px',
00103 'align' =>'right',
00104 'index' =>'items_count',
00105 'sortable' =>false,
00106 'type' =>'number'
00107 ));
00108
00109 $this->addColumn('items_qty', array(
00110 'header' =>Mage::helper('reports')->__('Quantity of Items'),
00111 'width' =>'80px',
00112 'align' =>'right',
00113 'index' =>'items_qty',
00114 'sortable' =>false,
00115 'type' =>'number'
00116 ));
00117
00118 $this->addColumn('subtotal', array(
00119 'header' =>Mage::helper('reports')->__('Subtotal'),
00120 'width' =>'80px',
00121 'type' =>'currency',
00122 'currency_code' => $this->getCurrentCurrencyCode(),
00123 'index' =>'subtotal',
00124 'sortable' =>false,
00125 'renderer' =>'adminhtml/report_grid_column_renderer_currency'
00126 ));
00127
00128 $this->addColumn('coupon_code', array(
00129 'header' =>Mage::helper('reports')->__('Applied Coupon'),
00130 'width' =>'80px',
00131 'index' =>'coupon_code',
00132 'sortable' =>false
00133 ));
00134
00135 $this->addColumn('created_at', array(
00136 'header' =>Mage::helper('reports')->__('Created at'),
00137 'width' =>'170px',
00138 'type' =>'datetime',
00139 'index' =>'created_at',
00140 'filter_index'=>'main_table.created_at',
00141 'sortable' =>false
00142 ));
00143
00144 $this->addColumn('updated_at', array(
00145 'header' =>Mage::helper('reports')->__('Updated at'),
00146 'width' =>'170px',
00147 'type' =>'datetime',
00148 'index' =>'updated_at',
00149 'filter_index'=>'main_table.updated_at',
00150 'sortable' =>false
00151 ));
00152
00153 $this->addExportType('*/*/exportAbandonedCsv', Mage::helper('reports')->__('CSV'));
00154 $this->addExportType('*/*/exportAbandonedExcel', Mage::helper('reports')->__('Excel'));
00155
00156 return parent::_prepareColumns();
00157 }
00158
00159 public function getRowUrl($row)
00160 {
00161 return $this->getUrl('*/customer/edit', array('id'=>$row->getCustomerId(), 'active_tab'=>'cart'));
00162 }
00163
00164 public function getRowClickCallback(){
00165 return "function(grid, evt) {
00166 var trElement = Event.findElement(evt, 'tr');
00167 if(trElement && trElement.id != ''){
00168 var newWindow = window.open(trElement.id, '_blank');
00169 newWindow.focus();
00170 }}";
00171 }
00172 }