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: class Mage_Sales_Block_Adminhtml_Billing_Agreement_Grid extends Mage_Adminhtml_Block_Widget_Grid
33: {
34: 35: 36: 37:
38: public function __construct()
39: {
40: parent::__construct();
41: $this->setId('billing_agreements');
42: $this->setUseAjax(true);
43: $this->setDefaultSort('agreement_id');
44: $this->setDefaultDir('DESC');
45: $this->setSaveParametersInSession(true);
46: }
47:
48: 49: 50: 51: 52:
53: public function getGridUrl()
54: {
55: return $this->getUrl('*/sales_billing_agreement/grid', array('_current' => true));
56: }
57:
58: 59: 60: 61: 62:
63: public function getRowUrl($item)
64: {
65: return $this->getUrl('*/sales_billing_agreement/view', array('agreement' => $item->getAgreementId()));
66: }
67:
68: 69: 70: 71: 72:
73: protected function _prepareCollection()
74: {
75: $collection = Mage::getResourceModel('sales/billing_agreement_collection')
76: ->addCustomerDetails();
77: $this->setCollection($collection);
78: return parent::_prepareCollection();
79: }
80:
81: 82: 83: 84: 85:
86: protected function _prepareColumns()
87: {
88: $this->addColumn('agreement_id', array(
89: 'header' => Mage::helper('sales')->__('ID'),
90: 'index' => 'agreement_id',
91: 'type' => 'text'
92: ));
93:
94: $this->addColumn('customer_email', array(
95: 'header' => Mage::helper('sales')->__('Customer Email'),
96: 'index' => 'customer_email',
97: 'type' => 'text'
98: ));
99:
100: $this->addColumn('customer_firstname', array(
101: 'header' => Mage::helper('sales')->__('Customer Name'),
102: 'index' => 'customer_firstname',
103: 'type' => 'text',
104: 'escape' => true
105: ));
106:
107: $this->addColumn('customer_lastname', array(
108: 'header' => Mage::helper('sales')->__('Customer Last Name'),
109: 'index' => 'customer_lastname',
110: 'type' => 'text',
111: 'escape' => true
112: ));
113:
114: $this->addColumn('method_code', array(
115: 'header' => Mage::helper('sales')->__('Payment Method'),
116: 'index' => 'method_code',
117: 'type' => 'options',
118: 'options' => Mage::helper('payment')->getAllBillingAgreementMethods()
119: ));
120:
121: $this->addColumn('reference_id', array(
122: 'header' => Mage::helper('sales')->__('Reference ID'),
123: 'index' => 'reference_id',
124: 'type' => 'text'
125: ));
126:
127: $this->addColumn('status', array(
128: 'header' => Mage::helper('sales')->__('Status'),
129: 'index' => 'status',
130: 'type' => 'options',
131: 'options' => Mage::getSingleton('sales/billing_agreement')->getStatusesArray()
132: ));
133:
134: $this->addColumn('created_at', array(
135: 'header' => Mage::helper('sales')->__('Created At'),
136: 'index' => 'agreement_created_at',
137: 'width' => 1,
138: 'type' => 'datetime',
139: 'align' => 'center',
140: 'default' => $this->__('N/A'),
141: 'html_decorators' => array('nobr')
142: ));
143:
144: $this->addColumn('updated_at', array(
145: 'header' => Mage::helper('sales')->__('Updated At'),
146: 'index' => 'agreement_updated_at',
147: 'width' => 1,
148: 'type' => 'datetime',
149: 'align' => 'center',
150: 'default' => $this->__('N/A'),
151: 'html_decorators' => array('nobr')
152: ));
153:
154: return parent::_prepareColumns();
155: }
156: }
157: