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