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:
35: class Mage_Adminhtml_Block_Newsletter_Queue_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36: {
37: 38: 39: 40: 41: 42: 43: 44:
45: protected function _prepareForm()
46: {
47:
48: $queue = Mage::getSingleton('newsletter/queue');
49:
50: $form = new Varien_Data_Form();
51:
52: $fieldset = $form->addFieldset('base_fieldset', array(
53: 'legend' => Mage::helper('newsletter')->__('Queue Information'),
54: 'class' => 'fieldset-wide'
55: ));
56:
57: $outputFormat = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
58:
59: if($queue->getQueueStatus() == Mage_Newsletter_Model_Queue::STATUS_NEVER) {
60: $fieldset->addField('date', 'date',array(
61: 'name' => 'start_at',
62: 'time' => true,
63: 'format' => $outputFormat,
64: 'label' => Mage::helper('newsletter')->__('Queue Date Start'),
65: 'image' => $this->getSkinUrl('images/grid-cal.gif')
66: ));
67:
68: if (!Mage::app()->isSingleStoreMode()) {
69: $fieldset->addField('stores','multiselect',array(
70: 'name' => 'stores[]',
71: 'label' => Mage::helper('newsletter')->__('Subscribers From'),
72: 'image' => $this->getSkinUrl('images/grid-cal.gif'),
73: 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(),
74: 'value' => $queue->getStores()
75: ));
76: }
77: else {
78: $fieldset->addField('stores', 'hidden', array(
79: 'name' => 'stores[]',
80: 'value' => Mage::app()->getStore(true)->getId()
81: ));
82: }
83: } else {
84: $fieldset->addField('date','date',array(
85: 'name' => 'start_at',
86: 'time' => true,
87: 'disabled' => 'true',
88: 'style' => 'width:38%;',
89: 'format' => $outputFormat,
90: 'label' => Mage::helper('newsletter')->__('Queue Date Start'),
91: 'image' => $this->getSkinUrl('images/grid-cal.gif')
92: ));
93:
94: if (!Mage::app()->isSingleStoreMode()) {
95: $fieldset->addField('stores','multiselect',array(
96: 'name' => 'stores[]',
97: 'label' => Mage::helper('newsletter')->__('Subscribers From'),
98: 'image' => $this->getSkinUrl('images/grid-cal.gif'),
99: 'required' => true,
100: 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(),
101: 'value' => $queue->getStores()
102: ));
103: }
104: else {
105: $fieldset->addField('stores', 'hidden', array(
106: 'name' => 'stores[]',
107: 'value' => Mage::app()->getStore(true)->getId()
108: ));
109: }
110: }
111:
112: if ($queue->getQueueStartAt()) {
113: $form->getElement('date')->setValue(
114: Mage::app()->getLocale()->date($queue->getQueueStartAt(), Varien_Date::DATETIME_INTERNAL_FORMAT)
115: );
116: }
117:
118: $fieldset->addField('subject', 'text', array(
119: 'name' =>'subject',
120: 'label' => Mage::helper('newsletter')->__('Subject'),
121: 'required' => true,
122: 'value' => (
123: $queue->isNew() ? $queue->getTemplate()->getTemplateSubject() : $queue->getNewsletterSubject()
124: )
125: ));
126:
127: $fieldset->addField('sender_name', 'text', array(
128: 'name' =>'sender_name',
129: 'label' => Mage::helper('newsletter')->__('Sender Name'),
130: 'title' => Mage::helper('newsletter')->__('Sender Name'),
131: 'required' => true,
132: 'value' => (
133: $queue->isNew() ? $queue->getTemplate()->getTemplateSenderName() : $queue->getNewsletterSenderName()
134: )
135: ));
136:
137: $fieldset->addField('sender_email', 'text', array(
138: 'name' =>'sender_email',
139: 'label' => Mage::helper('newsletter')->__('Sender Email'),
140: 'title' => Mage::helper('newsletter')->__('Sender Email'),
141: 'class' => 'validate-email',
142: 'required' => true,
143: 'value' => (
144: $queue->isNew() ? $queue->getTemplate()->getTemplateSenderEmail() : $queue->getNewsletterSenderEmail()
145: )
146: ));
147:
148: $widgetFilters = array('is_email_compatible' => 1);
149: $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')
150: ->getConfig(array('widget_filters' => $widgetFilters));
151:
152: if ($queue->isNew()) {
153: $fieldset->addField('text','editor', array(
154: 'name' => 'text',
155: 'label' => Mage::helper('newsletter')->__('Message'),
156: 'state' => 'html',
157: 'required' => true,
158: 'value' => $queue->getTemplate()->getTemplateText(),
159: 'style' => 'height: 600px;',
160: 'config' => $wysiwygConfig
161: ));
162:
163: $fieldset->addField('styles', 'textarea', array(
164: 'name' =>'styles',
165: 'label' => Mage::helper('newsletter')->__('Newsletter Styles'),
166: 'container_id' => 'field_newsletter_styles',
167: 'value' => $queue->getTemplate()->getTemplateStyles()
168: ));
169: } elseif (Mage_Newsletter_Model_Queue::STATUS_NEVER != $queue->getQueueStatus()) {
170: $fieldset->addField('text','textarea', array(
171: 'name' => 'text',
172: 'label' => Mage::helper('newsletter')->__('Message'),
173: 'value' => $queue->getNewsletterText(),
174: ));
175:
176: $fieldset->addField('styles', 'textarea', array(
177: 'name' =>'styles',
178: 'label' => Mage::helper('newsletter')->__('Newsletter Styles'),
179: 'value' => $queue->getNewsletterStyles()
180: ));
181:
182: $form->getElement('text')->setDisabled('true')->setRequired(false);
183: $form->getElement('styles')->setDisabled('true')->setRequired(false);
184: $form->getElement('subject')->setDisabled('true')->setRequired(false);
185: $form->getElement('sender_name')->setDisabled('true')->setRequired(false);
186: $form->getElement('sender_email')->setDisabled('true')->setRequired(false);
187: $form->getElement('stores')->setDisabled('true');
188: } else {
189: $fieldset->addField('text','editor', array(
190: 'name' => 'text',
191: 'label' => Mage::helper('newsletter')->__('Message'),
192: 'state' => 'html',
193: 'required' => true,
194: 'value' => $queue->getNewsletterText(),
195: 'style' => 'height: 600px;',
196: 'config' => $wysiwygConfig
197: ));
198:
199: $fieldset->addField('styles', 'textarea', array(
200: 'name' =>'styles',
201: 'label' => Mage::helper('newsletter')->__('Newsletter Styles'),
202: 'value' => $queue->getNewsletterStyles(),
203: 'style' => 'height: 300px;',
204: ));
205: }
206:
207: $this->setForm($form);
208: return $this;
209: }
210: }
211: