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_Shipment_Grid extends Mage_Adminhtml_Block_Widget_Grid
33: {
34:
35: 36: 37:
38: public function __construct()
39: {
40: parent::__construct();
41: $this->setId('sales_shipment_grid');
42: $this->setDefaultSort('created_at');
43: $this->setDefaultDir('DESC');
44: }
45:
46: 47: 48: 49: 50:
51: protected function _getCollectionClass()
52: {
53: return 'sales/order_shipment_grid_collection';
54: }
55:
56: 57: 58: 59: 60:
61: protected function _prepareCollection()
62: {
63: $collection = Mage::getResourceModel($this->_getCollectionClass());
64: $this->setCollection($collection);
65: return parent::_prepareCollection();
66: }
67:
68: 69: 70: 71: 72:
73: protected function _prepareColumns()
74: {
75: $this->addColumn('increment_id', array(
76: 'header' => Mage::helper('sales')->__('Shipment #'),
77: 'index' => 'increment_id',
78: 'type' => 'text',
79: ));
80:
81: $this->addColumn('created_at', array(
82: 'header' => Mage::helper('sales')->__('Date Shipped'),
83: 'index' => 'created_at',
84: 'type' => 'datetime',
85: ));
86:
87: $this->addColumn('order_increment_id', array(
88: 'header' => Mage::helper('sales')->__('Order #'),
89: 'index' => 'order_increment_id',
90: 'type' => 'text',
91: ));
92:
93: $this->addColumn('order_created_at', array(
94: 'header' => Mage::helper('sales')->__('Order Date'),
95: 'index' => 'order_created_at',
96: 'type' => 'datetime',
97: ));
98:
99: $this->addColumn('shipping_name', array(
100: 'header' => Mage::helper('sales')->__('Ship to Name'),
101: 'index' => 'shipping_name',
102: ));
103:
104: $this->addColumn('total_qty', array(
105: 'header' => Mage::helper('sales')->__('Total Qty'),
106: 'index' => 'total_qty',
107: 'type' => 'number',
108: ));
109:
110: $this->addColumn('action',
111: array(
112: 'header' => Mage::helper('sales')->__('Action'),
113: 'width' => '50px',
114: 'type' => 'action',
115: 'getter' => 'getId',
116: 'actions' => array(
117: array(
118: 'caption' => Mage::helper('sales')->__('View'),
119: 'url' => array('base'=>'*/sales_shipment/view'),
120: 'field' => 'shipment_id'
121: )
122: ),
123: 'filter' => false,
124: 'sortable' => false,
125: 'is_system' => true
126: ));
127:
128: $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
129: $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
130:
131: return parent::_prepareColumns();
132: }
133:
134: 135: 136: 137: 138: 139:
140: public function getRowUrl($row)
141: {
142: if (!Mage::getSingleton('admin/session')->isAllowed('sales/order/shipment')) {
143: return false;
144: }
145:
146: return $this->getUrl('*/sales_shipment/view',
147: array(
148: 'shipment_id'=> $row->getId(),
149: )
150: );
151: }
152:
153: 154: 155: 156: 157:
158: protected function _prepareMassaction()
159: {
160: $this->setMassactionIdField('entity_id');
161: $this->getMassactionBlock()->setFormFieldName('shipment_ids');
162: $this->getMassactionBlock()->setUseSelectAll(false);
163:
164: $this->getMassactionBlock()->addItem('pdfshipments_order', array(
165: 'label'=> Mage::helper('sales')->__('PDF Packingslips'),
166: 'url' => $this->getUrl('*/sales_shipment/pdfshipments'),
167: ));
168:
169: $this->getMassactionBlock()->addItem('print_shipping_label', array(
170: 'label'=> Mage::helper('sales')->__('Print Shipping Labels'),
171: 'url' => $this->getUrl('*/sales_order_shipment/massPrintShippingLabel'),
172: ));
173:
174: return $this;
175: }
176:
177: 178: 179: 180: 181:
182: public function getGridUrl()
183: {
184: return $this->getUrl('*/*/*', array('_current' => true));
185: }
186:
187: }
188: