1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Adminhtml
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * Shipment view form
29: *
30: * @category Mage
31: * @package Mage_Adminhtml
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Adminhtml_Block_Sales_Order_Shipment_View_Form extends Mage_Adminhtml_Block_Sales_Order_Abstract
35: {
36: /**
37: * Retrieve shipment model instance
38: *
39: * @return Mage_Sales_Model_Order_Shipment
40: */
41: public function getShipment()
42: {
43: return Mage::registry('current_shipment');
44: }
45:
46: /**
47: * Retrieve invoice order
48: *
49: * @return Mage_Sales_Model_Order
50: */
51: public function getOrder()
52: {
53: return $this->getShipment()->getOrder();
54: }
55:
56: /**
57: * Retrieve source
58: *
59: * @return Mage_Sales_Model_Order_Shipment
60: */
61: public function getSource()
62: {
63: return $this->getShipment();
64: }
65:
66: /**
67: * Get create label button html
68: *
69: * @return string
70: */
71: public function getCreateLabelButton()
72: {
73: $data['shipment_id'] = $this->getShipment()->getId();
74: $url = $this->getUrl('*/sales_order_shipment/createLabel', $data);
75: return $this->getLayout()
76: ->createBlock('adminhtml/widget_button')
77: ->setData(array(
78: 'label' => Mage::helper('sales')->__('Create Shipping Label...'),
79: 'onclick' => 'packaging.showWindow();',
80: ))
81: ->toHtml();
82: }
83:
84: /**
85: * Get print label button html
86: *
87: * @return string
88: */
89: public function getPrintLabelButton()
90: {
91: $data['shipment_id'] = $this->getShipment()->getId();
92: $url = $this->getUrl('*/sales_order_shipment/printLabel', $data);
93: return $this->getLayout()
94: ->createBlock('adminhtml/widget_button')
95: ->setData(array(
96: 'label' => Mage::helper('sales')->__('Print Shipping Label'),
97: 'onclick' => 'setLocation(\'' . $url . '\')'
98: ))
99: ->toHtml();
100: }
101:
102: /**
103: * Show packages button html
104: *
105: * @return string
106: */
107: public function getShowPackagesButton()
108: {
109: return $this->getLayout()
110: ->createBlock('adminhtml/widget_button')
111: ->setData(array(
112: 'label' => Mage::helper('sales')->__('Show Packages'),
113: 'onclick' => 'showPackedWindow();'
114: ))
115: ->toHtml();
116: }
117:
118: /**
119: * Check is carrier has functionality of creation shipping labels
120: *
121: * @return bool
122: */
123: public function canCreateShippingLabel()
124: {
125: $shippingCarrier = $this->getOrder()->getShippingCarrier();
126: return $shippingCarrier && $shippingCarrier->isShippingLabelsAvailable();
127: }
128: }
129: