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_Adminhtml_Block_Promo_Catalog_Edit_Tab_Main
35: extends Mage_Adminhtml_Block_Widget_Form
36: implements Mage_Adminhtml_Block_Widget_Tab_Interface
37: {
38: 39: 40: 41: 42:
43: public function getTabLabel()
44: {
45: return Mage::helper('catalogrule')->__('Rule Information');
46: }
47:
48: 49: 50: 51: 52:
53: public function getTabTitle()
54: {
55: return Mage::helper('catalogrule')->__('Rule Information');
56: }
57:
58: 59: 60: 61: 62:
63: public function canShowTab()
64: {
65: return true;
66: }
67:
68: 69: 70: 71: 72:
73: public function isHidden()
74: {
75: return false;
76: }
77:
78: protected function _prepareForm()
79: {
80: $model = Mage::registry('current_promo_catalog_rule');
81:
82: $form = new Varien_Data_Form();
83:
84: $form->setHtmlIdPrefix('rule_');
85:
86: $fieldset = $form->addFieldset('base_fieldset',
87: array('legend '=> Mage::helper('catalogrule')->__('General Information'))
88: );
89:
90: $fieldset->addField('auto_apply', 'hidden', array(
91: 'name' => 'auto_apply',
92: ));
93:
94: if ($model->getId()) {
95: $fieldset->addField('rule_id', 'hidden', array(
96: 'name' => 'rule_id',
97: ));
98: }
99:
100: $fieldset->addField('name', 'text', array(
101: 'name' => 'name',
102: 'label' => Mage::helper('catalogrule')->__('Rule Name'),
103: 'title' => Mage::helper('catalogrule')->__('Rule Name'),
104: 'required' => true,
105: ));
106:
107: $fieldset->addField('description', 'textarea', array(
108: 'name' => 'description',
109: 'label' => Mage::helper('catalogrule')->__('Description'),
110: 'title' => Mage::helper('catalogrule')->__('Description'),
111: 'style' => 'height: 100px;',
112: ));
113:
114: $fieldset->addField('is_active', 'select', array(
115: 'label' => Mage::helper('catalogrule')->__('Status'),
116: 'title' => Mage::helper('catalogrule')->__('Status'),
117: 'name' => 'is_active',
118: 'required' => true,
119: 'options' => array(
120: '1' => Mage::helper('catalogrule')->__('Active'),
121: '0' => Mage::helper('catalogrule')->__('Inactive'),
122: ),
123: ));
124:
125: if (Mage::app()->isSingleStoreMode()) {
126: $websiteId = Mage::app()->getStore(true)->getWebsiteId();
127: $fieldset->addField('website_ids', 'hidden', array(
128: 'name' => 'website_ids[]',
129: 'value' => $websiteId
130: ));
131: $model->setWebsiteIds($websiteId);
132: } else {
133: $field = $fieldset->addField('website_ids', 'multiselect', array(
134: 'name' => 'website_ids[]',
135: 'label' => Mage::helper('catalogrule')->__('Websites'),
136: 'title' => Mage::helper('catalogrule')->__('Websites'),
137: 'required' => true,
138: 'values' => Mage::getSingleton('adminhtml/system_store')->getWebsiteValuesForForm()
139: ));
140: $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
141: $field->setRenderer($renderer);
142: }
143:
144: $fieldset->addField('customer_group_ids', 'multiselect', array(
145: 'name' => 'customer_group_ids[]',
146: 'label' => Mage::helper('catalogrule')->__('Customer Groups'),
147: 'title' => Mage::helper('catalogrule')->__('Customer Groups'),
148: 'required' => true,
149: 'values' => Mage::getResourceModel('customer/group_collection')->toOptionArray()
150: ));
151:
152: $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
153: $fieldset->addField('from_date', 'date', array(
154: 'name' => 'from_date',
155: 'label' => Mage::helper('catalogrule')->__('From Date'),
156: 'title' => Mage::helper('catalogrule')->__('From Date'),
157: 'image' => $this->getSkinUrl('images/grid-cal.gif'),
158: 'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
159: 'format' => $dateFormatIso
160: ));
161: $fieldset->addField('to_date', 'date', array(
162: 'name' => 'to_date',
163: 'label' => Mage::helper('catalogrule')->__('To Date'),
164: 'title' => Mage::helper('catalogrule')->__('To Date'),
165: 'image' => $this->getSkinUrl('images/grid-cal.gif'),
166: 'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
167: 'format' => $dateFormatIso
168: ));
169:
170: $fieldset->addField('sort_order', 'text', array(
171: 'name' => 'sort_order',
172: 'label' => Mage::helper('catalogrule')->__('Priority'),
173: ));
174:
175: $form->setValues($model->getData());
176:
177:
178:
179: if ($model->isReadonly()) {
180: foreach ($fieldset->getElements() as $element) {
181: $element->setReadonly(true, true);
182: }
183: }
184:
185: $this->setForm($form);
186:
187: Mage::dispatchEvent('adminhtml_promo_catalog_edit_tab_main_prepare_form', array('form' => $form));
188:
189: return parent::_prepareForm();
190: }
191: }
192: