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 |
Definition at line 35 of file Form.php.
_applyPostData | ( | ) | [protected] |
Aplies posted data to gift message
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
string | $name |
Definition at line 239 of file Form.php.
00240 { 00241 return $this->_getFieldIdPrefix() . $id; 00242 }
_getFieldIdPrefix | ( | ) | [protected] |
_getFieldName | ( | $ | name | ) | [protected] |
_getSession | ( | ) | [protected] |
Definition at line 73 of file Form.php.
00074 { 00075 return Mage::getSingleton('adminhtml/session_quote'); 00076 }
_initMessage | ( | ) | [protected] |
_prepareForm | ( | ) |
Prepares 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
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
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 | ( | ) |
getMessage | ( | ) |
Retrive gift message for entity
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 | ) |