00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Adminhtml_Block_Sales_Order_View_Tab_Shipments
00035 extends Mage_Adminhtml_Block_Widget_Grid
00036 implements Mage_Adminhtml_Block_Widget_Tab_Interface
00037 {
00038 public function __construct()
00039 {
00040 parent::__construct();
00041 $this->setId('order_shipments_grid');
00042 $this->setUseAjax(true);
00043 }
00044
00045 protected function _prepareCollection()
00046 {
00047
00048 $collection = Mage::getResourceModel('sales/order_shipment_collection')
00049 ->addAttributeToSelect('increment_id')
00050 ->addAttributeToSelect('created_at')
00051 ->addAttributeToSelect('total_qty')
00052 ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')
00053 ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')
00054 ->addExpressionAttributeToSelect('shipping_name',
00055 'CONCAT({{shipping_firstname}}, " ", {{shipping_lastname}})',
00056 array('shipping_firstname', 'shipping_lastname'))
00057 ->setOrderFilter($this->getOrder())
00058 ;
00059 $this->setCollection($collection);
00060 return parent::_prepareCollection();
00061 }
00062
00063 protected function _prepareColumns()
00064 {
00065 $this->addColumn('increment_id', array(
00066 'header' => Mage::helper('sales')->__('Shipment #'),
00067 'index' => 'increment_id',
00068 ));
00069
00070 $this->addColumn('shipping_name', array(
00071 'header' => Mage::helper('sales')->__('Ship to Name'),
00072 'index' => 'shipping_name',
00073 ));
00074
00075 $this->addColumn('created_at', array(
00076 'header' => Mage::helper('sales')->__('Date Shipped'),
00077 'index' => 'created_at',
00078 'type' => 'datetime',
00079 ));
00080
00081 $this->addColumn('total_qty', array(
00082 'header' => Mage::helper('sales')->__('Total Qty'),
00083 'index' => 'total_qty',
00084 'type' => 'number',
00085 ));
00086
00087 return parent::_prepareColumns();
00088 }
00089
00090
00091
00092
00093
00094
00095 public function getOrder()
00096 {
00097 return Mage::registry('current_order');
00098 }
00099
00100 public function getRowUrl($row)
00101 {
00102 return $this->getUrl(
00103 '*/sales_order_shipment/view',
00104 array(
00105 'shipment_id'=> $row->getId(),
00106 'order_id' => $row->getOrderId()
00107 ));
00108 }
00109
00110 public function getGridUrl()
00111 {
00112 return $this->getUrl('*/*/shipments', array('_current' => true));
00113 }
00114
00115
00116
00117
00118 public function getTabLabel()
00119 {
00120 return Mage::helper('sales')->__('Shipments');
00121 }
00122
00123 public function getTabTitle()
00124 {
00125 return Mage::helper('sales')->__('Order Shipments');
00126 }
00127
00128 public function canShowTab()
00129 {
00130 if ($this->getOrder()->getIsVirtual()) {
00131 return false;
00132 }
00133 return true;
00134 }
00135
00136 public function isHidden()
00137 {
00138 return false;
00139 }
00140 }