*/ class Mage_Adminhtml_Block_Sales_Order_Create_Form_Account extends Mage_Adminhtml_Block_Sales_Order_Create_Form_Abstract { /** * Return Header CSS Class * * @return string */ public function getHeaderCssClass() { return 'head-account'; } /** * Return header text * * @return string */ public function getHeaderText() { return Mage::helper('sales')->__('Account Information'); } /** * Prepare Form and add elements to form * * @return Mage_Adminhtml_Block_Sales_Order_Create_Form_Account */ protected function _prepareForm() { /* @var $customerModel Mage_Customer_Model_Customer */ $customerModel = Mage::getModel('customer/customer'); /* @var $customerForm Mage_Customer_Model_Form */ $customerForm = Mage::getModel('customer/form'); $customerForm->setFormCode('adminhtml_checkout') ->setStore($this->getStore()) ->setEntity($customerModel); // prepare customer attributes to show $attributes = array(); // add system required attributes foreach ($customerForm->getSystemAttributes() as $attribute) { /* @var $attribute Mage_Customer_Model_Attribute */ if ($attribute->getIsRequired()) { $attributes[$attribute->getAttributeCode()] = $attribute; } } if ($this->getQuote()->getCustomerIsGuest()) { unset($attributes['group_id']); } // add user defined attributes foreach ($customerForm->getUserAttributes() as $attribute) { /* @var $attribute Mage_Customer_Model_Attribute */ $attributes[$attribute->getAttributeCode()] = $attribute; } $fieldset = $this->_form->addFieldset('main', array()); $this->_addAttributesToForm($attributes, $fieldset); $this->_form->addFieldNameSuffix('order[account]'); $this->_form->setValues($this->getFormValues()); return $this; } /** * Add additional data to form element * * @param Varien_Data_Form_Element_Abstract $element * @return Mage_Adminhtml_Block_Sales_Order_Create_Form_Abstract */ protected function _addAdditionalFormElementData(Varien_Data_Form_Element_Abstract $element) { switch ($element->getId()) { case 'email': $element->setRequired(0); $element->setClass('validate-email'); break; } return $this; } /** * Return customer data * * @deprecated since 1.4.0.1 * @return array */ public function getCustomerData() { return $this->getFormValues(); } /** * Return Form Elements values * * @return array */ public function getFormValues() { $data = $this->getCustomer()->getData(); foreach ($this->getQuote()->getData() as $key => $value) { if (strpos($key, 'customer_') === 0) { $data[substr($key, 9)] = $value; } } if ($this->getQuote()->getCustomerEmail()) { $data['email'] = $this->getQuote()->getCustomerEmail(); } return $data; } }