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: class Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Attributes
35: extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes
36: {
37: 38: 39: 40: 41:
42: protected function _prepareForm()
43: {
44: parent::_prepareForm();
45:
46: $special_price = $this->getForm()->getElement('special_price');
47: if ($special_price) {
48: $special_price->setRenderer(
49: $this->getLayout()->createBlock('bundle/adminhtml_catalog_product_edit_tab_attributes_special')
50: ->setDisableChild(false)
51: );
52: }
53:
54: $sku = $this->getForm()->getElement('sku');
55: if ($sku) {
56: $sku->setRenderer(
57: $this->getLayout()->createBlock('bundle/adminhtml_catalog_product_edit_tab_attributes_extend')
58: ->setDisableChild(false)
59: );
60: }
61:
62: $price = $this->getForm()->getElement('price');
63: if ($price) {
64: $price->setRenderer(
65: $this->getLayout()->createBlock('bundle/adminhtml_catalog_product_edit_tab_attributes_extend',
66: 'adminhtml.catalog.product.bundle.edit.tab.attributes.price')->setDisableChild(true)
67: );
68: }
69:
70: $tax = $this->getForm()->getElement('tax_class_id');
71: if ($tax) {
72: $tax->setAfterElementHtml(
73: '<script type="text/javascript">'
74: . "
75: //<![CDATA[
76: function changeTaxClassId() {
77: if ($('price_type').value == '" . Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC . "') {
78: $('tax_class_id').disabled = true;
79: $('tax_class_id').value = '0';
80: $('tax_class_id').removeClassName('required-entry');
81: if ($('advice-required-entry-tax_class_id')) {
82: $('advice-required-entry-tax_class_id').remove();
83: }
84: } else {
85: $('tax_class_id').disabled = false;
86: " . ($tax->getRequired() ? "$('tax_class_id').addClassName('required-entry');" : '') . "
87: }
88: }
89:
90: document.observe('dom:loaded', function() {
91: if ($('price_type')) {
92: $('price_type').observe('change', changeTaxClassId);
93: changeTaxClassId();
94: }
95: });
96: //]]>
97: "
98: . '</script>'
99: );
100: }
101:
102: $weight = $this->getForm()->getElement('weight');
103: if ($weight) {
104: $weight->setRenderer(
105: $this->getLayout()->createBlock('bundle/adminhtml_catalog_product_edit_tab_attributes_extend')
106: ->setDisableChild(true)
107: );
108: }
109:
110: $tier_price = $this->getForm()->getElement('tier_price');
111: if ($tier_price) {
112: $tier_price->setRenderer(
113: $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_price_tier')
114: ->setPriceColumnHeader(Mage::helper('bundle')->__('Percent Discount'))
115: ->setPriceValidation('validate-greater-than-zero validate-percents')
116: );
117: }
118:
119: $groupPrice = $this->getForm()->getElement('group_price');
120: if ($groupPrice) {
121: $groupPrice->setRenderer(
122: $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_price_group')
123: ->setPriceColumnHeader(Mage::helper('bundle')->__('Percent Discount'))
124: ->setPriceValidation('validate-greater-than-zero validate-percents')
125: );
126: }
127:
128: $mapEnabled = $this->getForm()->getElement('msrp_enabled');
129: if ($mapEnabled && $this->getCanEditPrice() !== false) {
130: $mapEnabled->setAfterElementHtml(
131: '<script type="text/javascript">'
132: . "
133: function changePriceTypeMap() {
134: if ($('price_type').value == " . Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC . ") {
135: $('msrp_enabled').setValue("
136: . Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Enabled::MSRP_ENABLE_NO
137: . ");
138: $('msrp_enabled').disable();
139: $('msrp_display_actual_price_type').setValue("
140: . Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Price::TYPE_USE_CONFIG
141: . ");
142: $('msrp_display_actual_price_type').disable();
143: $('msrp').setValue('');
144: $('msrp').disable();
145: } else {
146: $('msrp_enabled').enable();
147: $('msrp_display_actual_price_type').enable();
148: $('msrp').enable();
149: }
150: }
151: document.observe('dom:loaded', function() {
152: $('price_type').observe('change', changePriceTypeMap);
153: changePriceTypeMap();
154: });
155: "
156: . '</script>'
157: );
158: }
159: }
160:
161: 162: 163: 164: 165:
166: public function getProduct()
167: {
168: if (!$this->getData('product')){
169: $this->setData('product', Mage::registry('product'));
170: }
171: return $this->getData('product');
172: }
173: }
174: