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($this->getRequest()->getParam('text'))));
     foreach ($trans as $lg => $text) {
         if ($lg != $default) {
             $form->addElement('textarea', 'trans[' . $lg . ']', array('style' => 'width:95%'))->setLabel($lgList[$lg])->setValue($text);
         }
     }
     $form->addElement('hidden', 'text')->setValue($this->getRequest()->getParam('text'));
     return (string) $form;
 }
Esempio n. 2
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;
 }
Esempio n. 3
0
    function createForm()
    {
        $form = new Am_Form_Admin();
        $form->addText('title', array('size' => 80))->setLabel(___('Title'))->addRule('required');
        $form->addText('desc', array('size' => 80))->setLabel(___('Description'));
        $sel = $form->addSelect('access', array('size' => 1, 'id' => 'newsletter-access'))->setLabel(___('Access'));
        $sel->loadOptions(array(NewsletterList::ACCESS_RESTRICTED => ___('Restricted Access'), NewsletterList::ACCESS_USERS => ___('Access allowed for all Users'), NewsletterList::ACCESS_GUESTS_AND_USERS => ___('Access allowed for all Users and Guests')));
        $form->addScript()->setScript(<<<CUT
jQuery(document).ready(function(\$) {
    \$("#newsletter-access").change(function(){
        \$("select.category").closest(".row").toggle(\$(this).val() == 0);
    }).change();
});
CUT
);
        $form->addElement(new Am_Form_Element_ResourceAccess())->setName('_access')->setLabel(___('Access Permissions'))->setAttribute('without_period', 'true');
        return $form;
    }
Esempio n. 4
0
    function createForm()
    {
        $form = new Am_Form_Admin();
        $form->addAdvRadio('is_custom')->loadOptions(array(0 => ___('Use Pre-Defined Template'), 1 => ___('Define Custom Html Message')))->setValue(0);
        $form->addTextarea('content', array('rows' => '7', 'class' => 'row-wide el-wide'))->setLabel(___("Content\n" . 'You can use all user specific placeholders here eg. %user.login%, %user.name_f%, %user.name_l% etc.'))->addRule('required');
        $form->addText('url', array('class' => 'el-wide', 'rel' => 'form-pre-defined'))->setLabel(___('Link'));
        $form->addAdvcheckbox('is_blank', array('rel' => 'form-pre-defined'))->setLabel(___('Open Link in New Window'));
        $form->addScript()->setScript(<<<CUT
\$('[name=is_custom]').change(function(){
    \$('[rel=form-pre-defined]').closest('.row').toggle(\$('[name=is_custom]:checked').val() == 0)
}).change();
CUT
);
        $sel = $form->addMagicSelect('_target')->setLabel(___('Target By User'));
        $cats = $pr = $gr = array();
        foreach ($this->getDi()->userGroupTable->getSelectOptions() as $k => $v) {
            $gr['user_group_id-' . $k] = 'Group: ' . $v;
        }
        $options = array('free' => ___('All'), 'user_id' => ___('Specific User')) + ($cats ? array(___('Product Categories') => $cats) : array()) + ($gr ? array(___('User Groups') => $gr) : array()) + ($pr ? array(___('Products') => $pr) : array());
        $sel->loadOptions($options);
        //$sel->addRule('required');
        $sel->setJsOptions('{onChange:function(val){
                $("input[name^=_loginOrEmail]").closest(\'.row\').toggle(val.hasOwnProperty("user_id"));
        }}');
        $loginGroup = $form->addGroup('');
        $loginGroup->setLabel(___('E-Mail Address or Username'));
        $loginGroup->addHidden('_savedLoginOrEmail')->setValue('');
        $login = $loginGroup->addText('_loginOrEmail[]');
        $label_add_user = ___('Add User');
        $loginGroup->addHtml()->setHtml(<<<CUT
<div><a href="javascript:void(null);" id="target-user_id-add" class="local">{$label_add_user}</a></div>
CUT
);
        $form->addElement(new Am_Form_Element_ResourceAccess('_raccess', array('without_free' => true)))->setLabel('Target By Product');
        $gr = $form->addGroup()->setSeparator(' ')->setLabel(___("Dates\n" . 'date range when notification is shown'));
        $gr->addDate('begin', array('placeholder' => ___('Begin Date')));
        $gr->addDate('expire', array('placeholder' => ___('Expire Date')));
        $form->addScript('script')->setScript(<<<CUT
\$("input[name^=_loginOrEmail]").autocomplete({
        minLength: 2,
        source: window.rootUrl + "/admin-users/autocomplete"
});
CUT
);
        $delIcon = $this->getDi()->view->icon('delete');
        $form->addScript('script2')->setScript(<<<CUT

var arr = \$('[name=_savedLoginOrEmail]').val().split(',').reverse();
\$('[name^=_loginOrEmail]').val(arr.pop());
for (var i in arr) {
    var \$field = addEmailOrLogin(\$('#target-user_id-add'));
    \$field.val(arr[i]);
}

function addEmailOrLogin(context) {
    var \$field = \$('<input tyep="text" name="_loginOrEmail[]" />');
    \$(context).before('<br />');
    \$(context).before(\$field);
    \$(context).before('<a href="javascript:void(null)" onclick="\$(this).prev().remove();\$(this).prev().remove();\$(this).next().remove();\$(this).remove()">{$delIcon}</a>');
    \$(context).before('<br />');
    \$field.autocomplete({
        minLength: 2,
        source: window.rootUrl + "/admin-users/autocomplete"
    });
    return \$field;
}

\$('#target-user_id-add').click(function(){
    addEmailOrLogin(this);
})
CUT
);
        $form->addText('limit', array('placeholder' => ___('Unlimited')))->setLabel(___("Limit Number of Display per User\n" . 'keep it empty for unlimited'));
        return $form;
    }
Esempio n. 5
0
    function createForm()
    {
        $form = new Am_Form_Admin();
        $record = $this->getRecord();
        $plugins = $this->getDi()->plugins_newsletter->loadEnabled()->getAllEnabled();
        if ($record->isLoaded()) {
            if ($record->plugin_id) {
                $group = $form->addFieldset();
                $group->setLabel(ucfirst($record->plugin_id));
                $form->addStatic()->setLabel(___('Plugin List Id'))->setContent(Am_Controller::escape($record->plugin_list_id));
            }
        } else {
            if (count($plugins) > 1) {
                $sel = $form->addSelect('plugin_id')->setLabel(___('Plugin'));
                $sel->addOption(___('Standard'), '');
                foreach ($plugins as $pl) {
                    if (!$pl->canGetLists() && $pl->getId() != 'standard') {
                        $sel->addOption($pl->getTitle(), $pl->getId());
                    }
                }
            }
            foreach ($plugins as $pl) {
                $group = $form->addFieldset($pl->getId())->setId('headrow-' . $pl->getId());
                $group->setLabel($pl->getTitle());
            }
            $form->addText('plugin_list_id')->setLabel(___("Plugin List Id\nvalue required"));
            $form->addScript()->setScript(<<<END
\$(function(){
    function showHidePlugins(el, skip)
    {
        var txt = \$("input[name='plugin_list_id']");
        var enabled = el.size() && (el.val() != '');
        txt.closest(".row").toggle(enabled);
        if (enabled)
            txt.rules("add", { required : true});
        else if(skip)
            txt.rules("remove", "required");
        var selected = (el.size() && el.val()) ? el.val() : 'standard';
        \$("[id^='headrow-']").hide();
        \$("[id=headrow-"+selected+"-legend]").show();
        \$("[id=headrow-"+selected+"-pluginoptions]").show();
        \$("[id=headrow-"+selected+"]").show();
    }
    \$("select[name='plugin_id']").change(function(){
        showHidePlugins(\$(this), true);
    });
    showHidePlugins(\$("select[name='plugin_id']"), false);
});
END
);
        }
        $form->addText('title', array('class' => 'el-wide'))->setLabel(___('Title'))->addRule('required');
        $form->addText('desc', array('class' => 'el-wide'))->setLabel(___('Description'));
        $form->addAdvCheckbox('hide')->setLabel(___("Hide\n" . "do not display this item in members area"));
        $form->addAdvCheckbox('auto_subscribe')->setLabel(___("Auto-Subscribe users to list\n" . "once it becomes accessible for them"));
        foreach ($plugins as $pl) {
            $group = $form->addElement(new Am_Form_Container_PrefixFieldset('_vars'))->setId('headrow-' . $pl->getId() . '-pluginoptions');
            $gr = $group->addElement(new Am_Form_Container_PrefixFieldset($pl->getId()));
            $pl->getIntegrationFormElements($gr);
        }
        $group = $form->addFieldset('access')->setLabel(___('Access'));
        $group->addElement(new Am_Form_Element_ResourceAccess())->setName('_access')->setLabel(___('Access Permissions'))->setAttribute('without_free_without_login', 'true')->setAttribute('without_period', 'true');
        return $form;
    }
    function createForm()
    {
        $form = new Am_Form_Admin();
        $form->setAttribute('enctype', 'multipart/form-data');
        $form->setAttribute('target', '_top');
        $maxFileSize = min(ini_get('post_max_size'), ini_get('upload_max_filesize'));
        $el = $form->addElement(new Am_Form_Element_Upload('path', array(), array('prefix' => 'video')))->setLabel(___("Video/Audio File\n" . "(max upload size %s)\n" . "You can use this feature only for video and\naudio formats that %ssupported by %s%s", $maxFileSize, $this->getDi()->config->get('video_player', 'Flowplayer') == 'Flowplayer' ? '<a href="http://flowplayer.org/documentation/installation/formats.html" class="link" target="_blank">' : '<a href="http://www.longtailvideo.com/support/jw-player/28836/media-format-support/" class="link" target="_blank">', $this->getDi()->config->get('video_player', 'Flowplayer') == 'Flowplayer' ? 'Flowplayer' : 'JWPlayer', '</a>'))->setId('form-path');
        $jsOptions = <<<CUT
{
    onFileAdd : function (info) {
        var txt = \$(this).closest("form").find("input[name='title']");
        if (txt.data('changed-value')) return;
        txt.val(info.name);
    }
}
CUT;
        $el->setJsOptions($jsOptions);
        $form->addScript()->setScript(<<<CUT
\$(function(){
    \$("input[name='title']").change(function(){
        \$(this).data('changed-value', true);
    });
});
CUT
);
        $el->addRule('required');
        $form->addUpload('poster_id', null, array('prefix' => 'video-poster'))->setLabel(___("Poster Image\n" . "applicable only for video files"));
        $form->addText('title', array('class' => 'el-wide'))->setLabel(___('Title'))->addRule('required', 'This field is required');
        $form->addText('desc', array('class' => 'el-wide'))->setLabel(___('Description'));
        $form->addAdvCheckbox('hide')->setLabel(___("Hide\n" . "do not display this item link in members area"));
        $form->addElement(new Am_Form_Element_PlayerConfig('config'))->setLabel(___("Player Configuration\n" . 'this option is applied only for video files'));
        $form->addSelect('tpl')->setLabel(___("Template\nalternative template for this video\n" . "aMember will look for templates in [application/default/views/] folder\n" . "and in theme's [/] folder\n" . "and template filename must start with [layout]"))->loadOptions($this->getTemplateOptions());
        $form->addElement(new Am_Form_Element_ResourceAccess())->setName('_access')->setLabel(___('Access Permissions'));
        $form->addText('no_access_url', array('class' => 'el-wide'))->setLabel(___("No Access URL\n" . "customer without required access will see link to this url in " . "the player window\nleave empty if you want to redirect to " . "default 'No access' page"));
        $this->addCategoryToForm($form);
        $fs = $form->addAdvFieldset('meta', array('id' => 'meta'))->setLabel(___('Meta Data'));
        $fs->addText('meta_title', array('class' => 'el-wide'))->setLabel(___('Title'));
        $fs->addText('meta_keywords', array('class' => 'el-wide'))->setLabel(___('Keywords'));
        $fs->addText('meta_description', array('class' => 'el-wide'))->setLabel(___('Description'));
        $form->addEpilog('<div class="info">' . ___('In case of video do not start play before
full download and you use <a class="link" href="http://en.wikipedia.org/wiki/MPEG-4_Part_14">mp4 format</a>
more possible that metadata (moov atom) is located
at the end of file. There is special programs that allow to relocate
this metadata to the beginning of your file and allow play video before full
download (On Linux mashine you can use <em>qt-faststart</em> utility to do it).
Also your video editor can has option to locate metadata at beginning of file
(something like <em>FastStart</em> or <em>Web Optimized</em> option).
You need to relocate metadata for this file and reupload
it to aMember. You can use such utilites as <em>AtomicParsley</em> or similar
to check your file structure.') . '</div>');
        return $form;
    }
    public function addInvoiceAction()
    {
        $this->getDi()->authAdmin->getUser()->checkPermission('grid_invoice', 'insert');
        $form = new Am_Form_Admin('add-invoice');
        $tm_added = $form->addDate('tm_added')->setLabel(___('Date'));
        $tm_added->setValue($this->getDi()->sqlDate);
        $tm_added->addRule('required');
        $comment = $form->addText('comment', array('class' => 'el-wide'))->setLabel(___("Comment\nfor your reference"));
        $form->addElement(new Am_Form_Element_ProductsWithQty('product_id'))->setLabel(___('Products'))->loadOptions($this->getDi()->billingPlanTable->selectAllSorted())->addRule('required');
        $form->addSelect('paysys_id')->setLabel(___('Payment System'))->setId('add-invoice-paysys_id')->loadOptions(array('' => '') + $this->getDi()->paysystemList->getOptions());
        $couponEdit = $form->addText('coupon')->setLabel(___('Coupon'))->setId('p-coupon');
        $action = $form->addAdvRadio('_action')->setLabel(___('Action'))->setId('add-invoice-action')->loadOptions(array('pending' => ___('Just Add Pending Invoice'), 'pending-payment' => ___('Add Invoice and Payment/Access Manually'), 'pending-send' => ___('Add Pending Invoice and Send Link to Pay It to Customer')))->setValue('pending');
        $receipt = $form->addText('receipt')->setLabel(___('Receipt#'))->setId('add-invoice-receipt');
        $tm_due = $form->addDate('tm_due')->setLabel(___('Due Date'));
        $tm_due->setValue(sqlDate('+7 days'));
        $tm_due->setId('add-invoice-due');
        $message = $form->addTextarea('message', array('class' => 'el-wide'))->setLabel(___("Message\nwill be included to email to user"));
        $message->setId('add-invoice-message');
        $form->addElement('email_link', 'invoice_pay_link')->setLabel(___('Email Template with Payment Link'));
        $form->addScript()->setScript('
            $("[name=_action]").change(function(){
                var val = $("[name=_action]:checked").val();
                $("#add-invoice-receipt").closest("div.row").toggle(val == "pending-payment")
                $("#add-invoice-due").closest("div.row").toggle(val == "pending-send")
                $("#add-invoice-message").closest("div.row").toggle(val == "pending-send")
                $("[name=invoice_pay_link]").closest("div.row").toggle(val == "pending-send")
            }).change();

        ');
        $script = <<<CUT
        \$("input#p-coupon").autocomplete({
                minLength: 2,
                source: window.rootUrl + "/admin-coupons/autocomplete"
        });
CUT;
        $form->addScript('script')->setScript($script);
        $form->addSaveButton();
        $form->setDataSources(array($this->getRequest()));
        do {
            if ($form->isSubmitted() && $form->validate()) {
                $vars = $form->getValue();
                $invoice = $this->getDi()->invoiceRecord;
                $invoice->setUser($this->getDi()->userTable->load($this->user_id));
                $invoice->tm_added = sqlTime($vars['tm_added']);
                if ($vars['coupon']) {
                    $invoice->setCouponCode($vars['coupon']);
                    $error = $invoice->validateCoupon();
                    if ($error) {
                        $couponEdit->setError($error);
                        break;
                    }
                }
                foreach ($vars['product_id'] as $plan_id => $qty) {
                    $p = $this->getDi()->billingPlanTable->load($plan_id);
                    $pr = $p->getProduct();
                    try {
                        $invoice->add($pr, $qty);
                    } catch (Am_Exception_InputError $e) {
                        $form->setError($e->getMessage());
                        break 2;
                    }
                }
                $invoice->comment = $vars['comment'];
                $invoice->calculate();
                switch ($vars['_action']) {
                    case 'pending':
                        if (!$this->_addPendingInvoice($invoice, $form, $vars)) {
                            break 2;
                        }
                        break;
                    case 'pending-payment':
                        if (!$this->_addPendingInvoiceAndPayment($invoice, $form, $vars)) {
                            break 2;
                        }
                        break;
                    case 'pending-send':
                        if (!$this->_addPendingInvoiceAndSend($invoice, $form, $vars)) {
                            break 2;
                        }
                        break;
                    default:
                        throw new Am_Exception_InternalError(sprintf('Unknown action [%s] as %s::%s', $vars['_action'], __CLASS__, __METHOD__));
                }
                $this->getDi()->adminLogTable->log("Add Invoice (#{$invoice->invoice_id}/{$invoice->public_id}, Billing Terms: " . new Am_TermsText($invoice) . ")", 'invoice', $invoice->invoice_id);
                return $this->redirectLocation(REL_ROOT_URL . '/admin-user-payments/index/user_id/' . $this->user_id);
            }
            // if
        } while (false);
        $this->view->content = '<h1>' . ___('Add Invoice') . ' (<a href="' . REL_ROOT_URL . '/admin-user-payments/index/user_id/' . $this->user_id . '">' . ___('return') . '</a>)</h1>' . (string) $form;
        $this->view->display('admin/user-layout.phtml');
    }
 protected function createActionsForm(EmailTemplate $tpl)
 {
     $form = new Am_Form_Admin('EmailTemplate_Actions');
     $form->addElement('hidden', 'name')->setValue($tpl->name);
     $langOptions = $this->getLanguageOptions($this->getDi()->emailTemplateTable->getLanguages($tpl->name, null, null, $tpl->lang));
     if (count($langOptions)) {
         $lang_from = $form->addElement('select', 'copy_from')->setId('another_lang')->setLabel(___('Copy from another language'))->loadOptions(array('0' => '--' . ___('Please choose') . ' --') + $langOptions)->setValue(0);
     }
     if (isset($tpl->lang) && $tpl->lang) {
         $form->addElement('hidden', 'lang')->setValue($tpl->lang);
     }
     $form->addElement('hidden', 'label')->setValue($this->_request->get('label'));
     //we do not show action's form if there is not any avalable action
     if (!count($langOptions)) {
         $form = null;
     }
     return $form;
 }
 function presetAction()
 {
     $form = new Am_Form_Admin('player-config-preset');
     $form->addElement('text', 'name')->setLabel(___('Name of Preset'));
     echo (string) $form;
 }
 function createForm()
 {
     $form = new Am_Form_Admin('aff-general-link');
     $form->addElement('text', 'general_link_url', array('class' => 'el-wide'))->setLabel(___("General Affiliate Link Redirect URL\n" . 'It is url of landing page for default affiliate link (which does not related to any banner), ' . 'home page will be used if you keep it empty'))->setValue($this->getDi()->config->get('aff.general_link_url', ''));
     $form->addSaveButton();
     return $form;
 }
    function createForm()
    {
        $form = new Am_Form_Admin();
        $form->setAttribute('enctype', 'multipart/form-data');
        $form->setAttribute('target', '_top');
        $maxFileSize = min(ini_get('post_max_size'), ini_get('upload_max_filesize'));
        $el = $form->addElement(new Am_Form_Element_Upload('path', array(), array('prefix' => 'video')))->setLabel(___("Video File\n(max upload size %s)", $maxFileSize))->setId('form-path');
        $jsOptions = <<<CUT
{
    onFileAdd : function (info) {
        var txt = \$(this).closest("form").find("input[name='title']");
        if (txt.data('changed-value')) return;
        txt.val(info.name);
    }
}
CUT;
        $el->setJsOptions($jsOptions);
        $form->addScript()->setScript(<<<CUT
\$(function(){
    \$("input[name='title']").change(function(){
        \$(this).data('changed-value', true);
    });
});
CUT
);
        $el->addRule('required');
        $form->addText('title', array('size' => 50))->setLabel(___('Title'))->addRule('required', 'This field is required');
        $form->addText('desc', array('size' => 50))->setLabel(___('Description'))->addRule('required', 'This field is required');
        $form->addAdvCheckbox('hide')->setLabel(___("Hide\n" . "do not display this item link in members area"));
        $form->addElement(new Am_Form_Element_ResourceAccess())->setName('_access')->setLabel(___('Access Permissions'));
        return $form;
    }
Esempio n. 12
0
 public function renderConfigForms()
 {
     $out = "<!-- brick config forms -->";
     foreach ($this->getBricks(self::ALL) as $brick) {
         if (!$brick->haveConfigForm()) {
             continue;
         }
         $form = new Am_Form_Admin();
         $form->setDataSources(array(new Am_Request($brick->getConfigArray())));
         $brick->initConfigForm($form);
         $out .= "<div id='brick-config-{$brick->getId()}' class='brick-config' style='display:none'>\n";
         $out .= "<h1>" . ___("%s Configuration", $brick->getName()) . "</h1>";
         $out .= (string) $form;
         $out .= "</div>\n\n";
     }
     $form = new Am_Form_Admin();
     $form->addElement('textarea', '_tpl', array('rows' => 1, 'cols' => 40))->setLabel('-label-');
     $out .= "<div id='brick-labels' style='display:none'>\n";
     $out .= "<h1>" . ___('Edit Brick Labels') . "</h1>";
     $out .= (string) $form;
     $out .= "</div>\n";
     $out .= "<!-- end of brick config forms -->";
     return $out;
 }
 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 renderLanguageSelection()
 {
     $form = new Am_Form_Admin();
     $form->addElement('select', 'language')->setLabel(___('Language'))->setValue($this->getLanguage())->loadOptions($this->getLanguageOptions());
     $renderer = HTML_QuickForm2_Renderer::factory('array');
     $form->render($renderer);
     $form = $renderer->toArray();
     $filter = '';
     foreach ($form['elements'] as $el) {
         $filter .= ' ' . $el['label'] . ' ' . $el['html'];
     }
     return sprintf("<div class='filter-wrap'><form class='filter' method='get' action='%s'>\n", $this->escape($this->getUrl(null, 'index'))) . $filter . "</form></div>\n";
 }
Esempio n. 15
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;
        }
    }
 function createForm()
 {
     $form = new Am_Form_Admin();
     $text = $form->addElement('text', 'title', array('size' => 60))->setLabel('Title');
     $text->addRule('required');
     $url = $form->addElement('text', 'url', array('size' => 60))->setLabel('Redirect URL');
     $url->addRule('required');
     $form->addElement('textarea', 'desc', array('rows' => 10, 'style' => 'width:90%'))->setLabel(array('Description', ''));
     $form->addElement('hidden', 'type')->setValue($this->affBannerType);
     return $form;
 }
Esempio n. 17
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;
    }
 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;
 }
    protected function createForm()
    {
        $f = new Am_Form_Admin();
        $f->addText('user')->setLabel('Enter username of existing user')->addRule('required', 'This field is required');
        $f->addText('aff')->setLabel('Enter username of existing affiliate')->addRule('required', 'This field is required');
        $f->addText('coupon')->setLabel('Enter coupon code or leave field empty');
        $f->addCheckbox('is_first')->setLabel('Is first user invoice?');
        $f->addElement(new Am_Form_Element_ProductsWithQty('product_id'))->setLabel(___('Choose products to include into test invoice'))->loadOptions(Am_Di::getInstance()->billingPlanTable->selectAllSorted())->addRule('required');
        $f->addSelect('paysys_id')->setLabel(___('Payment System'))->loadOptions(Am_Di::getInstance()->paysystemList->getOptions());
        $f->addSubmit('', array('value' => 'Test'));
        $f->addScript()->setScript(<<<CUT
\$(function(){
    \$("#user-0, #aff-0" ).autocomplete({
        minLength: 2,
        source: window.rootUrl + "/admin-users/autocomplete"
    });
});
CUT
);
        foreach ($this->grid->getVariablesList() as $k) {
            $kk = $this->grid->getId() . '_' . $k;
            if ($v = @$_REQUEST[$kk]) {
                $f->addHidden($kk)->setValue($v);
            }
        }
        return $f;
    }