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: class Mage_Adminhtml_Block_Promo_Quote_Edit_Tab_Labels
28: extends Mage_Adminhtml_Block_Widget_Form
29: implements Mage_Adminhtml_Block_Widget_Tab_Interface
30: {
31: 32: 33: 34: 35:
36: public function getTabLabel()
37: {
38: return Mage::helper('salesrule')->__('Labels');
39: }
40:
41: 42: 43: 44: 45:
46: public function getTabTitle()
47: {
48: return Mage::helper('salesrule')->__('Labels');
49: }
50:
51: 52: 53: 54: 55:
56: public function canShowTab()
57: {
58: return true;
59: }
60:
61: 62: 63: 64: 65:
66: public function isHidden()
67: {
68: return false;
69: }
70:
71: protected function _prepareForm()
72: {
73: $rule = Mage::registry('current_promo_quote_rule');
74: $form = new Varien_Data_Form();
75: $form->setHtmlIdPrefix('rule_');
76:
77: $fieldset = $form->addFieldset('default_label_fieldset', array(
78: 'legend' => Mage::helper('salesrule')->__('Default Label')
79: ));
80: $labels = $rule->getStoreLabels();
81: $fieldset->addField('store_default_label', 'text', array(
82: 'name' => 'store_labels[0]',
83: 'required' => false,
84: 'label' => Mage::helper('salesrule')->__('Default Rule Label for All Store Views'),
85: 'value' => isset($labels[0]) ? $labels[0] : '',
86: ));
87:
88: $fieldset = $form->addFieldset('store_labels_fieldset', array(
89: 'legend' => Mage::helper('salesrule')->__('Store View Specific Labels'),
90: 'table_class' => 'form-list stores-tree',
91: ));
92: $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset');
93: $fieldset->setRenderer($renderer);
94:
95: foreach (Mage::app()->getWebsites() as $website) {
96: $fieldset->addField("w_{$website->getId()}_label", 'note', array(
97: 'label' => $website->getName(),
98: 'fieldset_html_class' => 'website',
99: ));
100: foreach ($website->getGroups() as $group) {
101: $stores = $group->getStores();
102: if (count($stores) == 0) {
103: continue;
104: }
105: $fieldset->addField("sg_{$group->getId()}_label", 'note', array(
106: 'label' => $group->getName(),
107: 'fieldset_html_class' => 'store-group',
108: ));
109: foreach ($stores as $store) {
110: $fieldset->addField("s_{$store->getId()}", 'text', array(
111: 'name' => 'store_labels['.$store->getId().']',
112: 'required' => false,
113: 'label' => $store->getName(),
114: 'value' => isset($labels[$store->getId()]) ? $labels[$store->getId()] : '',
115: 'fieldset_html_class' => 'store',
116: ));
117: }
118: }
119: }
120:
121:
122: if ($rule->isReadonly()) {
123: foreach ($fieldset->getElements() as $element) {
124: $element->setReadonly(true, true);
125: }
126: }
127:
128: $this->setForm($form);
129: return parent::_prepareForm();
130: }
131: }
132: