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: * Adminhtml sales order create sidebar
29: *
30: * @category Mage
31: * @package Mage_Adminhtml
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34:
35: class Mage_Adminhtml_Block_Sales_Order_Create_Form extends Mage_Adminhtml_Block_Sales_Order_Create_Abstract
36: {
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('sales_order_create_form');
41: }
42:
43: /**
44: * Retrieve url for loading blocks
45: * @return string
46: */
47: public function getLoadBlockUrl()
48: {
49: return $this->getUrl('*/*/loadBlock');
50: }
51:
52: /**
53: * Retrieve url for form submiting
54: * @return string
55: */
56: public function getSaveUrl()
57: {
58: return $this->getUrl('*/*/save');
59: }
60:
61: public function getCustomerSelectorDisplay()
62: {
63: $customerId = $this->getCustomerId();
64: if (is_null($customerId)) {
65: return 'block';
66: }
67: return 'none';
68: }
69:
70: public function getStoreSelectorDisplay()
71: {
72: $storeId = $this->getStoreId();
73: $customerId = $this->getCustomerId();
74: if (!is_null($customerId) && !$storeId) {
75: return 'block';
76: }
77: return 'none';
78: }
79:
80: public function getDataSelectorDisplay()
81: {
82: $storeId = $this->getStoreId();
83: $customerId = $this->getCustomerId();
84: if (!is_null($customerId) && $storeId) {
85: return 'block';
86: }
87: return 'none';
88: }
89:
90: public function getOrderDataJson()
91: {
92: $data = array();
93: if (!is_null($this->getCustomerId())) {
94: $data['customer_id'] = $this->getCustomerId();
95: $data['addresses'] = array();
96:
97: /* @var $addressForm Mage_Customer_Model_Form */
98: $addressForm = Mage::getModel('customer/form')
99: ->setFormCode('adminhtml_customer_address')
100: ->setStore($this->getStore());
101: foreach ($this->getCustomer()->getAddresses() as $address) {
102: $data['addresses'][$address->getId()] = $addressForm->setEntity($address)
103: ->outputData(Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_JSON);
104: }
105: }
106: if (!is_null($this->getStoreId())) {
107: $data['store_id'] = $this->getStoreId();
108: $currency = Mage::app()->getLocale()->currency($this->getStore()->getCurrentCurrencyCode());
109: $symbol = $currency->getSymbol() ? $currency->getSymbol() : $currency->getShortName();
110: $data['currency_symbol'] = $symbol;
111: $data['shipping_method_reseted'] = !(bool)$this->getQuote()->getShippingAddress()->getShippingMethod();
112: $data['payment_method'] = $this->getQuote()->getPayment()->getMethod();
113: }
114: return Mage::helper('core')->jsonEncode($data);
115: }
116: }
117: