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_Promo_Quote_Edit_Tab_Actions
36: extends Mage_Adminhtml_Block_Widget_Form
37: implements Mage_Adminhtml_Block_Widget_Tab_Interface
38: {
39: 40: 41: 42: 43:
44: public function getTabLabel()
45: {
46: return Mage::helper('salesrule')->__('Actions');
47: }
48:
49: 50: 51: 52: 53:
54: public function getTabTitle()
55: {
56: return Mage::helper('salesrule')->__('Actions');
57: }
58:
59: 60: 61: 62: 63:
64: public function canShowTab()
65: {
66: return true;
67: }
68:
69: 70: 71: 72: 73:
74: public function isHidden()
75: {
76: return false;
77: }
78:
79: protected function _prepareForm()
80: {
81: $model = Mage::registry('current_promo_quote_rule');
82:
83:
84: $form = new Varien_Data_Form();
85:
86: $form->setHtmlIdPrefix('rule_');
87:
88: $fieldset = $form->addFieldset('action_fieldset', array('legend'=>Mage::helper('salesrule')->__('Update prices using the following information')));
89:
90: $fieldset->addField('simple_action', 'select', array(
91: 'label' => Mage::helper('salesrule')->__('Apply'),
92: 'name' => 'simple_action',
93: 'options' => array(
94: Mage_SalesRule_Model_Rule::BY_PERCENT_ACTION => Mage::helper('salesrule')->__('Percent of product price discount'),
95: Mage_SalesRule_Model_Rule::BY_FIXED_ACTION => Mage::helper('salesrule')->__('Fixed amount discount'),
96: Mage_SalesRule_Model_Rule::CART_FIXED_ACTION => Mage::helper('salesrule')->__('Fixed amount discount for whole cart'),
97: Mage_SalesRule_Model_Rule::BUY_X_GET_Y_ACTION => Mage::helper('salesrule')->__('Buy X get Y free (discount amount is Y)'),
98: ),
99: ));
100: $fieldset->addField('discount_amount', 'text', array(
101: 'name' => 'discount_amount',
102: 'required' => true,
103: 'class' => 'validate-not-negative-number',
104: 'label' => Mage::helper('salesrule')->__('Discount Amount'),
105: ));
106: $model->setDiscountAmount($model->getDiscountAmount()*1);
107:
108: $fieldset->addField('discount_qty', 'text', array(
109: 'name' => 'discount_qty',
110: 'label' => Mage::helper('salesrule')->__('Maximum Qty Discount is Applied To'),
111: ));
112: $model->setDiscountQty($model->getDiscountQty()*1);
113:
114: $fieldset->addField('discount_step', 'text', array(
115: 'name' => 'discount_step',
116: 'label' => Mage::helper('salesrule')->__('Discount Qty Step (Buy X)'),
117: ));
118:
119: $fieldset->addField('apply_to_shipping', 'select', array(
120: 'label' => Mage::helper('salesrule')->__('Apply to Shipping Amount'),
121: 'title' => Mage::helper('salesrule')->__('Apply to Shipping Amount'),
122: 'name' => 'apply_to_shipping',
123: 'values' => Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray(),
124: ));
125:
126: $fieldset->addField('simple_free_shipping', 'select', array(
127: 'label' => Mage::helper('salesrule')->__('Free Shipping'),
128: 'title' => Mage::helper('salesrule')->__('Free Shipping'),
129: 'name' => 'simple_free_shipping',
130: 'options' => array(
131: 0 => Mage::helper('salesrule')->__('No'),
132: Mage_SalesRule_Model_Rule::FREE_SHIPPING_ITEM => Mage::helper('salesrule')->__('For matching items only'),
133: Mage_SalesRule_Model_Rule::FREE_SHIPPING_ADDRESS => Mage::helper('salesrule')->__('For shipment with matching items'),
134: ),
135: ));
136:
137: $fieldset->addField('stop_rules_processing', 'select', array(
138: 'label' => Mage::helper('salesrule')->__('Stop Further Rules Processing'),
139: 'title' => Mage::helper('salesrule')->__('Stop Further Rules Processing'),
140: 'name' => 'stop_rules_processing',
141: 'options' => array(
142: '1' => Mage::helper('salesrule')->__('Yes'),
143: '0' => Mage::helper('salesrule')->__('No'),
144: ),
145: ));
146:
147: $renderer = Mage::getBlockSingleton('adminhtml/widget_form_renderer_fieldset')
148: ->setTemplate('promo/fieldset.phtml')
149: ->setNewChildUrl($this->getUrl('*/promo_quote/newActionHtml/form/rule_actions_fieldset'));
150:
151: $fieldset = $form->addFieldset('actions_fieldset', array(
152: 'legend'=>Mage::helper('salesrule')->__('Apply the rule only to cart items matching the following conditions (leave blank for all items)')
153: ))->setRenderer($renderer);
154:
155: $fieldset->addField('actions', 'text', array(
156: 'name' => 'actions',
157: 'label' => Mage::helper('salesrule')->__('Apply To'),
158: 'title' => Mage::helper('salesrule')->__('Apply To'),
159: 'required' => true,
160: ))->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/actions'));
161:
162: Mage::dispatchEvent('adminhtml_block_salesrule_actions_prepareform', array('form' => $form));
163:
164: $form->setValues($model->getData());
165:
166: if ($model->isReadonly()) {
167: foreach ($fieldset->getElements() as $element) {
168: $element->setReadonly(true, true);
169: }
170: }
171:
172:
173: $this->setForm($form);
174:
175: return parent::_prepareForm();
176: }
177:
178: }
179: