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: class Mage_Sales_Block_Adminhtml_Recurring_Profile_Grid extends Mage_Adminhtml_Block_Widget_Grid
31: {
32: 33: 34:
35: public function __construct()
36: {
37: parent::__construct();
38: $this->setId('sales_recurring_profile_grid');
39: $this->setUseAjax(true);
40: $this->setSaveParametersInSession(true);
41: }
42:
43: 44: 45: 46: 47:
48: protected function _prepareCollection()
49: {
50: $collection = Mage::getResourceModel('sales/recurring_profile_collection');
51: $this->setCollection($collection);
52: if (!$this->getParam($this->getVarNameSort())) {
53: $collection->setOrder('profile_id', 'desc');
54: }
55: return parent::_prepareCollection();
56: }
57:
58: 59: 60: 61: 62:
63: protected function _prepareColumns()
64: {
65: $profile = Mage::getModel('sales/recurring_profile');
66:
67: $this->addColumn('reference_id', array(
68: 'header' => $profile->getFieldLabel('reference_id'),
69: 'index' => 'reference_id',
70: 'html_decorators' => array('nobr'),
71: 'width' => 1,
72: ));
73:
74: if (!Mage::app()->isSingleStoreMode()) {
75: $this->addColumn('store_id', array(
76: 'header' => Mage::helper('adminhtml')->__('Store'),
77: 'index' => 'store_id',
78: 'type' => 'store',
79: 'store_view' => true,
80: 'display_deleted' => true,
81: ));
82: }
83:
84: $this->addColumn('state', array(
85: 'header' => $profile->getFieldLabel('state'),
86: 'index' => 'state',
87: 'type' => 'options',
88: 'options' => $profile->getAllStates(),
89: 'html_decorators' => array('nobr'),
90: 'width' => 1,
91: ));
92:
93: $this->addColumn('created_at', array(
94: 'header' => $profile->getFieldLabel('created_at'),
95: 'index' => 'created_at',
96: 'type' => 'datetime',
97: 'html_decorators' => array('nobr'),
98: 'width' => 1,
99: ));
100:
101: $this->addColumn('updated_at', array(
102: 'header' => $profile->getFieldLabel('updated_at'),
103: 'index' => 'updated_at',
104: 'type' => 'datetime',
105: 'html_decorators' => array('nobr'),
106: 'width' => 1,
107: ));
108:
109: $methods = array();
110: foreach (Mage::helper('payment')->getRecurringProfileMethods() as $method) {
111: $methods[$method->getCode()] = $method->getTitle();
112: }
113: $this->addColumn('method_code', array(
114: 'header' => $profile->getFieldLabel('method_code'),
115: 'index' => 'method_code',
116: 'type' => 'options',
117: 'options' => $methods,
118: ));
119:
120: $this->addColumn('schedule_description', array(
121: 'header' => $profile->getFieldLabel('schedule_description'),
122: 'index' => 'schedule_description',
123: ));
124:
125: return parent::_prepareColumns();
126: }
127:
128: 129: 130: 131: 132: 133:
134: public function getRowUrl($row)
135: {
136: return $this->getUrl('*/sales_recurring_profile/view', array('profile' => $row->getId()));
137: }
138:
139: 140: 141: 142: 143:
144: public function getGridUrl()
145: {
146: return $this->getUrl('*/*/grid', array('_current'=>true));
147: }
148: }
149: