00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Adminhtml 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 /** 00028 * Order create address form 00029 * 00030 * @author Magento Core Team <core@magentocommerce.com> 00031 */ 00032 class Mage_Adminhtml_Block_Sales_Order_Create_Form_Address extends Mage_Adminhtml_Block_Sales_Order_Create_Abstract 00033 { 00034 protected $_form; 00035 00036 protected function _prepareLayout() 00037 { 00038 Varien_Data_Form::setElementRenderer( 00039 $this->getLayout()->createBlock('adminhtml/widget_form_renderer_element') 00040 ); 00041 Varien_Data_Form::setFieldsetRenderer( 00042 $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset') 00043 ); 00044 Varien_Data_Form::setFieldsetElementRenderer( 00045 $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset_element') 00046 ); 00047 } 00048 00049 public function getAddressCollection() 00050 { 00051 return $this->getCustomer()->getAddresses(); 00052 } 00053 00054 public function getAddressCollectionJson() 00055 { 00056 $data = array(); 00057 foreach ($this->getAddressCollection() as $address) { 00058 $data[$address->getId()] = $address->getData(); 00059 } 00060 return Zend_Json::encode($data); 00061 } 00062 00063 public function getForm() 00064 { 00065 $this->_prepareForm(); 00066 return $this->_form; 00067 } 00068 00069 protected function _prepareForm() 00070 { 00071 if (!$this->_form) { 00072 $this->_form = new Varien_Data_Form(); 00073 $fieldset = $this->_form->addFieldset('main', array('no_container'=>true)); 00074 $addressModel = Mage::getModel('customer/address'); 00075 00076 foreach ($addressModel->getAttributes() as $attribute) { 00077 if (!$attribute->getIsVisible()) { 00078 continue; 00079 } 00080 if ($inputType = $attribute->getFrontend()->getInputType()) { 00081 $element = $fieldset->addField($attribute->getAttributeCode(), $inputType, 00082 array( 00083 'name' => $attribute->getAttributeCode(), 00084 'label' => $this->__($attribute->getFrontend()->getLabel()), 00085 'class' => $attribute->getFrontend()->getClass(), 00086 'required' => $attribute->getIsRequired(), 00087 ) 00088 ) 00089 ->setEntityAttribute($attribute); 00090 00091 if ($inputType == 'select' || $inputType == 'multiselect') { 00092 $element->setValues($attribute->getFrontend()->getSelectOptions()); 00093 } 00094 } 00095 } 00096 00097 if ($regionElement = $this->_form->getElement('region')) { 00098 $regionElement->setRenderer( 00099 $this->getLayout()->createBlock('adminhtml/customer_edit_renderer_region') 00100 ); 00101 } 00102 if ($regionElement = $this->_form->getElement('region_id')) { 00103 $regionElement->setNoDisplay(true); 00104 } 00105 $this->_form->setValues($this->getFormValues()); 00106 } 00107 return $this; 00108 } 00109 00110 public function getFormValues() 00111 { 00112 return array(); 00113 } 00114 00115 public function getAddressId() 00116 { 00117 return false; 00118 } 00119 00120 public function getAddressAsString($address) 00121 { 00122 return $address->format('oneline'); 00123 } 00124 }