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
00035 class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Alerts_Stock extends Mage_Adminhtml_Block_Widget_Grid
00036 {
00037 public function __construct()
00038 {
00039 parent::__construct();
00040
00041 $this->setId('alertStock');
00042 $this->setDefaultSort('add_date');
00043 $this->setDefaultSort('desc');
00044 $this->setUseAjax(true);
00045 $this->setFilterVisibility(false);
00046 $this->setEmptyText(Mage::helper('catalog')->__('There are no customers for this alert'));
00047 }
00048
00049 protected function _prepareCollection()
00050 {
00051 $productId = $this->getRequest()->getParam('id');
00052 $websiteId = 0;
00053 if ($store = $this->getRequest()->getParam('store')) {
00054 $websiteId = Mage::app()->getStore($store)->getWebsiteId();
00055 }
00056 $collection = Mage::getModel('productalert/stock')
00057 ->getCustomerCollection()
00058 ->join($productId, $websiteId);
00059 $this->setCollection($collection);
00060 return parent::_prepareCollection();
00061 }
00062
00063 protected function _prepareColumns()
00064 {
00065 $this->addColumn('firstname', array(
00066 'header' => Mage::helper('catalog')->__('First Name'),
00067 'index' => 'firstname',
00068 ));
00069
00070 $this->addColumn('lastname', array(
00071 'header' => Mage::helper('catalog')->__('Last Name'),
00072 'index' => 'lastname',
00073 ));
00074
00075 $this->addColumn('email', array(
00076 'header' => Mage::helper('catalog')->__('Email'),
00077 'index' => 'email',
00078 ));
00079
00080 $this->addColumn('add_date', array(
00081 'header' => Mage::helper('catalog')->__('Date Subscribed'),
00082 'index' => 'add_date',
00083 'type' => 'date'
00084 ));
00085
00086 $this->addColumn('send_date', array(
00087 'header' => Mage::helper('catalog')->__('Last Notification'),
00088 'index' => 'last_send_date',
00089 'type' => 'date'
00090 ));
00091
00092 $this->addColumn('send_count', array(
00093 'header' => Mage::helper('catalog')->__('Send Count'),
00094 'index' => 'send_count',
00095 ));
00096
00097 return parent::_prepareColumns();
00098 }
00099
00100 public function getGridUrl()
00101 {
00102 $productId = $this->getRequest()->getParam('id');
00103 $storeId = $this->getRequest()->getParam('store', 0);
00104 if ($storeId) {
00105 $storeId = Mage::app()->getStore($storeId)->getId();
00106 }
00107 return $this->getUrl('*/catalog_product/alertsStockGrid', array(
00108 'id' => $productId,
00109 'store' => $storeId
00110 ));
00111 }
00112 }