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_GiftMessage
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: * Gift message adminhtml sales order create items
29: *
30: * @category Mage
31: * @package Mage_GiftMessage
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_GiftMessage_Block_Adminhtml_Sales_Order_Create_Items extends Mage_Adminhtml_Block_Template
35: {
36: /**
37: * Get order item
38: *
39: * @return Mage_Sales_Model_Quote_Item
40: */
41: public function getItem()
42: {
43: return $this->getParentBlock()->getItem();
44: }
45:
46: /**
47: * Indicates that block can display gift messages form
48: *
49: * @return boolean
50: */
51: public function canDisplayGiftMessage()
52: {
53: $item = $this->getItem();
54: if (!$item) {
55: return false;
56: }
57: return $this->helper('giftmessage/message')->getIsMessagesAvailable(
58: 'item', $item, $item->getStoreId()
59: );
60: }
61:
62: /**
63: * Return form html
64: *
65: * @return string
66: */
67: public function getFormHtml()
68: {
69: return $this->getLayout()->createBlock('adminhtml/sales_order_create_giftmessage_form')
70: ->setEntity($this->getItem())
71: ->setEntityType('item')
72: ->toHtml();
73: }
74:
75: /**
76: * Retrieve gift message for item
77: *
78: * @return string
79: */
80: public function getMessageText()
81: {
82: if ($this->getItem()->getGiftMessageId()) {
83: $model = $this->helper('giftmessage/message')->getGiftMessage($this->getItem()->getGiftMessageId());
84: return $this->htmlEscape($model->getMessage());
85: }
86: return '';
87: }
88: }
89: