Mage_Adminhtml_Block_Sales_Order_Create_Form_Account Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Sales_Order_Create_Form_Account:

Mage_Adminhtml_Block_Sales_Order_Create_Abstract Mage_Adminhtml_Block_Widget Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 getHeaderCssClass ()
 getHeaderText ()
 getForm ()
 _sortMethods ($a, $b)
 getDisplayFields ()
 getCustomerData ()

Protected Member Functions

 _prepareLayout ()
 _prepareForm ()

Protected Attributes

 $_form


Detailed Description

Create order account form

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 32 of file Account.php.


Member Function Documentation

_prepareForm (  )  [protected]

Definition at line 65 of file Account.php.

00066     {
00067         if (!$this->_form) {
00068 
00069             $display = $this->getDisplayFields();
00070 
00071             $this->_form = new Varien_Data_Form();
00072             $fieldset = $this->_form->addFieldset('main', array());
00073             $customerModel = Mage::getModel('customer/customer');
00074 
00075             foreach ($customerModel->getAttributes() as $attribute) {
00076                 if (!array_key_exists($attribute->getAttributeCode(), $display)) {
00077                     continue;
00078                 }
00079 
00080                 if ($inputType = $attribute->getFrontend()->getInputType()) {
00081                     $field = $display[$attribute->getAttributeCode()];
00082                     $element = $fieldset->addField($attribute->getAttributeCode(), $inputType,
00083                         array(
00084                             'name'      => $attribute->getAttributeCode(),
00085                             'label'     => $attribute->getFrontend()->getLabel(),
00086                             'class'     => isset($field['class']) ? $field['class'] : $attribute->getFrontend()->getClass(),
00087                             'required'  => isset($field['required']) ? $field['required'] : $attribute->getIsRequired(),
00088                         )
00089                     )
00090                     ->setEntityAttribute($attribute)
00091                     ;
00092 
00093                     if ($inputType == 'select' || $inputType == 'multiselect') {
00094                         $element->setValues($attribute->getFrontend()->getSelectOptions());
00095                     }
00096                     $element->setSortOrder($display[$attribute->getAttributeCode()]);
00097                 }
00098             }
00099 
00100             /*
00101             * want to sort element only when there are more than one element
00102             */
00103             if ($fieldset->getElements()->count()>1) {
00104                 $fieldset->getElements()->usort(array($this, '_sortMethods'));
00105             }
00106 
00107             $this->_form->addFieldNameSuffix('order[account]');
00108             $this->_form->setValues($this->getCustomerData());
00109         }
00110         return $this;
00111     }

_prepareLayout (  )  [protected]

Preparing global layout

You can redefine this method in child classes for changin layout

Returns:
Mage_Core_Block_Abstract

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 36 of file Account.php.

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     }

_sortMethods ( a,
b 
)

Definition at line 113 of file Account.php.

00114     {
00115         if (is_object($a)) {
00116             return (int)$a->sort_order < (int)$b->sort_order ? -1 : ((int)$a->sort_order > (int)$b->sort_order ? 1 : 0);
00117         }
00118         return 0;
00119     }

getCustomerData (  ) 

Definition at line 147 of file Account.php.

00148     {
00149         $data = $this->getCustomer()->getData();
00150         foreach ($this->getQuote()->getData() as $key=>$value) {
00151             if (strstr($key, 'customer_')) {
00152                 $data[str_replace('customer_', '', $key)] = $value;
00153             }
00154         }
00155         $data['group_id'] = $this->getCreateOrderModel()->getCustomerGroupId();
00156         $data['email'] = ($this->getQuote()->getCustomerEmail() ? $this->getQuote()->getCustomerEmail() :$this->getCustomer()->getData('email'));
00157         return $data;
00158     }

getDisplayFields (  ) 

Return new customer account fields for order

Returns:
array

Definition at line 126 of file Account.php.

00127     {
00128         $fields = array(
00129             'group_id' => array(
00130                 'order' => 1
00131             ),
00132             'email' => array(
00133                 'order' => 2,
00134                 'class' => 'validate-email',
00135                 'required' => false
00136             ),
00137         );
00138 
00139         if ($this->getQuote()->getCustomerIsGuest()) {
00140             unset($fields['group_id']);
00141         }
00142 
00143         return $fields;
00144     }

getForm (  ) 

Definition at line 59 of file Account.php.

00060     {
00061         $this->_prepareForm();
00062         return $this->_form;
00063     }

getHeaderCssClass (  ) 

Definition at line 49 of file Account.php.

00050     {
00051         return 'head-account';
00052     }

getHeaderText (  ) 

Definition at line 54 of file Account.php.

00055     {
00056         return Mage::helper('sales')->__('Account Information');
00057     }


Member Data Documentation

$_form [protected]

Definition at line 34 of file Account.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:22:59 2009 for Magento by  doxygen 1.5.8