Mage_Adminhtml_Block_Customer_Edit_Tab_Account Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Customer_Edit_Tab_Account:

Mage_Adminhtml_Block_Widget_Form 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

 __construct ()
 initForm ()


Detailed Description

Definition at line 34 of file Account.php.


Constructor & Destructor Documentation

__construct (  ) 

Class constructor

Reimplemented from Mage_Adminhtml_Block_Widget_Form.

Definition at line 36 of file Account.php.

00037     {
00038         parent::__construct();
00039     }


Member Function Documentation

initForm (  ) 

Definition at line 41 of file Account.php.

00042     {
00043         $form = new Varien_Data_Form();
00044         $form->setHtmlIdPrefix('_account');
00045         $form->setFieldNameSuffix('account');
00046 
00047         $customer = Mage::registry('current_customer');
00048 
00049         $fieldset = $form->addFieldset('base_fieldset',
00050             array('legend'=>Mage::helper('customer')->__('Account Information'))
00051         );
00052 
00053 
00054         $this->_setFieldset($customer->getAttributes(), $fieldset);
00055 
00056         if ($customer->getId()) {
00057             $form->getElement('website_id')->setDisabled('disabled');
00058             $form->getElement('created_in')->setDisabled('disabled');
00059         } else {
00060             $fieldset->removeField('created_in');
00061         }
00062 
00063         $form->getElement('email')->addClass('validate-email');
00064 
00065 //        if (Mage::app()->isSingleStoreMode()) {
00066 //            $fieldset->removeField('website_id');
00067 //            $fieldset->addField('website_id', 'hidden', array(
00068 //                'name'      => 'website_id'
00069 //            ));
00070 //            $customer->setWebsiteId(Mage::app()->getStore(true)->getWebsiteId());
00071 //        }
00072 
00073         if ($customer->getId()) {
00074             if (!$customer->isReadonly()) {
00075                 // add password management fieldset
00076                 $newFieldset = $form->addFieldset(
00077                     'password_fieldset',
00078                     array('legend'=>Mage::helper('customer')->__('Password Management'))
00079                 );
00080                 // New customer password
00081                 $field = $newFieldset->addField('new_password', 'text',
00082                     array(
00083                         'label' => Mage::helper('customer')->__('New Password'),
00084                         'name'  => 'new_password',
00085                         'class' => 'validate-new-password'
00086                     )
00087                 );
00088                 $field->setRenderer($this->getLayout()->createBlock('adminhtml/customer_edit_renderer_newpass'));
00089 
00090                 // prepare customer confirmation control (only for existing customers)
00091                 $confirmationKey = $customer->getConfirmation();
00092                 if ($confirmationKey || $customer->isConfirmationRequired()) {
00093                     $confirmationAttribute = $customer->getAttribute('confirmation');
00094                     if (!$confirmationKey) {
00095                         $confirmationKey = $customer->getRandomConfirmationKey();
00096                     }
00097                     $element = $fieldset->addField('confirmation', 'select', array(
00098                         'name'  => 'confirmation',
00099                         'label' => Mage::helper('customer')->__($confirmationAttribute->getFrontendLabel()),
00100                     ))->setEntityAttribute($confirmationAttribute)
00101                         ->setValues(array('' => 'Confirmed', $confirmationKey => 'Not confirmed'));
00102 
00103                     // prepare send welcome email checkbox, if customer is not confirmed
00104                     // no need to add it, if website id is empty
00105                     if ($customer->getConfirmation() && $customer->getWebsiteId()) {
00106                         $fieldset->addField('sendemail', 'checkbox', array(
00107                             'name'  => 'sendemail',
00108                             'label' => Mage::helper('customer')->__('Send Welcome Email after Confirmation')
00109                         ));
00110                     }
00111                 }
00112             }
00113         }
00114         else {
00115             $newFieldset = $form->addFieldset(
00116                 'password_fieldset',
00117                 array('legend'=>Mage::helper('customer')->__('Password Management'))
00118             );
00119             $field = $newFieldset->addField('password', 'text',
00120                 array(
00121                     'label' => Mage::helper('customer')->__('Password'),
00122                     'class' => 'input-text required-entry validate-password',
00123                     'name'  => 'password',
00124                     'required' => true
00125                 )
00126             );
00127             $field->setRenderer($this->getLayout()->createBlock('adminhtml/customer_edit_renderer_newpass'));
00128 
00129             // prepare send welcome email checkbox
00130             $fieldset->addField('sendemail', 'checkbox', array(
00131                 'label' => Mage::helper('customer')->__('Send welcome email'),
00132                 'name'  => 'sendemail',
00133                 'id'    => 'sendemail',
00134             ));
00135         }
00136 
00137         // make sendemail disabled, if website_id has empty value
00138         if ($sendemail = $form->getElement('sendemail')) {
00139             $prefix = $form->getHtmlIdPrefix();
00140             $sendemail->setAfterElementHtml(
00141                 '<script type="text/javascript">'
00142                 . "
00143                 $('{$prefix}website_id').disableSendemail = function() {
00144                     $('{$prefix}sendemail').disabled = ('' == this.value || '0' == this.value);
00145                 }.bind($('{$prefix}website_id'));
00146                 Event.observe('{$prefix}website_id', 'click', $('{$prefix}website_id').disableSendemail);
00147                 $('{$prefix}website_id').disableSendemail();
00148                 "
00149                 . '</script>'
00150             );
00151         }
00152 
00153         if ($customer->isReadonly()) {
00154             foreach ($customer->getAttributes() as $attribute) {
00155                 $element = $form->getElement($attribute->getAttributeCode());
00156                 if ($element) {
00157                     $element->setReadonly(true, true);
00158                 }
00159             }
00160         }
00161 
00162         $form->setValues($customer->getData());
00163         $this->setForm($form);
00164         return $this;
00165     }


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

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