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_Adminhtml_Block_Sales_Creditmemo_Grid extends Mage_Adminhtml_Block_Widget_Grid
33: {
34:
35: public function __construct()
36: {
37: parent::__construct();
38: $this->setId('sales_creditmemo_grid');
39: $this->setDefaultSort('created_at');
40: $this->setDefaultDir('DESC');
41: }
42:
43: 44: 45: 46: 47:
48: protected function _getCollectionClass()
49: {
50: return 'sales/order_creditmemo_grid_collection';
51: }
52:
53: protected function _prepareCollection()
54: {
55: $collection = Mage::getResourceModel($this->_getCollectionClass());
56: $this->setCollection($collection);
57: return parent::_prepareCollection();
58: }
59:
60:
61: protected function _prepareColumns()
62: {
63: $this->addColumn('increment_id', array(
64: 'header' => Mage::helper('sales')->__('Credit Memo #'),
65: 'index' => 'increment_id',
66: 'type' => 'text',
67: ));
68:
69: $this->addColumn('created_at', array(
70: 'header' => Mage::helper('sales')->__('Created At'),
71: 'index' => 'created_at',
72: 'type' => 'datetime',
73: ));
74:
75: $this->addColumn('order_increment_id', array(
76: 'header' => Mage::helper('sales')->__('Order #'),
77: 'index' => 'order_increment_id',
78: 'type' => 'text',
79: ));
80:
81: $this->addColumn('order_created_at', array(
82: 'header' => Mage::helper('sales')->__('Order Date'),
83: 'index' => 'order_created_at',
84: 'type' => 'datetime',
85: ));
86:
87: $this->addColumn('billing_name', array(
88: 'header' => Mage::helper('sales')->__('Bill to Name'),
89: 'index' => 'billing_name',
90: ));
91:
92: $this->addColumn('state', array(
93: 'header' => Mage::helper('sales')->__('Status'),
94: 'index' => 'state',
95: 'type' => 'options',
96: 'options' => Mage::getModel('sales/order_creditmemo')->getStates(),
97: ));
98:
99: $this->addColumn('grand_total', array(
100: 'header' => Mage::helper('customer')->__('Refunded'),
101: 'index' => 'grand_total',
102: 'type' => 'currency',
103: 'align' => 'right',
104: 'currency' => 'order_currency_code',
105: ));
106:
107: $this->addColumn('action',
108: array(
109: 'header' => Mage::helper('sales')->__('Action'),
110: 'width' => '50px',
111: 'type' => 'action',
112: 'getter' => 'getId',
113: 'actions' => array(
114: array(
115: 'caption' => Mage::helper('sales')->__('View'),
116: 'url' => array('base'=>'*/sales_creditmemo/view'),
117: 'field' => 'creditmemo_id'
118: )
119: ),
120: 'filter' => false,
121: 'sortable' => false,
122: 'is_system' => true
123: ));
124:
125: $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
126: $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
127:
128: return parent::_prepareColumns();
129: }
130:
131: protected function _prepareMassaction()
132: {
133: $this->setMassactionIdField('entity_id');
134: $this->getMassactionBlock()->setFormFieldName('creditmemo_ids');
135: $this->getMassactionBlock()->setUseSelectAll(false);
136:
137: $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
138: 'label'=> Mage::helper('sales')->__('PDF Credit Memos'),
139: 'url' => $this->getUrl('*/sales_creditmemo/pdfcreditmemos'),
140: ));
141:
142: return $this;
143: }
144:
145: public function getRowUrl($row)
146: {
147: if (!Mage::getSingleton('admin/session')->isAllowed('sales/order/creditmemo')) {
148: return false;
149: }
150:
151: return $this->getUrl('*/sales_creditmemo/view',
152: array(
153: 'creditmemo_id'=> $row->getId(),
154: )
155: );
156: }
157:
158: public function getGridUrl()
159: {
160: return $this->getUrl('*/*/*', array('_current' => true));
161: }
162:
163:
164:
165: }
166: