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_Shipments
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_shipments');
42: $this->setUseAjax(true);
43: }
44:
45: 46: 47: 48: 49:
50: protected function _getCollectionClass()
51: {
52: return 'sales/order_shipment_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('increment_id')
61: ->addFieldToSelect('total_qty')
62: ->addFieldToSelect('shipping_name')
63: ->setOrderFilter($this->getOrder())
64: ;
65: $this->setCollection($collection);
66: return parent::_prepareCollection();
67: }
68:
69: protected function _prepareColumns()
70: {
71: $this->addColumn('increment_id', array(
72: 'header' => Mage::helper('sales')->__('Shipment #'),
73: 'index' => 'increment_id',
74: ));
75:
76: $this->addColumn('shipping_name', array(
77: 'header' => Mage::helper('sales')->__('Ship to Name'),
78: 'index' => 'shipping_name',
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('total_qty', array(
88: 'header' => Mage::helper('sales')->__('Total Qty'),
89: 'index' => 'total_qty',
90: 'type' => 'number',
91: ));
92:
93: return parent::_prepareColumns();
94: }
95:
96: 97: 98: 99: 100:
101: public function getOrder()
102: {
103: return Mage::registry('current_order');
104: }
105:
106: public function getRowUrl($row)
107: {
108: return $this->getUrl(
109: '*/sales_order_shipment/view',
110: array(
111: 'shipment_id'=> $row->getId(),
112: 'order_id' => $row->getOrderId()
113: ));
114: }
115:
116: public function getGridUrl()
117: {
118: return $this->getUrl('*/*/shipments', array('_current' => true));
119: }
120:
121: 122: 123:
124: public function getTabLabel()
125: {
126: return Mage::helper('sales')->__('Shipments');
127: }
128:
129: public function getTabTitle()
130: {
131: return Mage::helper('sales')->__('Order Shipments');
132: }
133:
134: public function canShowTab()
135: {
136: if ($this->getOrder()->getIsVirtual()) {
137: return false;
138: }
139: return true;
140: }
141:
142: public function isHidden()
143: {
144: return false;
145: }
146: }
147: