예제 #1
0
 function createForm()
 {
     $form = new Am_Form_Admin();
     $form->setAction($this->getUrl(null, 'clear'));
     $form->addDate('dat')->setLabel(___("Date to Purge\nall records prior to this date will be removed from selected tables"))->addRule('required');
     $section = $form->addFieldset('tables')->setLabel(___('Tables to Purge'));
     foreach ($this->getItems() as $id => $item) {
         $section->addAdvCheckbox($id)->setLabel(array($item['title'], $item['desc']));
     }
     $form->addSaveButton(___('Clear'));
     return $form;
 }
예제 #2
0
 protected function getTransForm($text)
 {
     $trans = $this->getTrans($text);
     $lgList = $this->getDi()->languagesListUser;
     $form = new Am_Form_Admin();
     $form->setAction($this->getUrl(null, 'update-trans'));
     $default = $this->getDi()->config->get('lang.default', 'en');
     $form->addStatic('text_default')->setContent(sprintf("<div>%s</div>", $this->escape($text)));
     foreach ($trans as $lg => $t) {
         if ($lg != $default) {
             $form->addElement('textarea', 'trans[' . $lg . ']', array('class' => 'el-wide'))->setLabel($lgList[$lg])->setValue($t);
         }
     }
     $form->addElement('hidden', 'text')->setValue($text);
     return (string) $form;
 }
 public function createAccessForm()
 {
     static $form;
     if (!$form) {
         $form = new Am_Form_Admin();
         $form->setAction($url = $this->getUrl(null, 'c', null, 'payments', 'addaccess', 'user_id', $this->user_id));
         $sel = $form->addSelect('product_id');
         $options = $this->getDi()->productTable->getOptions();
         $sel->addOption(___('Please select an item...'), '');
         foreach ($options as $k => $v) {
             $sel->addOption($v, $k);
         }
         $sel->addRule('required', 'this field is required');
         $form->addDate('begin_date')->addRule('required', 'this field is required');
         $form->addDate('expire_date')->addRule('required', 'this field is required');
         $form->addSaveButton('Add Access Manually');
     }
     return $form;
 }
예제 #4
0
 /**
  * Add elements to config form
  * no need to add "time" controls
  */
 protected function createForm()
 {
     $form = new Am_Form_Admin('form-' . $this->getId());
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array($this->getFormDefaults()));
     $form->setAction(REL_ROOT_URL . '/admin-reports/run/report_id/' . $this->getId());
     if ($this->getPointFieldType() == self::POINT_DATE) {
         $start = $form->addElement('Date', 'start')->setLabel(___('Start'));
         $start->addRule('required');
         $stop = $form->addElement('Date', 'stop')->setLabel(___('End'));
         $stop->addRule('required');
         $form->addRule('callback', 'Start Date cannot be later than the End Date', array($this, 'checkStopDate'));
         $quant = $form->addElement('Select', 'quant')->setLabel(___('Quantity'));
         $quant->addRule('required');
         $quant->loadOptions($this->getQuantityOptions());
     }
     $this->_initConfigForm($form);
     $form->addSubmit('save', array('value' => ___('Run Report')));
     return $form;
 }
 protected function createUploadForm($force_submited = false)
 {
     $form = new Am_Form_Admin('upload');
     $form->setAction($this->getUrl(null, ''));
     $form->setAttribute('enctype', 'multipart/form-data');
     $file = $form->addElement('file', 'file[]')->setLabel(___('File'));
     $file->setAttribute('class', 'styled');
     $file->addRule('required', ___('This field is a requried field'));
     $form->addElement('submit', '_submit_', array('value' => ___('Next')));
     return $form;
 }
예제 #6
0
    public function run()
    {
        $form = new Am_Form_Admin();
        $form->setAction($this->getUrl());
        $form->setAttribute('name', 'export');
        $form->setAttribute('target', '_blank');
        $form->addElement('magicselect', 'fields_to_export')->loadOptions($this->getExportOptions())->setLabel(___('Fields To Export'));
        $form->addElement('select', 'export_type')->loadOptions(Am_Grid_Export_Processor_Factory::getOptions())->setLabel(___('Export Format'))->setId('form-export-type');
        foreach (Am_Grid_Export_Processor_Factory::createAll() as $id => $obj) {
            $obj->buildForm($form->addElement('fieldset', $id)->setId('form-export-options-' . $id));
        }
        $form->addSubmit('export', array('value' => ___('Export')));
        $script = <<<CUT
(function(\$){
    \$(function(){
        function update_options(\$sel) {
            \$('[id^=form-export-options-]').hide();
            \$('#form-export-options-' + \$sel.val()).show();
        }   
        
        update_options(\$('#form-export-type'));
        \$('#form-export-type').bind('change', function() {
            update_options(\$(this));
        })

    })
})(jQuery)
CUT;
        $form->addScript('script')->setScript($script);
        $this->initForm($form);
        if ($form->isSubmitted()) {
            $values = $form->getValue();
            $fields = array();
            foreach ($values['fields_to_export'] as $fieldName) {
                $fields[$fieldName] = $this->getField($fieldName);
            }
            $export = Am_Grid_Export_Processor_Factory::create($values['export_type']);
            $export->run($this->grid, $this->getDataSource($fields), $fields, $values);
            exit;
        } else {
            echo $this->renderTitle();
            echo $form;
        }
    }
예제 #7
0
파일: Report.php 프로젝트: irovast/eyedock
 /**
  * Add elements to config form
  * no need to add "time" controls
  */
 protected function createForm()
 {
     $form = new Am_Form_Admin('form-' . $this->getId());
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array($this->getFormDefaults()));
     $form->setAction(REL_ROOT_URL . '/admin-reports/run/report_id/' . $this->getId());
     $this->_initConfigForm($form);
     $this->_afterInitConfigForm($form);
     $form->addSubmit('save', array('value' => ___('Run Report')));
     return $form;
 }
 public function createAccessForm()
 {
     static $form;
     if (!$form) {
         $form = new Am_Form_Admin();
         $form->setAction($url = $this->getUrl(null, 'addaccess', null, 'user_id', $this->user_id));
         $sel = $form->addSelect('product_id', array('class' => 'el-wide am-combobox'));
         $options = $this->getDi()->productTable->getOptions();
         $sel->addOption(___('Please select an item...'), '');
         foreach ($options as $k => $v) {
             $sel->addOption($v, $k);
         }
         $sel->addRule('required', ___('This field is required'));
         $form->addText('comment', array('class' => 'el-wide', 'placeholder' => ___('Comment for Your Reference')));
         $form->addDate('begin_date')->addRule('required', ___('This field is required'));
         $form->addDate('expire_date')->addRule('required', ___('This field is required'));
         $form->addAdvCheckbox('does_not_send_autoresponder');
         $form->addSaveButton(___('Add Access Manually'));
     }
     return $form;
 }
예제 #9
0
    function createForm()
    {
        $form = new Am_Form_Admin('am-form-email');
        $form->setDataSources(array($this->getRequest()));
        $form->setAction($this->getUrl(null, 'preview'));
        if ($options = $this->getDi()->emailTemplateLayoutTable->getOptions()) {
            $form->addSelect('email_template_layout_id')->setLabel(___('Layout'))->loadOptions(array('' => ___('No Layout')) + $options);
        }
        $gr = $form->addGroup()->setLabel(___("Reply To\n" . "mailbox for replies to message"))->setSeparator(' ');
        $sel = $gr->addSelect('reply_to')->loadOptions($this->getReplyToOptions());
        $id = $sel->getId();
        $gr->addText('reply_to_other', array('placeholder' => ___('Email Address')))->setId($id . '-other')->persistentFreeze(true);
        // ??? why is it necessary? but it is
        $gr->addScript()->setScript(<<<CUT
\$('#{$id}').change(function(){
   \$('#{$id}-other').toggle(\$(this).val() == 'other');
}).change();
CUT
);
        $subj = $form->addText('subject', array('class' => 'el-wide'))->setLabel(___('Email Subject'));
        $subj->persistentFreeze(true);
        // ??? why is it necessary? but it is
        $subj->addRule('required', ___('Subject is required'));
        //        $arch = $form->addElement('advcheckbox', 'do_archive')->setLabel(array('Archive Message', 'if you are sending it to newsletter subscribers'));
        $format = $form->addGroup(null)->setLabel(___('E-Mail Format'));
        $format->setSeparator(' ');
        $format->addRadio('format', array('value' => 'html'))->setContent(___('HTML Message'));
        $format->addRadio('format', array('value' => 'text'))->setContent(___('Plain-Text Message'));
        $group = $form->addGroup('', array('id' => 'body-group', 'class' => 'no-label'))->setLabel(___('Message Text'));
        $group->addStatic()->setContent('<div class="mail-editor">');
        $group->addStatic()->setContent('<div class="mail-editor-element">');
        $group->addElement('textarea', 'body', array('id' => 'body-0', 'rows' => '15', 'class' => 'el-wide'));
        $group->addStatic()->setContent('</div>');
        $group->addStatic()->setContent('<div class="mail-editor-element">');
        $this->tagsOptions = Am_Mail_TemplateTypes::getInstance()->getTagsOptions('send_signup_mail');
        $tagsOptions = array();
        foreach ($this->tagsOptions as $k => $v) {
            $tagsOptions[$k] = "{$k} - {$v}";
        }
        $sel = $group->addSelect('', array('id' => 'insert-tags'));
        $sel->loadOptions(array_merge(array('' => ''), $tagsOptions));
        $group->addStatic()->setContent('</div>');
        $group->addStatic()->setContent('</div>');
        $fileChooser = new Am_Form_Element_Upload('files', array('multiple' => '1'), array('prefix' => 'email'));
        $form->addElement($fileChooser)->setLabel(___('Attachments'));
        foreach ($this->searchUi->getHidden() as $k => $v) {
            $form->addHidden($k)->setValue($v);
        }
        $id = 'body-0';
        $vars = "";
        foreach ($this->tagsOptions as $k => $v) {
            $vars .= sprintf("[%s, %s],\n", Am_Controller::getJson($v), Am_Controller::getJson($k));
        }
        $vars = trim($vars, "\n\r,");
        if ($this->queue_id) {
            $form->addHidden('queue_id')->setValue($this->queue_id);
        }
        $form->addScript('_bodyscript')->setScript(<<<CUT
\$(function(){
    \$('select#insert-tags').change(function(){
        var val = \$(this).val();
        if (!val) return;
        \$("#{$id}").insertAtCaret(val);
        \$(this).prop("selectedIndex", -1);
    });

    if (CKEDITOR.instances["{$id}"]) {
        delete CKEDITOR.instances["{$id}"];
    }
    var editor = null;
    \$("input[name='format']").change(function()
    {
        if (window.configDisable_rte) return;
        if (!this.checked) return;
        if (this.value == 'html')
        {
            if (!editor) {
                editor = initCkeditor("{$id}", { placeholder_items: [
                    {$vars}
                ],entities_greek: false});
            }
            \$('select#insert-tags').hide();
        } else {
            if (editor) {
                editor.destroy();
                editor = null;
            }
            \$('select#insert-tags').show();
        }
    }).change();
});

CUT
);
        $this->getDi()->hook->call(Am_Event::MAIL_SIMPLE_INIT_FORM, array('form' => $form));
        $buttons = $form->addGroup('buttons');
        $buttons->addSubmit('send', array('value' => ___('Preview')));
        return $form;
    }
 function createForm()
 {
     $form = new Am_Form_Admin('am-form-email');
     $form->setDataSources(array($this->_request));
     $form->setAction($this->getUrl(null, 'preview'));
     $subj = $form->addElement('text', 'subject', array('size' => 80))->setLabel(array(___('Email Subject')));
     $subj->persistentFreeze(true);
     // ??? why is it necessary? but it is
     $subj->addRule('required', 'Subject is required');
     //        $arch = $form->addElement('advcheckbox', 'do_archive')->setLabel(array('Archive Message', 'if you are sending it to newsletter subscribers'));
     $format = $form->addGroup(null)->setLabel(___('E-Mail Format'));
     $format->addRadio('format', array('value' => 'html'))->setContent(___('HTML Message'));
     $format->addRadio('format', array('value' => 'text'))->setContent(___('Plain-Text Message'));
     $group = $form->addGroup('', array('id' => 'body-group', 'class' => 'no-label'))->setLabel('Message Text');
     $group->addElement('textarea', 'body', array('id' => 'body-0', 'rows' => '15', 'cols' => '80', 'style' => 'width: 90%;'));
     $fileChooser = new Am_Form_Element_Upload('files', array('multiple' => '1'), array('prefix' => 'email'));
     $form->addElement($fileChooser)->setLabel(___('Attach Uploaded File'));
     foreach ($this->searchUi->getHidden() as $k => $v) {
         $form->addHidden($k)->setValue($v);
     }
     $form->addElement('submit', 'send', array('value' => ___('Preview'), 'style' => 'width: 200px'));
     return $form;
 }
 protected function createconfirmForm()
 {
     $form = new Am_Form_Admin('confirm');
     $form->setAction($this->getUrl(null, 'confirm'));
     $form->addElement('select', 'mode')->setLabel('Import Mode')->loadOptions(self::getImportModeOptions());
     $group = $form->addGroup();
     $group->addElement('inputbutton', 'back', array('value' => 'Back'))->setId('back');
     $group->addElement('submit', '_submit_', array('value' => 'Do Import'))->setId('_submit_');
     if ($form->isSubmitted()) {
         $form->setDataSources(array($this->_request));
     } else {
         $form->setDataSources(array(new HTML_QuickForm2_DataSource_Array(array())));
     }
     return $form;
 }
 public function getForm()
 {
     $languageTranslation = Am_Locale::getSelfNames();
     $avalableLocaleList = Zend_Locale::getLocaleList();
     $existingLanguages = Am_Di::getInstance()->languagesListUser;
     $languageOptions = array();
     foreach ($avalableLocaleList as $k => $v) {
         $locale = new Zend_Locale($k);
         if (!array_key_exists($locale->getLanguage(), $existingLanguages) && isset($languageTranslation[$locale->getLanguage()])) {
             $languageOptions[$locale->getLanguage()] = "({$k}) " . $languageTranslation[$locale->getLanguage()];
         }
     }
     asort($languageOptions);
     $form = new Am_Form_Admin();
     $form->setAction($this->grid->makeUrl(null));
     $form->addElement('select', 'new_language')->setLabel(___('Language'))->loadOptions($languageOptions)->setId('languageSelect');
     $form->addElement('hidden', 'a')->setValue('new');
     $form->addSaveButton();
     foreach ($this->grid->getVariablesList() as $k) {
         if ($val = $this->grid->getRequest()->get($k)) {
             $form->addHidden($this->grid->getId() . '_' . $k)->setValue($val);
         }
     }
     return $form;
 }