1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27:
28: 29: 30: 31: 32: 33: 34:
35: class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Alerts_Stock extends Mage_Adminhtml_Block_Widget_Grid
36: {
37: public function __construct()
38: {
39: parent::__construct();
40:
41: $this->setId('alertStock');
42: $this->setDefaultSort('add_date');
43: $this->setDefaultSort('DESC');
44: $this->setUseAjax(true);
45: $this->setFilterVisibility(false);
46: $this->setEmptyText(Mage::helper('catalog')->__('There are no customers for this alert.'));
47: }
48:
49: protected function _prepareCollection()
50: {
51: $productId = $this->getRequest()->getParam('id');
52: $websiteId = 0;
53: if ($store = $this->getRequest()->getParam('store')) {
54: $websiteId = Mage::app()->getStore($store)->getWebsiteId();
55: }
56: if (Mage::helper('catalog')->isModuleEnabled('Mage_ProductAlert')) {
57: $collection = Mage::getModel('productalert/stock')
58: ->getCustomerCollection()
59: ->join($productId, $websiteId);
60: $this->setCollection($collection);
61: }
62: return parent::_prepareCollection();
63: }
64:
65: protected function _prepareColumns()
66: {
67: $this->addColumn('firstname', array(
68: 'header' => Mage::helper('catalog')->__('First Name'),
69: 'index' => 'firstname',
70: ));
71:
72: $this->addColumn('lastname', array(
73: 'header' => Mage::helper('catalog')->__('Last Name'),
74: 'index' => 'lastname',
75: ));
76:
77: $this->addColumn('email', array(
78: 'header' => Mage::helper('catalog')->__('Email'),
79: 'index' => 'email',
80: ));
81:
82: $this->addColumn('add_date', array(
83: 'header' => Mage::helper('catalog')->__('Date Subscribed'),
84: 'index' => 'add_date',
85: 'type' => 'date'
86: ));
87:
88: $this->addColumn('send_date', array(
89: 'header' => Mage::helper('catalog')->__('Last Notification'),
90: 'index' => 'send_date',
91: 'type' => 'date'
92: ));
93:
94: $this->addColumn('send_count', array(
95: 'header' => Mage::helper('catalog')->__('Send Count'),
96: 'index' => 'send_count',
97: ));
98:
99: return parent::_prepareColumns();
100: }
101:
102: public function getGridUrl()
103: {
104: $productId = $this->getRequest()->getParam('id');
105: $storeId = $this->getRequest()->getParam('store', 0);
106: if ($storeId) {
107: $storeId = Mage::app()->getStore($storeId)->getId();
108: }
109: return $this->getUrl('*/catalog_product/alertsStockGrid', array(
110: 'id' => $productId,
111: 'store' => $storeId
112: ));
113: }
114: }
115: