Mage_Adminhtml_Block_Tax_Rate_Form Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Tax_Rate_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

 __construct ()

Protected Member Functions

 _prepareForm ()

Protected Attributes

 $_titles = null


Detailed Description

Definition at line 35 of file Form.php.


Constructor & Destructor Documentation

__construct (  ) 

Class constructor

Reimplemented from Mage_Adminhtml_Block_Widget_Form.

Definition at line 39 of file Form.php.

00040     {
00041         parent::__construct();
00042         $this->setDestElementId('rate_form');
00043         $this->setTemplate('tax/rate/form.phtml');
00044     }


Member Function Documentation

_prepareForm (  )  [protected]

Prepare form before rendering HTML

Returns:
Mage_Adminhtml_Block_Widget_Form

Reimplemented from Mage_Adminhtml_Block_Widget_Form.

Definition at line 46 of file Form.php.

00047     {
00048         $rateId = (int)$this->getRequest()->getParam('rate');
00049         $rateObject = new Varien_Object();
00050         $rateModel  = Mage::getSingleton('tax/calculation_rate');
00051         $rateObject->setData($rateModel->getData());
00052         $form = new Varien_Data_Form();
00053 
00054         $countries = Mage::getModel('adminhtml/system_config_source_country')
00055             ->toOptionArray();
00056         unset($countries[0]);
00057 
00058         $regionCollection = Mage::getModel('directory/region')
00059             ->getCollection()
00060             ->addCountryFilter($rateModel->getTaxCountryId());
00061 
00062         $regions = $regionCollection->toOptionArray();
00063 
00064         if ($regions) {
00065             $regions[0]['label'] = '*';
00066         } else {
00067             $regions = array(array('value'=>'', 'label'=>'*'));
00068         }
00069 
00070         $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('tax')->__('Tax Rate Information')));
00071 
00072         if( $rateObject->getTaxCalculationRateId() > 0 ) {
00073             $fieldset->addField('tax_calculation_rate_id', 'hidden',
00074                 array(
00075                     'name' => "tax_calculation_rate_id",
00076                     'value' => $rateObject->getTaxCalculationRateId()
00077                 )
00078             );
00079         }
00080 
00081         $countryId = $rateObject->getTaxCountryId();
00082         if (!$countryId) {
00083             $countryId = Mage::getStoreConfig('general/country/default');
00084         }
00085 
00086         $fieldset->addField('code', 'text',
00087             array(
00088                 'name' => 'code',
00089                 'label' => Mage::helper('tax')->__('Tax Identifier'),
00090                 'title' => Mage::helper('tax')->__('Tax Identifier'),
00091                 'class' => 'required-entry',
00092                 'value' => $rateModel->getCode(),
00093                 'required' => true,
00094             )
00095         );
00096 
00097         $fieldset->addField('tax_country_id', 'select',
00098             array(
00099                 'name' => 'tax_country_id',
00100                 'label' => Mage::helper('tax')->__('Country'),
00101                 'title' => Mage::helper('tax')->__('Please select Country'),
00102                 'class' => 'required-entry',
00103                 'required' => true,
00104                 'values' => $countries,
00105                 'value' => $countryId,
00106             )
00107         );
00108 
00109         $fieldset->addField('tax_region_id', 'select',
00110             array(
00111                 'name' => 'tax_region_id',
00112                 'label' => Mage::helper('tax')->__('State'),
00113                 'title' => Mage::helper('tax')->__('Please select State'),
00114                 'class' => 'required-entry',
00115                 'required' => true,
00116                 'values' => $regions,
00117                 'value' => $rateObject->getTaxRegionId()
00118             )
00119         );
00120 
00121         /* FIXME!!! {*
00122         $fieldset->addField('tax_county_id', 'select',
00123             array(
00124                 'name' => 'tax_county_id',
00125                 'label' => Mage::helper('tax')->__('County'),
00126                 'title' => Mage::helper('tax')->__('Please select County'),
00127                 'values' => array(
00128                     array(
00129                         'label' => '*',
00130                         'value' => ''
00131                     )
00132                 ),
00133                 'value' => $rateObject->getTaxCountyId()
00134             )
00135         );
00136         } */
00137 
00138         $postcode = $rateObject->getTaxPostcode();
00139         if (!$postcode) {
00140             $postcode = '*';
00141         }
00142 
00143         $fieldset->addField('tax_postcode', 'text',
00144             array(
00145                 'name' => 'tax_postcode',
00146                 'label' => Mage::helper('tax')->__('Zip/Post Code'),
00147                 'value' => $postcode
00148             )
00149         );
00150 
00151         if ($rateObject->getRate()) {
00152             $value = 1*$rateObject->getRate();
00153         } else {
00154             $value = 0;
00155         }
00156         $fieldset->addField('rate', 'text',
00157             array(
00158                 'name' => "rate",
00159                 'label' => Mage::helper('tax')->__('Rate'),
00160                 'title' => Mage::helper('tax')->__('Rate'),
00161                 'value' => number_format($value, 4),
00162                 'required' => true,
00163                 'class' => 'validate-not-negative-number required-entry'
00164             )
00165         );
00166 
00167         $form->setAction($this->getUrl('*/tax_rate/save'));
00168         $form->setUseContainer(true);
00169         $form->setId('rate_form');
00170         $form->setMethod('post');
00171 
00172 
00173         if (!Mage::app()->isSingleStoreMode()) {
00174             $form->addElement(Mage::getBlockSingleton('adminhtml/tax_rate_title_fieldset')->setLegend(Mage::helper('tax')->__('Tax Titles')));
00175         }
00176 
00177         $this->setForm($form);
00178 
00179         return parent::_prepareForm();
00180     }


Member Data Documentation

$_titles = null [protected]

Definition at line 37 of file Form.php.


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

Generated on Sat Jul 4 17:23:05 2009 for Magento by  doxygen 1.5.8