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: class Mage_Adminhtml_Block_Sales_Order_View_Tab_Creditmemos
35: extends Mage_Adminhtml_Block_Widget_Grid
36: implements Mage_Adminhtml_Block_Widget_Tab_Interface
37: {
38: public function __construct()
39: {
40: parent::__construct();
41: $this->setId('order_creditmemos');
42: $this->setUseAjax(true);
43: }
44:
45: 46: 47: 48: 49:
50: protected function _getCollectionClass()
51: {
52: return 'sales/order_creditmemo_grid_collection';
53: }
54:
55:
56: protected function _prepareCollection()
57: {
58: $collection = Mage::getResourceModel($this->_getCollectionClass())
59: ->addFieldToSelect('entity_id')
60: ->addFieldToSelect('created_at')
61: ->addFieldToSelect('increment_id')
62: ->addFieldToSelect('order_currency_code')
63: ->addFieldToSelect('store_currency_code')
64: ->addFieldToSelect('base_currency_code')
65: ->addFieldToSelect('state')
66: ->addFieldToSelect('grand_total')
67: ->addFieldToSelect('base_grand_total')
68: ->addFieldToSelect('billing_name')
69: ->setOrderFilter($this->getOrder())
70: ;
71: $this->setCollection($collection);
72: return parent::_prepareCollection();
73: }
74:
75: protected function _prepareColumns()
76: {
77: $this->addColumn('increment_id', array(
78: 'header' => Mage::helper('sales')->__('Credit Memo #'),
79: 'width' => '120px',
80: 'index' => 'increment_id',
81: ));
82:
83: $this->addColumn('billing_name', array(
84: 'header' => Mage::helper('sales')->__('Bill to Name'),
85: 'index' => 'billing_name',
86: ));
87:
88: $this->addColumn('created_at', array(
89: 'header' => Mage::helper('sales')->__('Created At'),
90: 'index' => 'created_at',
91: 'type' => 'datetime',
92: ));
93:
94: $this->addColumn('state', array(
95: 'header' => Mage::helper('sales')->__('Status'),
96: 'index' => 'state',
97: 'type' => 'options',
98: 'options' => Mage::getModel('sales/order_creditmemo')->getStates(),
99: ));
100:
101: $this->addColumn('base_grand_total', array(
102: 'header' => Mage::helper('customer')->__('Refunded'),
103: 'index' => 'base_grand_total',
104: 'type' => 'currency',
105: 'currency' => 'base_currency_code',
106: ));
107:
108: return parent::_prepareColumns();
109: }
110:
111: 112: 113: 114: 115:
116: public function getOrder()
117: {
118: return Mage::registry('current_order');
119: }
120:
121: public function getRowUrl($row)
122: {
123: return $this->getUrl(
124: '*/sales_order_creditmemo/view',
125: array(
126: 'creditmemo_id'=> $row->getId(),
127: 'order_id' => $row->getOrderId()
128: ));
129: }
130:
131: public function getGridUrl()
132: {
133: return $this->getUrl('*/*/creditmemos', array('_current' => true));
134: }
135:
136: 137: 138:
139: public function getTabLabel()
140: {
141: return Mage::helper('sales')->__('Credit Memos');
142: }
143:
144: public function getTabTitle()
145: {
146: return Mage::helper('sales')->__('Order Credit Memos');
147: }
148:
149: public function canShowTab()
150: {
151: return true;
152: }
153:
154: public function isHidden()
155: {
156: return false;
157: }
158: }
159: