00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Attributes_Extend extends Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element
00035 {
00036 const DYNAMIC = 0;
00037 const FIXED = 1;
00038
00039 public function getElementHtml()
00040 {
00041 $elementHtml = parent::getElementHtml();
00042
00043 $switchAttributeCode = $this->getAttribute()->getAttributeCode().'_type';
00044 $switchAttributeValue = $this->getProduct()->getData($switchAttributeCode);
00045
00046 $html = '<select name="product[' . $switchAttributeCode . ']" id="' . $switchAttributeCode . '" type="select" class="required-entry select next-toinput"' . ($this->getProduct()->getId() && $this->getAttribute()->getAttributeCode() == 'price' || $this->getElement()->getReadonly() ? ' disabled="disabled"' : '') . '>
00047 <option value="">' . $this->__('--Select--') . '</option>
00048 <option ' . ($switchAttributeValue == self::DYNAMIC ? 'selected' : '') . ' value="' . self::DYNAMIC . '">' . $this->__('Dynamic') . '</option>
00049 <option ' . ($switchAttributeValue == self::FIXED ? 'selected' : '') . ' value="' . self::FIXED . '">' . $this->__('Fixed') . '</option>
00050 </select>';
00051
00052 $html .= '<span class="next-toselect">'.$elementHtml.'</span>';
00053 if ($this->getDisableChild() && !$this->getElement()->getReadonly()) {
00054 $html .= "<script type=\"text/javascript\">
00055 function " . $switchAttributeCode . "_change() {
00056 if ($('" . $switchAttributeCode . "').value == '" . self::DYNAMIC . "') {
00057 $('" . $this->getAttribute()->getAttributeCode() . "').disabled = true;
00058 $('" . $this->getAttribute()->getAttributeCode() . "').value = '';
00059 $('" . $this->getAttribute()->getAttributeCode() . "').removeClassName('required-entry');
00060
00061 if ($('dynamic-price-warrning')) {
00062 $('dynamic-price-warrning').show();
00063 }
00064 } else {
00065 $('" . $this->getAttribute()->getAttributeCode() . "').disabled = false;
00066 $('" . $this->getAttribute()->getAttributeCode() . "').addClassName('required-entry');
00067
00068 if ($('dynamic-price-warrning')) {
00069 $('dynamic-price-warrning').hide();
00070 }
00071 }
00072 }
00073
00074 $('" . $switchAttributeCode . "').observe('change', " . $switchAttributeCode . "_change);
00075 " . $switchAttributeCode . "_change();
00076 </script>";
00077 }
00078 return $html;
00079 }
00080
00081 public function getProduct()
00082 {
00083 if (!$this->getData('product')){
00084 $this->setData('product', Mage::registry('product'));
00085 }
00086 return $this->getData('product');
00087 }
00088 }