1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34:
35: class Mage_Adminhtml_Block_Tax_Rule_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36: {
37: 38: 39: 40:
41: public function __construct()
42: {
43: parent::__construct();
44:
45: $this->setId('taxRuleForm');
46: $this->setTitle(Mage::helper('tax')->__('Tax Rule Information'));
47: }
48:
49: 50: 51: 52:
53: protected function _prepareForm()
54: {
55: $model = Mage::registry('tax_rule');
56: $form = new Varien_Data_Form(array(
57: 'id' => 'edit_form',
58: 'action' => $this->getData('action'),
59: 'method' => 'post'
60: ));
61:
62: $fieldset = $form->addFieldset('base_fieldset', array(
63: 'legend' => Mage::helper('tax')->__('Tax Rule Information')
64: ));
65:
66: $productClasses = Mage::getModel('tax/class')
67: ->getCollection()
68: ->setClassTypeFilter(Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT)
69: ->toOptionArray();
70:
71: $customerClasses = Mage::getModel('tax/class')
72: ->getCollection()
73: ->setClassTypeFilter(Mage_Tax_Model_Class::TAX_CLASS_TYPE_CUSTOMER)
74: ->toOptionArray();
75:
76: $rates = Mage::getModel('tax/calculation_rate')
77: ->getCollection()
78: ->toOptionArray();
79:
80: $fieldset->addField('code', 'text',
81: array(
82: 'name' => 'code',
83: 'label' => Mage::helper('tax')->__('Name'),
84: 'class' => 'required-entry',
85: 'required' => true,
86: )
87: );
88:
89: $fieldset->addField('tax_customer_class', 'multiselect',
90: array(
91: 'name' => 'tax_customer_class',
92: 'label' => Mage::helper('tax')->__('Customer Tax Class'),
93: 'class' => 'required-entry',
94: 'values' => $customerClasses,
95: 'value' => $model->getCustomerTaxClasses(),
96: 'required' => true,
97: )
98: );
99:
100: $fieldset->addField('tax_product_class', 'multiselect',
101: array(
102: 'name' => 'tax_product_class',
103: 'label' => Mage::helper('tax')->__('Product Tax Class'),
104: 'class' => 'required-entry',
105: 'values' => $productClasses,
106: 'value' => $model->getProductTaxClasses(),
107: 'required' => true,
108: )
109: );
110:
111: $fieldset->addField('tax_rate', 'multiselect',
112: array(
113: 'name' => 'tax_rate',
114: 'label' => Mage::helper('tax')->__('Tax Rate'),
115: 'class' => 'required-entry',
116: 'values' => $rates,
117: 'value' => $model->getRates(),
118: 'required' => true,
119: )
120: );
121: $fieldset->addField('priority', 'text',
122: array(
123: 'name' => 'priority',
124: 'label' => Mage::helper('tax')->__('Priority'),
125: 'class' => 'validate-not-negative-number',
126: 'value' => (int) $model->getPriority(),
127: 'required' => true,
128: 'note' => Mage::helper('tax')->__('Tax rates at the same priority are added, others are compounded.'),
129: )
130: );
131: $fieldset->addField('position', 'text',
132: array(
133: 'name' => 'position',
134: 'label' => Mage::helper('tax')->__('Sort Order'),
135: 'class' => 'validate-not-negative-number',
136: 'value' => (int) $model->getPosition(),
137: 'required' => true,
138: )
139: );
140:
141: if ($model->getId() > 0 ) {
142: $fieldset->addField('tax_calculation_rule_id', 'hidden',
143: array(
144: 'name' => 'tax_calculation_rule_id',
145: 'value' => $model->getId(),
146: 'no_span' => true
147: )
148: );
149: }
150:
151: $form->addValues($model->getData());
152: $form->setAction($this->getUrl('*/tax_rule/save'));
153: $form->setUseContainer(true);
154: $this->setForm($form);
155:
156: return parent::_prepareForm();
157: }
158: }
159: