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_Bundle_Option extends Mage_Adminhtml_Block_Widget
00035 {
00036 protected $_element = null;
00037 protected $_customerGroups = null;
00038 protected $_websites = null;
00039
00040 protected $_oprions = null;
00041
00042 public function __construct()
00043 {
00044 $this->setTemplate('bundle/product/edit/bundle/option.phtml');
00045 }
00046
00047 public function getFieldId()
00048 {
00049 return 'bundle_option';
00050 }
00051
00052 public function getFieldName()
00053 {
00054 return 'bundle_options';
00055 }
00056
00057
00058
00059
00060
00061
00062 public function getProduct()
00063 {
00064 if (!$this->getData('product')) {
00065 $this->setData('product', Mage::registry('product'));
00066 }
00067 return $this->getData('product');
00068 }
00069
00070 public function render(Varien_Data_Form_Element_Abstract $element)
00071 {
00072 $this->setElement($element);
00073 return $this->toHtml();
00074 }
00075
00076 public function setElement(Varien_Data_Form_Element_Abstract $element)
00077 {
00078 $this->_element = $element;
00079 return $this;
00080 }
00081
00082 public function getElement()
00083 {
00084 return $this->_element;
00085 }
00086
00087 public function isMultiWebsites()
00088 {
00089 return !Mage::app()->isSingleStoreMode();
00090 }
00091
00092 protected function _prepareLayout()
00093 {
00094 $this->setChild('add_selection_button',
00095 $this->getLayout()->createBlock('adminhtml/widget_button')
00096 ->setData(array(
00097 'id' => $this->getFieldId().'_{{index}}_add_button',
00098 'label' => Mage::helper('bundle')->__('Add Selection'),
00099 'on_click' => 'bSelection.showSearch(event)',
00100 'class' => 'add'
00101 )));
00102
00103 $this->setChild('close_search_button',
00104 $this->getLayout()->createBlock('adminhtml/widget_button')
00105 ->setData(array(
00106 'id' => $this->getFieldId().'_{{index}}_close_button',
00107 'label' => Mage::helper('bundle')->__('Close'),
00108 'on_click' => 'bSelection.closeSearch(event)',
00109 'class' => 'back no-display'
00110 )));
00111
00112 $this->setChild('option_delete_button',
00113 $this->getLayout()->createBlock('adminhtml/widget_button')
00114 ->setData(array(
00115 'label' => Mage::helper('catalog')->__('Delete Option'),
00116 'class' => 'delete delete-product-option',
00117 'on_click' => 'bOption.remove(event)'
00118 ))
00119 );
00120
00121 $this->setChild('selection_template',
00122 $this->getLayout()->createBlock('bundle/adminhtml_catalog_product_edit_tab_bundle_option_selection')
00123 );
00124
00125 return parent::_prepareLayout();
00126 }
00127
00128 public function getAddButtonHtml()
00129 {
00130 return $this->getChildHtml('add_button');
00131 }
00132
00133 public function getCloseSearchButtonHtml()
00134 {
00135 return $this->getChildHtml('close_search_button');
00136 }
00137
00138 public function getAddSelectionButtonHtml()
00139 {
00140 return $this->getChildHtml('add_selection_button');
00141 }
00142
00143 public function getOptions()
00144 {
00145 if (!$this->_options) {
00146 $this->getProduct()->getTypeInstance(true)->setStoreFilter($this->getProduct()->getStoreId(), $this->getProduct());
00147
00148 $optionCollection = $this->getProduct()->getTypeInstance(true)->getOptionsCollection($this->getProduct());
00149
00150 $selectionCollection = $this->getProduct()->getTypeInstance(true)->getSelectionsCollection(
00151 $this->getProduct()->getTypeInstance(true)->getOptionsIds($this->getProduct()),
00152 $this->getProduct()
00153 );
00154
00155 $this->_options = $optionCollection->appendSelections($selectionCollection);
00156 }
00157 return $this->_options;
00158 }
00159
00160 public function getAddButtonId()
00161 {
00162 $buttonId = $this->getLayout()
00163 ->getBlock('admin.product.bundle.items')
00164 ->getChild('add_button')->getId();
00165 return $buttonId;
00166 }
00167
00168 public function getOptionDeleteButtonHtml()
00169 {
00170 return $this->getChildHtml('option_delete_button');
00171 }
00172
00173 public function getSelectionHtml()
00174 {
00175 return $this->getChildHtml('selection_template');
00176 }
00177
00178 public function getTypeSelectHtml()
00179 {
00180 $select = $this->getLayout()->createBlock('adminhtml/html_select')
00181 ->setData(array(
00182 'id' => $this->getFieldId().'_{{index}}_type',
00183 'class' => 'select select-product-option-type required-option-select',
00184 'extra_params' => 'onchange="bOption.changeType(event)"'
00185 ))
00186 ->setName($this->getFieldName().'[{{index}}][type]')
00187 ->setOptions(Mage::getSingleton('bundle/source_option_type')->toOptionArray());
00188
00189 return $select->getHtml();
00190 }
00191
00192 public function getRequireSelectHtml()
00193 {
00194 $select = $this->getLayout()->createBlock('adminhtml/html_select')
00195 ->setData(array(
00196 'id' => $this->getFieldId().'_{{index}}_required',
00197 'class' => 'select'
00198 ))
00199 ->setName($this->getFieldName().'[{{index}}][required]')
00200 ->setOptions(Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray());
00201
00202 return $select->getHtml();
00203 }
00204
00205 public function isDefaultStore()
00206 {
00207 return ($this->getProduct()->getStoreId() == '0');
00208 }
00209 }