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_Invoices
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_invoices');
42: $this->setUseAjax(true);
43: }
44:
45: 46: 47: 48: 49:
50: protected function _getCollectionClass()
51: {
52: return 'sales/order_invoice_grid_collection';
53: }
54:
55: protected function _prepareCollection()
56: {
57: $collection = Mage::getResourceModel($this->_getCollectionClass())
58: ->addFieldToSelect('entity_id')
59: ->addFieldToSelect('created_at')
60: ->addFieldToSelect('order_id')
61: ->addFieldToSelect('increment_id')
62: ->addFieldToSelect('state')
63: ->addFieldToSelect('grand_total')
64: ->addFieldToSelect('base_grand_total')
65: ->addFieldToSelect('store_currency_code')
66: ->addFieldToSelect('base_currency_code')
67: ->addFieldToSelect('order_currency_code')
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')->__('Invoice #'),
79: 'index' => 'increment_id',
80: 'width' => '120px',
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')->__('Invoice Date'),
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_invoice')->getStates(),
99: ));
100:
101: $this->addColumn('base_grand_total', array(
102: 'header' => Mage::helper('customer')->__('Amount'),
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('*/sales_order_invoice/view',
124: array(
125: 'invoice_id'=> $row->getId(),
126: 'order_id' => $row->getOrderId()
127: )
128: );
129: }
130:
131: public function getGridUrl()
132: {
133: return $this->getUrl('*/*/invoices', array('_current' => true));
134: }
135:
136:
137: 138: 139:
140: public function getTabLabel()
141: {
142: return Mage::helper('sales')->__('Invoices');
143: }
144:
145: public function getTabTitle()
146: {
147: return Mage::helper('sales')->__('Order Invoices');
148: }
149:
150: public function canShowTab()
151: {
152: return true;
153: }
154:
155: public function isHidden()
156: {
157: return false;
158: }
159: }
160: