Mage_Adminhtml_Block_Sales_Order_Create_Giftmessage_Form Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Sales_Order_Create_Giftmessage_Form:

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

 setEntity (Varien_Object $entity)
 getEntity ()
 getDefaultSender ()
 getDefaultRecipient ()
 _prepareForm ()
 getMessage ()

Protected Member Functions

 _getSession ()
 _initMessage ()
 _getFieldName ($name)
 _getFieldId ($id)
 _getFieldIdPrefix ()
 _applyPostData ()

Protected Attributes

 $_entity
 $_giftMessage


Detailed Description

Definition at line 35 of file Form.php.


Member Function Documentation

_applyPostData (  )  [protected]

Aplies posted data to gift message

Returns:
Mage_Adminhtml_Block_Sales_Order_Create_Giftmessage_Form

Definition at line 259 of file Form.php.

00260     {
00261         if(is_array($giftmessages = $this->getRequest()->getParam('giftmessage'))
00262            && isset($giftmessages[$this->getEntity()->getId()])) {
00263             $this->getMessage()->addData($giftmessages[$this->getEntity()->getId()]);
00264         }
00265 
00266         return $this;
00267     }

_getFieldId ( id  )  [protected]

Retrive real html id for field

Parameters:
string $name
Returns:
string

Definition at line 239 of file Form.php.

00240     {
00241         return $this->_getFieldIdPrefix() . $id;
00242     }

_getFieldIdPrefix (  )  [protected]

Retrive field html id prefix

Returns:
unknown

Definition at line 249 of file Form.php.

00250     {
00251         return 'giftmessage_' . $this->getEntity()->getId() . '_';
00252     }

_getFieldName ( name  )  [protected]

Retrive real name for field

Parameters:
string $name
Returns:
string

Definition at line 228 of file Form.php.

00229     {
00230         return 'giftmessage[' . $this->getEntity()->getId() . '][' . $name . ']';
00231     }

_getSession (  )  [protected]

Definition at line 73 of file Form.php.

00074     {
00075         return Mage::getSingleton('adminhtml/session_quote');
00076     }

_initMessage (  )  [protected]

Initialize gift message for entity

Returns:
Mage_Adminhtml_Block_Sales_Order_Create_Giftmessage_Form

Definition at line 200 of file Form.php.

00201     {
00202         $this->_giftMessage = $this->helper('giftmessage/message')->getGiftMessage(
00203                                    $this->getEntity()->getGiftMessageId()
00204                               );
00205         return $this;
00206     }

_prepareForm (  ) 

Prepares form

Returns:
Mage_Adminhtml_Block_Sales_Order_Create_Giftmessage_Form

Reimplemented from Mage_Adminhtml_Block_Widget_Form.

Definition at line 135 of file Form.php.

00136     {
00137         $form = new Varien_Data_Form();
00138         $fieldset = $form->addFieldset('main', array('no_container'=>true));
00139 
00140         $fieldset->addField('type','hidden',
00141             array(
00142                 'name' =>  $this->_getFieldName('type'),
00143             )
00144         );
00145 
00146         $form->setHtmlIdPrefix($this->_getFieldIdPrefix());
00147 
00148         $fieldset->addField('sender','text',
00149             array(
00150                 'name'  =>  $this->_getFieldName('sender'),
00151                 'label' =>  Mage::helper('sales')->__('From'),
00152                 'class' =>  $this->getMessage()->getMessage() ? 'required-entry' : ''
00153             )
00154         );
00155         $fieldset->addField('recipient','text',
00156             array(
00157                 'name'  =>  $this->_getFieldName('recipient'),
00158                 'label' =>  Mage::helper('sales')->__('To'),
00159                 'class' =>  $this->getMessage()->getMessage() ? 'required-entry' : ''
00160             )
00161         );
00162 
00163         $fieldset->addField('message', 'textarea',
00164             array(
00165                 'name'      =>  $this->_getFieldName('message'),
00166                 'label'     =>  Mage::helper('sales')->__('Message'),
00167                 'rows'      =>  '5',
00168                 'cols'      =>  '20',
00169                 'onchange'  =>  'toogleRequired(\'' . $this->_getFieldId('message')
00170                              .  '\', [\'' . $this->_getFieldId('sender')
00171                              .  '\', \'' . $this->_getFieldId('recipient') . '\']);'
00172             )
00173         );
00174 
00175         // Set default sender and recipient from billing and shipping adresses
00176         if(!$this->getMessage()->getSender()) {
00177             $this->getMessage()->setSender($this->getDefaultSender());
00178         }
00179 
00180         if(!$this->getMessage()->getRecipient()) {
00181             $this->getMessage()->setRecipient($this->getDefaultRecipient());
00182         }
00183 
00184         $this->getMessage()->setType($this->getEntityType());
00185 
00186         // Overriden default data with edited when block reloads througth Ajax
00187         $this->_applyPostData();
00188 
00189         $form->setValues($this->getMessage()->getData());
00190 
00191         $this->setForm($form);
00192         return $this;
00193     }

getDefaultRecipient (  ) 

Retrive default value for giftmessage recipient

Returns:
string

Definition at line 107 of file Form.php.

00108     {
00109         if(!$this->getEntity()) {
00110             return '';
00111         }
00112 
00113         if($this->getEntity()->getOrder()) {
00114             if ($this->getEntity()->getOrder()->getShippingAddress()) {
00115                 return $this->getEntity()->getOrder()->getShippingAddress()->getName();
00116             } else if ($this->getEntity()->getOrder()->getBillingAddress()) {
00117                 return $this->getEntity()->getOrder()->getBillingAddress()->getName();
00118             }
00119         }
00120 
00121         if ($this->getEntity()->getShippingAddress()) {
00122             return $this->getEntity()->getShippingAddress()->getName();
00123         } else if ($this->getEntity()->getBillingAddress()) {
00124             return $this->getEntity()->getBillingAddress()->getName();
00125         }
00126 
00127         return '';
00128     }

getDefaultSender (  ) 

Retrive default value for giftmessage sender

Returns:
string

Definition at line 83 of file Form.php.

00084     {
00085         if(!$this->getEntity()) {
00086             return '';
00087         }
00088 
00089         if($this->_getSession()->getCustomer()->getId()) {
00090             return $this->_getSession()->getCustomer()->getName();
00091         }
00092 
00093         $object = $this->getEntity();
00094 
00095         if ($this->getEntity()->getQuote()) {
00096             $object = $this->getEntity()->getQuote();
00097         }
00098 
00099         return $object->getBillingAddress()->getName();
00100     }

getEntity (  ) 

Retrive entity for form

Returns:
Varien_Object

Definition at line 68 of file Form.php.

00069     {
00070         return $this->_entity;
00071     }

getMessage (  ) 

Retrive gift message for entity

Returns:
Mage_GiftMessage_Model_Message

Definition at line 213 of file Form.php.

00214     {
00215         if(is_null($this->_giftMessage)) {
00216             $this->_initMessage();
00217         }
00218 
00219         return $this->_giftMessage;
00220     }

setEntity ( Varien_Object entity  ) 

Set entity for form

Parameters:
Varien_Object $entity
Returns:
Mage_Adminhtml_Block_Sales_Order_Create_Giftmessage_Form

Definition at line 57 of file Form.php.

00058     {
00059         $this->_entity  = $entity;
00060         return $this;
00061     }


Member Data Documentation

$_entity [protected]

Definition at line 42 of file Form.php.

$_giftMessage [protected]

Definition at line 49 of file Form.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