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_Info extends Mage_Adminhtml_Block_Sales_Order_Abstract
35: {
36: 37: 38:
39: protected function _beforeToHtml()
40: {
41: if (!$this->getParentBlock()) {
42: Mage::throwException(Mage::helper('adminhtml')->__('Invalid parent block for this block.'));
43: }
44: $this->setOrder($this->getParentBlock()->getOrder());
45:
46: foreach ($this->getParentBlock()->getOrderInfoData() as $k => $v) {
47: $this->setDataUsingMethod($k, $v);
48: }
49:
50: parent::_beforeToHtml();
51: }
52:
53: public function getOrderStoreName()
54: {
55: if ($this->getOrder()) {
56: $storeId = $this->getOrder()->getStoreId();
57: if (is_null($storeId)) {
58: $deleted = Mage::helper('adminhtml')->__(' [deleted]');
59: return nl2br($this->getOrder()->getStoreName()) . $deleted;
60: }
61: $store = Mage::app()->getStore($storeId);
62: $name = array(
63: $store->getWebsite()->getName(),
64: $store->getGroup()->getName(),
65: $store->getName()
66: );
67: return implode('<br/>', $name);
68: }
69: return null;
70: }
71:
72: public function getCustomerGroupName()
73: {
74: if ($this->getOrder()) {
75: return Mage::getModel('customer/group')->load((int)$this->getOrder()->getCustomerGroupId())->getCode();
76: }
77: return null;
78: }
79:
80: public function getCustomerViewUrl()
81: {
82: if ($this->getOrder()->getCustomerIsGuest() || !$this->getOrder()->getCustomerId()) {
83: return false;
84: }
85: return $this->getUrl('*/customer/edit', array('id' => $this->getOrder()->getCustomerId()));
86: }
87:
88: public function getViewUrl($orderId)
89: {
90: return $this->getUrl('*/sales_order/view', array('order_id'=>$orderId));
91: }
92:
93: 94: 95: 96: 97: 98: 99: 100:
101: protected function _prepareAccountDataSortOrder(array $data, $sortOrder)
102: {
103: if (isset($data[$sortOrder])) {
104: return $this->_prepareAccountDataSortOrder($data, $sortOrder + 1);
105: }
106: return $sortOrder;
107: }
108:
109: 110: 111: 112: 113: 114:
115: public function getCustomerAccountData()
116: {
117: $accountData = array();
118:
119:
120: $config = Mage::getSingleton('eav/config');
121: $entityType = 'customer';
122: $customer = Mage::getModel('customer/customer');
123: foreach ($config->getEntityAttributeCodes($entityType) as $attributeCode) {
124:
125: $attribute = $config->getAttribute($entityType, $attributeCode);
126: if (!$attribute->getIsVisible() || $attribute->getIsSystem()) {
127: continue;
128: }
129: $orderKey = sprintf('customer_%s', $attribute->getAttributeCode());
130: $orderValue = $this->getOrder()->getData($orderKey);
131: if ($orderValue != '') {
132: $customer->setData($attribute->getAttributeCode(), $orderValue);
133: $dataModel = Mage_Customer_Model_Attribute_Data::factory($attribute, $customer);
134: $value = $dataModel->outputValue(Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_HTML);
135: $sortOrder = $attribute->getSortOrder() + $attribute->getIsUserDefined() ? 200 : 0;
136: $sortOrder = $this->_prepareAccountDataSortOrder($accountData, $sortOrder);
137: $accountData[$sortOrder] = array(
138: 'label' => $attribute->getFrontendLabel(),
139: 'value' => $this->escapeHtml($value, array('br'))
140: );
141: }
142: }
143:
144: ksort($accountData, SORT_NUMERIC);
145:
146: return $accountData;
147: }
148:
149: 150: 151: 152: 153: 154: 155:
156: public function getAddressEditLink($address, $label='')
157: {
158: if (empty($label)) {
159: $label = $this->__('Edit');
160: }
161: $url = $this->getUrl('*/sales_order/address', array('address_id'=>$address->getId()));
162: return '<a href="'.$url.'">' . $label . '</a>';
163: }
164:
165: 166: 167: 168:
169: public function shouldDisplayCustomerIp()
170: {
171: return !Mage::getStoreConfigFlag('sales/general/hide_customer_ip', $this->getOrder()->getStoreId());
172: }
173: }
174: