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_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('sales_order_grid');
41: $this->setUseAjax(true);
42: $this->setDefaultSort('created_at');
43: $this->setDefaultDir('DESC');
44: $this->setSaveParametersInSession(true);
45: }
46:
47: 48: 49: 50: 51:
52: protected function _getCollectionClass()
53: {
54: return 'sales/order_grid_collection';
55: }
56:
57: protected function _prepareCollection()
58: {
59: $collection = Mage::getResourceModel($this->_getCollectionClass());
60: $this->setCollection($collection);
61: return parent::_prepareCollection();
62: }
63:
64: protected function _prepareColumns()
65: {
66:
67: $this->addColumn('real_order_id', array(
68: 'header'=> Mage::helper('sales')->__('Order #'),
69: 'width' => '80px',
70: 'type' => 'text',
71: 'index' => 'increment_id',
72: ));
73:
74: if (!Mage::app()->isSingleStoreMode()) {
75: $this->addColumn('store_id', array(
76: 'header' => Mage::helper('sales')->__('Purchased From (Store)'),
77: 'index' => 'store_id',
78: 'type' => 'store',
79: 'store_view'=> true,
80: 'display_deleted' => true,
81: ));
82: }
83:
84: $this->addColumn('created_at', array(
85: 'header' => Mage::helper('sales')->__('Purchased On'),
86: 'index' => 'created_at',
87: 'type' => 'datetime',
88: 'width' => '100px',
89: ));
90:
91: $this->addColumn('billing_name', array(
92: 'header' => Mage::helper('sales')->__('Bill to Name'),
93: 'index' => 'billing_name',
94: ));
95:
96: $this->addColumn('shipping_name', array(
97: 'header' => Mage::helper('sales')->__('Ship to Name'),
98: 'index' => 'shipping_name',
99: ));
100:
101: $this->addColumn('base_grand_total', array(
102: 'header' => Mage::helper('sales')->__('G.T. (Base)'),
103: 'index' => 'base_grand_total',
104: 'type' => 'currency',
105: 'currency' => 'base_currency_code',
106: ));
107:
108: $this->addColumn('grand_total', array(
109: 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
110: 'index' => 'grand_total',
111: 'type' => 'currency',
112: 'currency' => 'order_currency_code',
113: ));
114:
115: $this->addColumn('status', array(
116: 'header' => Mage::helper('sales')->__('Status'),
117: 'index' => 'status',
118: 'type' => 'options',
119: 'width' => '70px',
120: 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
121: ));
122:
123: if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
124: $this->addColumn('action',
125: array(
126: 'header' => Mage::helper('sales')->__('Action'),
127: 'width' => '50px',
128: 'type' => 'action',
129: 'getter' => 'getId',
130: 'actions' => array(
131: array(
132: 'caption' => Mage::helper('sales')->__('View'),
133: 'url' => array('base'=>'*/sales_order/view'),
134: 'field' => 'order_id'
135: )
136: ),
137: 'filter' => false,
138: 'sortable' => false,
139: 'index' => 'stores',
140: 'is_system' => true,
141: ));
142: }
143: $this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
144:
145: $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
146: $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
147:
148: return parent::_prepareColumns();
149: }
150:
151: protected function _prepareMassaction()
152: {
153: $this->setMassactionIdField('entity_id');
154: $this->getMassactionBlock()->setFormFieldName('order_ids');
155: $this->getMassactionBlock()->setUseSelectAll(false);
156:
157: if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
158: $this->getMassactionBlock()->addItem('cancel_order', array(
159: 'label'=> Mage::helper('sales')->__('Cancel'),
160: 'url' => $this->getUrl('*/sales_order/massCancel'),
161: ));
162: }
163:
164: if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
165: $this->getMassactionBlock()->addItem('hold_order', array(
166: 'label'=> Mage::helper('sales')->__('Hold'),
167: 'url' => $this->getUrl('*/sales_order/massHold'),
168: ));
169: }
170:
171: if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
172: $this->getMassactionBlock()->addItem('unhold_order', array(
173: 'label'=> Mage::helper('sales')->__('Unhold'),
174: 'url' => $this->getUrl('*/sales_order/massUnhold'),
175: ));
176: }
177:
178: $this->getMassactionBlock()->addItem('pdfinvoices_order', array(
179: 'label'=> Mage::helper('sales')->__('Print Invoices'),
180: 'url' => $this->getUrl('*/sales_order/pdfinvoices'),
181: ));
182:
183: $this->getMassactionBlock()->addItem('pdfshipments_order', array(
184: 'label'=> Mage::helper('sales')->__('Print Packingslips'),
185: 'url' => $this->getUrl('*/sales_order/pdfshipments'),
186: ));
187:
188: $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
189: 'label'=> Mage::helper('sales')->__('Print Credit Memos'),
190: 'url' => $this->getUrl('*/sales_order/pdfcreditmemos'),
191: ));
192:
193: $this->getMassactionBlock()->addItem('pdfdocs_order', array(
194: 'label'=> Mage::helper('sales')->__('Print All'),
195: 'url' => $this->getUrl('*/sales_order/pdfdocs'),
196: ));
197:
198: $this->getMassactionBlock()->addItem('print_shipping_label', array(
199: 'label'=> Mage::helper('sales')->__('Print Shipping Labels'),
200: 'url' => $this->getUrl('*/sales_order_shipment/massPrintShippingLabel'),
201: ));
202:
203: return $this;
204: }
205:
206: public function getRowUrl($row)
207: {
208: if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
209: return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
210: }
211: return false;
212: }
213:
214: public function getGridUrl()
215: {
216: return $this->getUrl('*/*/grid', array('_current'=>true));
217: }
218:
219: }
220: