Exemple #1
0
 public function render(Varien_Data_Form_Element_Abstract $element)
 {
     $html = $this->_getHeaderHtml($element);
     $renderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
     $attributes = Mage::getConfig()->getNode(self::XML_PATH_IMAGE_TYPES)->asArray();
     foreach ($attributes as $key => $attribute) {
         /**
          * Watermark size field
          */
         $field = new Varien_Data_Form_Element_Text();
         $field->setName("groups[watermark][fields][{$key}_size][value]")->setForm($this->getForm())->setLabel(Mage::helper('adminhtml')->__('Size for %s', $attribute['title']))->setRenderer($renderer);
         $html .= $field->toHtml();
         /**
          * Watermark upload field
          */
         $field = new Varien_Data_Form_Element_Imagefile();
         $field->setName("groups[watermark][fields][{$key}_image][value]")->setForm($this->getForm())->setLabel(Mage::helper('adminhtml')->__('Watermark File for %s', $attribute['title']))->setRenderer($renderer);
         $html .= $field->toHtml();
         /**
          * Watermark position field
          */
         $field = new Varien_Data_Form_Element_Select();
         $field->setName("groups[watermark][fields][{$key}_position][value]")->setForm($this->getForm())->setLabel(Mage::helper('adminhtml')->__('Position of Watermark for %s', $attribute['title']))->setRenderer($renderer)->setValues(Mage::getSingleton('adminhtml/system_config_source_catalog_product_watermark_position')->toOptionArray());
         $html .= $field->toHtml();
     }
     $html .= $this->_getFooterHtml($element);
     return $html;
 }
Exemple #2
0
 protected function _prepareForm()
 {
     if (Mage::getSingleton('adminhtml/session')->getFormData()) {
         $data = Mage::getSingleton('adminhtml/session')->getFormData();
     } elseif ($this->getPeriod()) {
         $data = $this->getPeriod()->getData();
     }
     $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))), 'method' => 'post', 'enctype' => 'multipart/form-data'));
     $fieldset = $form->addFieldset('period_details', array('legend' => $this->__('Period Details')));
     $fieldset->addField('id', 'hidden', array('required' => false, 'name' => 'id'));
     $fieldset->addField('name', 'text', array('required' => true, 'name' => 'name', 'label' => 'Name'));
     $fieldset->addField('sort_order', 'text', array('required' => false, 'name' => 'sort_order', 'label' => 'Sort Order'));
     $select = new Varien_Data_Form_Element_Select(array('name' => 'period_type', 'style' => 'width:241px', 'options' => Mage::getModel('sarp/source_periods')->getGridOptions()));
     $select->setId('period_type')->setRenderer(Mage::getBlockSingleton('sarp/adminhtml_widget_form_renderer_element'))->setForm($form)->setValue(@$data['period_type']);
     $fieldset->addField('period_value', 'text', array('required' => true, 'name' => 'period_value', 'label' => 'Repeat each', 'style' => 'width:30px', 'after_element_html' => $select->toHtml()));
     $selectE = new Varien_Data_Form_Element_Select(array('name' => 'expire_type', 'style' => 'width:241px', 'options' => Mage::getModel('sarp/source_periods')->getGridOptions()));
     $selectE->setId('expire_type')->setRenderer(Mage::getBlockSingleton('sarp/adminhtml_widget_form_renderer_element'))->setForm($form)->setValue(@$data['expire_type']);
     $fieldset->addField('expire_value', 'text', array('required' => false, 'name' => 'expire_value', 'label' => 'Expires After', 'style' => 'width:30px', 'after_element_html' => $selectE->toHtml()));
     $fieldset->addField('excluded_weekdays', 'multiselect', array('required' => false, 'name' => 'excluded_weekdays', 'label' => 'Exclude Weekdays', 'values' => Mage::getModel('sarp/source_periods_weekdays')->getAllOptions()));
     $fieldset->addField('payment_offset', 'text', array('required' => false, 'name' => 'payment_offset', 'label' => 'Require payment before, days'));
     if (!isset($data['expire_value']) || $data['expire_value'] == 0) {
         $data['expire_value'] = '';
     }
     if (!isset($data['excluded_weekdays']) || !strlen($data['excluded_weekdays'])) {
         $data['excluded_weekdays'] = -1;
     }
     $form->setValues($data);
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
Exemple #3
0
 protected function _prepareForm()
 {
     if (Mage::getSingleton('adminhtml/session')->getFormData()) {
         $data = Mage::getSingleton('adminhtml/session')->getFormData();
     } elseif ($this->getAlert()) {
         $data = $this->getAlert()->getData();
     }
     $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))), 'method' => 'post', 'enctype' => 'multipart/form-data'));
     $fieldset = $form->addFieldset('alert_details', array('legend' => $this->__('Alert Details')));
     $fieldset->addField('id', 'hidden', array('required' => false, 'name' => 'id'));
     $fieldset->addField('name', 'text', array('required' => true, 'name' => 'name', 'label' => 'Name'));
     // Status field
     $fieldset->addField('status', 'select', array('required' => true, 'name' => 'status', 'label' => 'Status', 'options' => Mage::getModel('sarp/source_alert_status')->getGridOptions()));
     $fieldset->addField('type', 'select', array('required' => true, 'name' => 'type', 'label' => 'Event Type', 'onchange' => 'switchTemplates($(this).getValue())', 'options' => Mage::getModel('sarp/source_alert_type')->getGridOptions()));
     $fieldset->addField('recipient', 'select', array('required' => true, 'name' => 'recipient', 'onchange' => 'switchTemplates($F(\'type\'))', 'label' => 'Recipient', 'options' => Mage::getModel('sarp/source_alert_recipient')->getGridOptions()));
     $selectIsAfter = new Varien_Data_Form_Element_Select(array('name' => 'time_is_after', 'style' => 'width:120px', 'options' => array('0' => $this->__('Before'), '1' => $this->__('After'))));
     $selectIsAfter->setId('time_is_after')->setRenderer(Mage::getBlockSingleton('sarp/adminhtml_widget_form_renderer_element'))->setForm($form)->setValue(@$data['time_is_after']);
     $selectMultiplier = new Varien_Data_Form_Element_Select(array('name' => 'time_multiplier', 'style' => 'width:120px', 'options' => Mage::getModel('sarp/source_alert_multiplier')->getGridOptions()));
     $selectMultiplier->setId('time_multiplier')->setRenderer(Mage::getBlockSingleton('sarp/adminhtml_widget_form_renderer_element'))->setForm($form)->setValue(@$data['time_multiplier']);
     $fieldset->addField('time_amount', 'text', array('required' => true, 'name' => 'time_amount', 'label' => 'Notify', 'style' => 'width:30px', 'after_element_html' => $selectMultiplier->toHtml() . $selectIsAfter->toHtml()));
     $fieldset->addField('store_ids', 'multiselect', array('required' => true, 'name' => 'store_ids', 'label' => 'Store', 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true)));
     $fieldset->addField('email_template_date_start', 'select', array('label' => $this->__('Template'), 'note' => '', 'class' => 'template_selector', 'name' => 'email_template', 'values' => Mage::getModel('adminhtml/system_config_source_email_template')->setPath('sarp/template/firstdelivery')->toOptionArray()));
     $fieldset->addField('email_template_activation', 'select', array('label' => $this->__('Template'), 'note' => '', 'class' => 'template_selector', 'name' => 'email_template', 'values' => Mage::getModel('adminhtml/system_config_source_email_template')->setPath('sarp/template/activation')->toOptionArray()));
     $fieldset->addField('email_template_delivery', 'select', array('label' => $this->__('Template'), 'note' => '', 'class' => 'template_selector', 'name' => 'email_template', 'values' => Mage::getModel('adminhtml/system_config_source_email_template')->setPath('sarp/template/delivery')->toOptionArray()));
     $fieldset->addField('email_template_date_expire', 'select', array('label' => $this->__('Template'), 'note' => '', 'class' => 'template_selector', 'name' => 'email_template', 'values' => Mage::getModel('adminhtml/system_config_source_email_template')->setPath('sarp/template/expiredate')->toOptionArray()));
     $fieldset->addField('email_template_new_subscription', 'select', array('label' => $this->__('Template'), 'note' => '', 'class' => 'template_selector', 'name' => 'email_template', 'values' => Mage::getModel('adminhtml/system_config_source_email_template')->setPath('sarp/template/newsubscription')->toOptionArray()));
     $fieldset->addField('email_template_cancel_subscription', 'select', array('label' => $this->__('Template'), 'note' => '', 'class' => 'template_selector', 'name' => 'email_template', 'values' => Mage::getModel('adminhtml/system_config_source_email_template')->setPath('sarp/template/unsubscription')->toOptionArray()));
     $fieldset->addField('email_template_suspended', 'select', array('label' => $this->__('Template'), 'note' => '', 'class' => 'template_selector', 'name' => 'email_template', 'values' => Mage::getModel('adminhtml/system_config_source_email_template')->setPath('sarp/template/suspended')->toOptionArray()));
     $fieldset->addField('email_template_date_start_admin', 'select', array('label' => $this->__('Template'), 'note' => '', 'class' => 'template_selector', 'name' => 'email_template', 'values' => Mage::getModel('adminhtml/system_config_source_email_template')->setPath('sarp/template/firstdelivery_admin')->toOptionArray()));
     $fieldset->addField('email_template_activation_admin', 'select', array('label' => $this->__('Template'), 'note' => '', 'class' => 'template_selector', 'name' => 'email_template', 'values' => Mage::getModel('adminhtml/system_config_source_email_template')->setPath('sarp/template/activation_admin')->toOptionArray()));
     $fieldset->addField('email_template_delivery_admin', 'select', array('label' => $this->__('Template'), 'note' => '', 'class' => 'template_selector', 'name' => 'email_template', 'values' => Mage::getModel('adminhtml/system_config_source_email_template')->setPath('sarp/template/delivery_admin')->toOptionArray()));
     $fieldset->addField('email_template_date_expire_admin', 'select', array('label' => $this->__('Template'), 'note' => '', 'class' => 'template_selector', 'name' => 'email_template', 'values' => Mage::getModel('adminhtml/system_config_source_email_template')->setPath('sarp/template/expiredate_admin')->toOptionArray()));
     $fieldset->addField('email_template_new_subscription_admin', 'select', array('label' => $this->__('Template'), 'note' => '', 'class' => 'template_selector', 'name' => 'email_template', 'values' => Mage::getModel('adminhtml/system_config_source_email_template')->setPath('sarp/template/newsubscription_admin')->toOptionArray()));
     $fieldset->addField('email_template_cancel_subscription_admin', 'select', array('label' => $this->__('Template'), 'note' => '', 'class' => 'template_selector', 'name' => 'email_template', 'values' => Mage::getModel('adminhtml/system_config_source_email_template')->setPath('sarp/template/unsubscription_admin')->toOptionArray()));
     $fieldset->addField('email_template_suspended_admin', 'select', array('label' => $this->__('Template'), 'note' => '', 'class' => 'template_selector', 'name' => 'email_template', 'values' => Mage::getModel('adminhtml/system_config_source_email_template')->setPath('sarp/template/suspended_admin')->toOptionArray()));
     foreach (array('email_template_date_start', 'email_template_activation', 'email_template_delivery', 'email_template_date_expire', 'email_template_new_subscription', 'email_template_cancel_subscription', 'email_template_suspended_subscription', 'email_template_date_start_admin', 'email_template_activation_admin', 'email_template_delivery_admin', 'email_template_date_expire_admin', 'email_template_new_subscription_admin', 'email_template_cancel_subscription_admin', 'email_template_suspended_subscription_admin') as $id) {
         $data[$id] = @$data['email_template'];
     }
     $form->setValues($data);
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }