예제 #1
0
    public function indexAction()
    {
        if ($this->getRequest()->getParam('title') && $this->getRequest()->getParam('actionType')) {
            $productIds = $this->getRequest()->getParam('productIds');
            $prIds = $productIds ? implode(',', $productIds) : implode(',', array_keys($this->getDi()->productTable->getOptions(true)));
            $htmlcode = '
<!-- Button/Link for aMember Shopping Cart -->
<script type="text/javascript">
if (typeof cart  == "undefined")
    document.write("<scr" + "ipt src=\'' . REL_ROOT_URL . '/application/cart/views/public/js/cart.js\'></scr" + "ipt>");
</script>
';
            if ($this->getRequest()->getParam('isLink')) {
                $htmlcode .= '<a href="#" onclick="cart.' . $this->getRequest()->getParam('actionType') . '(this,' . $prIds . '); return false;" >' . $this->getRequest()->getParam('title') . '</a>';
            } else {
                $htmlcode .= '<input type="button" onclick="cart.' . $this->getRequest()->getParam('actionType') . '(this,' . $prIds . '); return false;" value="' . $this->getRequest()->getParam('title') . '">';
            }
            $htmlcode .= '
<!-- End Button/Link for aMember Shopping Cart -->
';
            $this->view->assign('htmlcode', $htmlcode);
            $this->view->display('admin/cart/button-code.phtml');
        } else {
            $form = new Am_Form_Admin();
            $form->addMagicSelect('productIds')->setLabel(___('Select Product(s)
if nothing selected - all products'))->loadOptions($this->getDi()->productTable->getOptions());
            $form->addSelect('isLink')->setLabel(___('Select Type of Element'))->loadOptions(array(0 => 'Button', 1 => 'Link'));
            $form->addSelect('actionType')->setLabel(___('Select Action of Element'))->loadOptions(array('addExternal' => ___('Add to Basket only'), 'addBasketExternal' => ___('Add & Go to Basket'), 'addCheckoutExternal' => ___('Add & Checkout')));
            $form->addText('title')->setLabel(___('Title of Element'))->addRule('required');
            $form->addSaveButton(___('Generate'));
            $this->view->assign('form', $form);
            $this->view->display('admin/cart/button-code.phtml');
        }
    }
 public function createForm()
 {
     $form = new Am_Form_Admin();
     $options = Am_Currency::getSupportedCurrencies();
     array_remove_value($options, Am_Currency::getDefault());
     $sel = $form->addSelect('currency', array('class' => 'am-combobox'))->setLabel(___('Currency'))->loadOptions($options)->addRule('required');
     $date = $form->addDate('date')->setLabel(___('Date'))->addRule('required')->addRule('callback2', "--wrong date--", array($this, 'checkDate'));
     $rate = $form->addText('rate', array('length' => 8))->setLabel(___("Exchange Rate\nenter cost of 1 (one) %s", Am_Currency::getDefault()))->addRule('required');
     return $form;
 }
예제 #3
0
 function changePaysysAction()
 {
     $form = new Am_Form_Admin();
     $form->setDataSources(array($this->_request));
     $form->addStatic()->setContent(___('If you are moving from one payment processor, you can use this page to switch existing subscription from one payment processor to another. It is possible only if full credit card info is stored on aMember side.'));
     $options = array();
     foreach ($this->getModule()->getPlugins() as $ps) {
         $options[$ps->getId()] = $ps->getTitle();
     }
     $from = $form->addSelect('from')->setLabel('Move Active Invoices From')->loadOptions($options)->addRule('required');
     $to = $form->addSelect('to')->setLabel('Move To')->loadOptions($options)->addRule('required');
     $to->addRule('neq', ___('Values must not be equal'), $from);
     $form->addSaveButton();
     if ($form->isSubmitted() && $form->validate()) {
         $vars = $form->getValue();
         $updated = $this->getDi()->db->query("UPDATE ?_invoice SET paysys_id=? WHERE paysys_id=? AND status IN (?a)", $vars['to'], $vars['from'], array(Invoice::RECURRING_ACTIVE));
         $this->view->content = "{$updated} rows changed. New rebills for these invoices will be handled with [{$vars['to']}]";
     } else {
         $this->view->content = (string) $form;
     }
     $this->view->title = ___("Change Paysystem");
     $this->view->display('admin/layout.phtml');
 }
예제 #4
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;
    }
예제 #5
0
파일: Newsletter.php 프로젝트: grlf/eyedock
    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;
    }
 function replaceProductAction()
 {
     $this->getDi()->authAdmin->getUser()->checkPermission('_payment', 'edit');
     $item = $this->getDi()->invoiceItemTable->load($this->_request->getInt('id'));
     $pr = $this->getDi()->productTable->load($item->item_id);
     $form = new Am_Form_Admin('replace-product-form');
     $form->setDataSources(array($this->_request));
     $form->method = 'post';
     $form->addHidden('id');
     $form->addHidden('user_id');
     $form->addStatic()->setLabel(___('Replace Product'))->setContent("#{$pr->product_id} [{$pr->title}]");
     $sel = $form->addSelect('product_id')->setLabel('To Product');
     $options = array('' => '-- ' . ___('Please select') . ' --');
     foreach ($this->getDi()->billingPlanTable->getProductPlanOptions() as $k => $v) {
         if (strpos($k, $pr->pk() . '-') !== 0) {
             $options[$k] = $v;
         }
     }
     $sel->loadOptions($options);
     $sel->addRule('required');
     $form->addSubmit('_save', array('value' => ___('Save')));
     if ($form->isSubmitted() && $form->validate()) {
         try {
             list($p, $b) = explode("-", $sel->getValue(), 2);
             $item->replaceProduct(intval($p), intval($b));
             $this->getDi()->adminLogTable->log("Inside invoice: product #{$item->item_id} replaced to product #{$p} (plan #{$b})", 'invoice', $item->invoice_id);
             return $this->ajaxResponse(array('ok' => true));
         } catch (Am_Exception $e) {
             $sel->setError($e->getMessage());
         }
     }
     echo $form->__toString();
 }
    public function createConfigForm(Am_Grid_Editable $grid)
    {
        $form = new Am_Form_Admin();
        $record = $grid->getRecord($grid->getCurrentAction());
        if (empty($record->type)) {
            $record->type = null;
        }
        if (empty($record->tier)) {
            $record->tier = 0;
        }
        $globalOptions = AffCommissionRule::getTypes();
        $record->type && !isset($globalOptions[$record->type]) && ($globalOptions[$record->type] = $record->getTypeTitle());
        $cb = $form->addSelect('type')->setLabel('Type')->loadOptions($globalOptions);
        if ($record->isGlobal()) {
            $cb->toggleFrozen(true);
        }
        $form->addScript()->setScript(<<<CUT
\$(function(){
    \$("select#type-0").change(function(){
        var val = \$(this).val();
        \$("fieldset#multiplier").toggle(val == 'multi');
        \$("fieldset#commission").toggle(val != 'multi');
        var checked = val.match(/^global-/);
        \$("#conditions").toggle(!checked);
        \$("#sort_order-0").closest(".row").toggle(!checked);
    }).change();

    \$("#condition-select").change(function(){
        var val = \$(this).val();
        \$(this.options[this.selectedIndex]).prop("disabled", true);
        this.selectedIndex = 0;
        \$('input[name="_conditions_status[' + val + ']"]').val(1);
        \$('#row-'+val).show();
    });

    \$("#conditions .row").not("#row-condition-select").each(function(){
        var val = /row-(.*)/i.exec(this.id).pop();
        if (!\$('input[name="_conditions_status[' + val + ']"]').val()) {
            \$(this).hide();
        } else {
            \$("#condition-select option[value='"+val+"']").prop("disabled", true);
        }
        \$(this).find(".element-title").append("&nbsp;<a href='javascript:' class='hide-row'>X</a>&nbsp;");
    });

    \$(document).on('click',"a.hide-row",function(){
        var row = \$(this).closest(".row");
        var id = row.hide().attr("id");
        var val = /row-(.*)/i.exec(id).pop();
        \$('input[name="_conditions_status[' + val + ']"]').val(0);
        \$("#condition-select option[value='"+val+"']").prop("disabled", false);
    });

    \$('#used-type').change(function(){
        \$('#used-batch_id, #used-code').hide();
        switch (\$(this).val()) {
            case 'batch' :
                \$('#used-batch_id').show();
                break;
            case 'coupon' :
                \$('#used-code').show();
                break;
        }

    }).change()
});
CUT
);
        $comment = $form->addText('comment', array('size' => 40))->setLabel('Rule title - for your own reference');
        if ($record->isGlobal()) {
            $comment->toggleFrozen(true);
        } else {
            $comment->addRule('required', 'This field is required');
        }
        if (!$record->isGlobal()) {
            $form->addInteger('sort_order')->setLabel('Sort order - rules with lesser values executed first');
        }
        if (!$record->isGlobal()) {
            $set = $form->addFieldset('', array('id' => 'conditions'))->setLabel('Conditions');
            $set->addSelect('', array('id' => 'condition-select'))->setLabel('Add Condition')->loadOptions(array('' => ___('Select Condition...'), 'first_time' => ___('First Time Purchase of Product'), 'coupon' => ___('By Used Coupon'), 'paysys_id' => ___('By Used Payment System'), 'product_id' => ___('By Product'), 'product_category_id' => ___('By Product Category'), 'aff_group_id' => ___('By Affiliate Group Id'), 'aff_sales_count' => ___('By Affiliate Sales Count'), 'aff_items_count' => ___('By Affiliate Item Sales Count'), 'aff_sales_amount' => ___('By Affiliate Sales Amount'), 'aff_product_id' => ___('By Affiliate Active Product'), 'aff_product_category_id' => ___('By Affiliate Active Product Category')));
            $set->addHidden('_conditions_status[product_id]');
            $set->addMagicSelect('_conditions[product_id]', array('id' => 'product_id'))->setLabel(___("This rule is for particular products\n" . 'if none specified, rule works for all products'))->loadOptions(Am_Di::getInstance()->productTable->getOptions());
            $set->addHidden('_conditions_status[product_category_id]');
            $el = $set->addMagicSelect('_conditions[product_category_id]', array('id' => 'product_category_id'))->setLabel(___("This rule is for particular product categories\n" . "if none specified, rule works for all product categories"));
            $el->loadOptions(Am_Di::getInstance()->productCategoryTable->getAdminSelectOptions());
            $set->addHidden('_conditions_status[aff_group_id]');
            $el = $set->addMagicSelect('_conditions[aff_group_id]', array('id' => 'aff_group_id'))->setLabel(___("This rule is for particular affiliate groups\n" . "you can add user groups and assign it to customers in User editing form"));
            $el->loadOptions(Am_Di::getInstance()->userGroupTable->getSelectOptions());
            $set->addHidden('_conditions_status[aff_sales_count]');
            $gr = $set->addGroup('_conditions[aff_sales_count]', array('id' => 'aff_sales_count'))->setLabel(___("Affiliate sales count\n" . "trigger this commission if affiliate made more than ... sales within ... days before the current date\n" . "(only count of new invoices is calculated)"));
            $gr->addStatic()->setContent('use only if affiliate referred ');
            $gr->addInteger('count', array('size' => 4));
            $gr->addStatic()->setContent(' invoices within last ');
            $gr->addInteger('days', array('size' => 4));
            $gr->addStatic()->setContent(' days');
            $set->addHidden('_conditions_status[aff_items_count]');
            $gr = $set->addGroup('_conditions[aff_items_count]', array('id' => 'aff_items_count'))->setLabel(___("Affiliate items count\n" . "trigger this commission if affiliate made more than ... item sales within ... days before the current date\n" . "(only count of items in new invoices is calculated"));
            $gr->addStatic()->setContent('use only if affiliate made ');
            $gr->addInteger('count', array('size' => 4));
            $gr->addStatic()->setContent(' item sales within last ');
            $gr->addInteger('days', array('size' => 4));
            $gr->addStatic()->setContent(' days');
            $set->addHidden('_conditions_status[aff_sales_amount]');
            $gr = $set->addGroup('_conditions[aff_sales_amount]', array('id' => 'aff_sales_amount'))->setLabel(___("Affiliate sales amount\n" . "trigger this commission if affiliate made more than ... sales within ... days before the current date\n" . "(only new invoices calculated)"));
            $gr->addStatic()->setContent('use only if affiliate made ');
            $gr->addInteger('count', array('size' => 4));
            $gr->addStatic()->setContent(' ' . Am_Currency::getDefault() . ' in commissions within last ');
            $gr->addInteger('days', array('size' => 4));
            $gr->addStatic()->setContent(' days');
            $set->addHidden('_conditions_status[coupon]');
            $gr = $set->addGroup('_conditions[coupon]', array('id' => 'coupon'))->setLabel(___('Used coupon'));
            $gr->setSeparator(' ');
            $gr->addSelect('used')->loadOptions(array('1' => 'Used', '0' => "Didn't Use"));
            $gr->addSelect('type')->setId('used-type')->loadOptions(array('any' => ___('Any Coupon'), 'batch' => ___("Coupon From Batch"), 'coupon' => ___("Specific Coupon")));
            $gr->addSelect('batch_id')->setId('used-batch_id')->loadOptions($this->getDi()->couponBatchTable->getOptions());
            $gr->addText('code', array('size' => 10))->setId('used-code');
            $set->addHidden('_conditions_status[paysys_id]');
            $set->addMagicSelect('_conditions[paysys_id]', array('id' => 'paysys_id'))->setLabel(___('This rule is for particular payment system'))->loadOptions(Am_Di::getInstance()->paysystemList->getOptions());
            $set->addHidden('_conditions_status[first_time]');
            $set->addStatic('_conditions[first_time]', array('id' => 'first_time'))->setLabel(___("First Time Purchase of Product"))->setContent("<div><strong>&#x2713;</strong></div>");
            $set->addHidden('_conditions_status[aff_product_id]');
            $set->addMagicSelect('_conditions[aff_product_id]', array('id' => 'aff_product_id'))->setLabel(___("Apply this rule if affiliate has active access to"))->loadOptions(Am_Di::getInstance()->productTable->getOptions());
            $set->addHidden('_conditions_status[aff_product_category_id]');
            $el = $set->addMagicSelect('_conditions[aff_product_category_id]', array('id' => 'aff_product_category_id'))->setLabel(___("Apply this rule if affiliate has active access to"));
            $el->loadOptions(Am_Di::getInstance()->productCategoryTable->getAdminSelectOptions());
        }
        $set = $form->addFieldset('', array('id' => 'commission'))->setLabel('Commission');
        if ($record->tier == 0) {
            $set->addElement(new Am_Form_Element_AffCommissionSize(null, null, 'first_payment'))->setLabel(___("Commission for First Payment\ncalculated for first payment in each invoice"));
            $set->addElement(new Am_Form_Element_AffCommissionSize(null, null, 'recurring'))->setLabel(___("Commission for Rebills"));
            $group = $set->addGroup('')->setLabel(___("Commission for Free Signup\ncalculated for first customer invoice only"));
            $group->addText('free_signup_c', array('size' => 5));
            $group->addStatic()->setContent('&nbsp;&nbsp;' . Am_Currency::getDefault());
            //->addRule('gte', 'Value must be a valid number > 0, or empty (no text)', 0);
        } else {
            $set->addText('first_payment_c')->setLabel(___("Commission\n% of commission received by referred affiliate"));
        }
        if (!$record->isGlobal()) {
            $set = $form->addFieldset('', array('id' => 'multiplier'))->setLabel('Multipier');
            $set->addText('multi', array('size' => 5, 'placeholder' => '1.0'))->setLabel(___("Multiply commission calculated by the following rules\n" . "to number specified in this field. To keep commission untouched, enter 1 or delete this rule"));
            //->addRule('gt', 'Values must be greater than 0.0', 0.0);
        }
        return $form;
    }
    public function createConfigForm(Am_Grid_Editable $grid)
    {
        $form = new Am_Form_Admin();
        $record = $grid->getRecord($grid->getCurrentAction());
        if (empty($record->type)) {
            $record->type = null;
        }
        $globalOptions = AffCommissionRule::getTypes();
        foreach (Am_Di::getInstance()->db->selectCol("SELECT DISTINCT `type` FROM ?_aff_commission_rule") as $type) {
            if (AffCommissionRule::isGlobalType($type) && $type != $record->type) {
                unset($globalOptions[$type]);
            }
        }
        $cb = $form->addSelect('type')->setLabel('Type')->loadOptions($globalOptions);
        if ($record->isGlobal()) {
            $cb->toggleFrozen(true);
        }
        $form->addScript()->setScript(<<<CUT
\$(function(){
    \$("select#type-0").change(function(){
        var val = \$(this).val();
        \$("fieldset#multiplier").toggle(val == 'multi');
        \$("fieldset#commission").toggle(val != 'multi');
        var checked = val.match(/^global-/);
        \$("#conditions").toggle(!checked);
        \$("#sort_order-0").closest(".row").toggle(!checked);
        \$("#comment-0").closest(".row").toggle(!checked);
    }).change();
    
    \$("#condition-select").change(function(){
        var val = \$(this).val();
        \$(this.options[this.selectedIndex]).prop("disabled", true);
        this.selectedIndex = 0;
        \$('#'+val).show();
    });

    \$("#conditions .row").not("#row-condition-select").each(function(){
        if (!\$(":input:filled", this).not(".magicselect").length && !\$(".magicselect-item", this).length) 
            \$(this).hide();
        else
            \$("#condition-select option[value='"+this.id+"']").prop("disabled", true);
        \$(this).find(".element-title").append("&nbsp;<a href='javascript:' class='hide-row'>X</a>&nbsp;");
    });

    \$("a.hide-row").live('click',function(){
        var row = \$(this).closest(".row");
        row.find("a.hide-row").remove();
        var id = row.hide().attr("id");
        \$("#condition-select option[value='"+id+"']").prop("disabled", false);
    });
});
CUT
);
        $form->addText('comment', array('size' => 40))->setLabel('Rule title - for your own reference')->addRule('required', 'This field is required');
        $form->addInteger('sort_order')->setLabel('Sort order - rules with lesser values executed first');
        if (!$record->isGlobal()) {
            $set = $form->addFieldset('', array('id' => 'conditions'))->setLabel('Conditions');
            $set->addSelect('', array('id' => 'condition-select'))->setLabel('Add Condition')->loadOptions(array('' => 'Select Condition...', 'row-product_id' => 'By Product', 'row-product_category_id' => 'By Product Category', 'row-aff_group_id' => 'By Affiliate Group Id', 'row-aff_sales_count' => 'By Affiliate Sales Count', 'row-aff_sales_amount' => 'By Affiliate Sales Amount'));
            $set->addMagicSelect('_conditions[product_id]', array('id' => 'product_id'))->setLabel(array('This rule is for particular products', 'if none specified, rule works for all products'))->loadOptions(Am_Di::getInstance()->productTable->getOptions());
            $el = $set->addMagicSelect('_conditions[product_category_id]', array('id' => 'product_category_id'))->setLabel(array('This rule is for particular product categories', 'if none specified, rule works for all product categories'));
            $el->loadOptions(Am_Di::getInstance()->productCategoryTable->getAdminSelectOptions());
            $el = $set->addMagicSelect('_conditions[aff_group_id]', array('id' => 'aff_group_id'))->setLabel(array('This rule is for particular affiliate groups', 'you can add user groups and assign it to customers in User editing form'));
            $el->loadOptions(Am_Di::getInstance()->userGroupTable->getSelectOptions());
            $gr = $set->addGroup('_conditions[aff_sales_count]', array('id' => 'aff_sales_count'))->setLabel(array('Affiliate sales count', 'trigger this commission if affiliate made more than ... sales within ... days before the current date' . PHP_EOL . '(recurring: affiliate sales count will be recalculated on each rebill)'));
            $gr->addStatic()->setContent('use only if affiliate made ');
            $gr->addInteger('count', array('size' => 4));
            $gr->addStatic()->setContent(' commissions within last ');
            $gr->addInteger('days', array('size' => 4));
            $gr->addStatic()->setContent(' days');
            $gr = $set->addGroup('_conditions[aff_sales_amount]', array('id' => 'aff_sales_amount'))->setLabel(array('Affiliate sales amount', 'trigger this commission if affiliate made more than ... sales within ... days before the current date' . PHP_EOL . '(recurring: affiliate sales count will be recalculated on each rebill)'));
            $gr->addStatic()->setContent('use only if affiliate made ');
            $gr->addInteger('count', array('size' => 4));
            $gr->addStatic()->setContent(' ' . Am_Currency::getDefault() . ' in commissions within last ');
            $gr->addInteger('days', array('size' => 4));
            $gr->addStatic()->setContent(' days');
        }
        $set = $form->addFieldset('', array('id' => 'commission'))->setLabel('Commission');
        if ($record->type != AffCommissionRule::TYPE_GLOBAL_2) {
            $set->addElement(new Am_Form_Element_AffCommissionSize(null, null, 'first_payment'))->setLabel(___("Commission for First Payment\ncalculated for first payment in each invoice"));
            $set->addElement(new Am_Form_Element_AffCommissionSize(null, null, 'recurring'))->setLabel(___("Commission for Rebills"));
            $set->addText('free_signup_c')->setLabel(___("Commission for Free Signup\ncalculated for first customer invoice only"));
            //->addRule('gte', 'Value must be a valid number > 0, or empty (no text)', 0);
        } else {
            $set->addText('first_payment_c')->setLabel(___("Second Level Commission\n% of commission received by referred affiliate"));
        }
        if (!$record->isGlobal()) {
            $set = $form->addFieldset('', array('id' => 'multiplier'))->setLabel('Multipier');
            $set->addText('multi', array('size' => 5, 'placeholder' => '1.0'))->setLabel(array(___("Multiply commission calculated by the following rules\n                    to number specified in this field. To keep commission untouched, enter 1 or delete this rule")));
            //->addRule('gt', 'Values must be greater than 0.0', 0.0);
        }
        return $form;
    }
예제 #10
0
    public function createUpgradesForm(Am_Grid_Editable $grid)
    {
        $form = new Am_Form_Admin();
        $options = $grid->_planOptions;
        $from = $form->addSelect('from_billing_plan_id', null, array('options' => $options))->setLabel(___('Upgrade From'));
        $to = $form->addSelect('to_billing_plan_id', null, array('options' => $options))->setLabel(___('Upgrade To'));
        $to->addRule('neq', ___('[From] and [To] billing plans must not be equal'), $from);
        $form->addText('surcharge', array('placeholder' => '0.0'))->setLabel(___("Surcharge\nto be additionally charged when customer moves [From]->[To] plan\naMember will not charge First Price on upgrade, use Surcharge instead"));
        $el = $form->addAdvRadio('type')->setLabel(___('Upgrade Price Calculation Type'));
        $el->addOption(<<<CUT
          <b>Default</b> - Unused amount from previous subscription  will be applied as discount to new one
CUT
, ProductUpgrade::TYPE_DEFAULT);
        $el->addOption(<<<CUT
          <b>Flat</b> - User only pay flat rate on upgrade (Surcharge amount)
CUT
, ProductUpgrade::TYPE_FLAT);
        return $form;
    }
 public function createUpgradesForm()
 {
     $form = new Am_Form_Admin();
     $options = $this->getDi()->db->selectCol("SELECT concat(b.plan_id) AS ARRAY_KEY, concat(p.title, '/',b.title)\n            FROM ?_billing_plan b RIGHT JOIN ?_product p USING (product_id)\n            ORDER BY b.product_id");
     $from = $form->addSelect('from_billing_plan_id', null, array('options' => $options))->setLabel(___('Upgrade From'));
     $to = $form->addSelect('to_billing_plan_id', null, array('options' => $options))->setLabel(___('Upgrade To'));
     $to->addRule('neq', ___('[From] and [To] billing plans must not be equal'), $from);
     $form->addText('surcharge', array('placeholder' => '0.0'))->setLabel(___('Surcharge'));
     return $form;
 }
예제 #12
0
    protected function createForm()
    {
        $form = new Am_Form_Admin('EmailTemplate');
        $form->addElement(new Am_Form_Element_Html('info'))->setLabel(___('Template'))->setHtml(sprintf('<div><strong>%s</strong><br /><small>%s</small></div>', $this->escape($this->getParam('name')), $this->escape($this->getParam('label'))));
        $form->addElement('hidden', 'name');
        $langOptions = $this->getLanguageOptions($this->getDi()->config->get('lang.enabled', array($this->getDi()->config->get('lang.default', 'en'))));
        /* @var $lang HTML_QuickForm2_Element */
        $lang = $form->addElement('select', 'lang')->setId('lang')->setLabel(___('Language'))->loadOptions($langOptions);
        if (count($langOptions) == 1) {
            $lang->toggleFrozen(true);
        }
        $lang->addRule('required');
        if ($options = $this->getDi()->emailTemplateLayoutTable->getOptions()) {
            $form->addSelect('email_template_layout_id')->setLabel(___('Layout'))->loadOptions(array('' => ___('No Layout')) + $options);
        }
        $tt = Am_Mail_TemplateTypes::getInstance()->find($this->getParam('name'));
        if ($tt && !empty($tt['isAdmin'])) {
            $op = array('-1' => Am_Controller::escape(sprintf('%s <%s>', Am_Di::getInstance()->config->get('site_title') . ' Admin', Am_Di::getInstance()->config->get('admin_email'))));
            foreach (Am_Di::getInstance()->adminTable->findBy() as $admin) {
                $op[$admin->pk()] = Am_Controller::escape(sprintf('%s <%s>', $admin->getName(), $admin->email));
            }
            $form->addMagicSelect('_admins', array('value' => 'default'))->setLabel(___('Admin Recipients'))->loadOptions($op)->addRule('required');
        } else {
            $form->addText('bcc', array('class' => 'el-wide', 'placeholder' => ___('Email Addresses Separated by Comma')))->setLabel(___("BCC\n" . "blind carbon copy allows the sender of a message to conceal the person entered in the Bcc field from the other recipients"))->addRule('callback', ___('Please enter valid e-mail addresses'), array('Am_Validate', 'emails'));
        }
        $form->addScript()->setScript(<<<CUT
\$("#checkbox-recipient-other").change(function(){
\$("#row-input-recipient-emails").toggle(this.checked);
}).change();
CUT
);
        $body = $form->addElement(new Am_Form_Element_MailEditor($this->getParam('name')));
        $form->addElement('hidden', 'label')->setValue($this->getParam('label'));
        return $form;
    }
 function createImportForm(&$defaults)
 {
     $form = new Am_Form_Admin();
     /** count imported */
     $imported_products = $this->getDi()->db->selectCell("SELECT COUNT(id) FROM ?_data WHERE `table`='product' AND `key`='wom:id'");
     $wopCfg = $this->db_wordpress->selectCell("SELECT option_value FROM ?_options WHERE option_name = ?", 'ws_plugin__optimizemember_options');
     $wopCfg = unserialize($wopCfg);
     if (is_array($wopCfg)) {
         $amProducts = array('' => '-- Please Select --') + $this->getDi()->productTable->getOptions();
         $womProducts = array();
         for ($i = 0; $i <= 10; $i++) {
             $womProducts['level' . ($i ? $i : '')] = $wopCfg['level' . $i . '_label'];
         }
         if ($imported_products) {
             $cb = $form->addStatic()->setContent("Linked");
         } else {
             $cb = $form->addRadio('import', array('value' => 'product'));
             foreach ($womProducts as $key => $value) {
                 $form->addSelect("pr_link[" . $key . "]")->setLabel($value)->loadOptions($amProducts);
             }
             $form->addRule('callback2', '-error-', array($this, 'validateForm'));
         }
         $cb->setLabel('Link Products');
     }
     if (!is_array($wopCfg) || $imported_products) {
         $imported_users = $this->getDi()->db->selectCell("SELECT COUNT(id) FROM ?_data WHERE `table`='user' AND `key`='wom:id'");
         $total = $this->db_wordpress->selectCell("SELECT COUNT(*) FROM ?_users");
         if ($imported_users >= $total) {
             $cb = $form->addStatic()->setContent("Imported ({$imported_users})");
         } else {
             $cb = $form->addGroup();
             if ($imported_users) {
                 $cb->addStatic()->setContent("partially imported ({$imported_users} of {$total} total)<br /><br />");
             }
             $cb->addRadio('import', array('value' => 'user'));
             $cb->addStatic()->setContent('<br /><br /># of users (keep empty to import all) ');
             $cb->addInteger('user[count]');
             $cb->addStatic()->setContent('<br />Keep the same user IDs');
             $keep_id_chkbox = $cb->addCheckbox('user[keep_user_id]');
             if ($this->getDi()->db->selectCell("SELECT COUNT(*) FROM ?_user")) {
                 $keep_id_chkbox->setAttribute('disabled');
                 $cb->addStatic()->setContent('User database have records already. Please use Clean Up if you want to keep the same user IDs');
             }
         }
         $cb->setLabel('Import User and Payment Records');
     }
     $form->addSaveButton('Run');
     $defaults = array();
     return $form;
 }
예제 #14
0
    function changePaysysAction()
    {
        $form = new Am_Form_Admin();
        $form->setDataSources(array($this->_request));
        $form->addStatic()->setContent(___('If you are moving from one payment processor, you can use this page to switch existing subscription from one payment processor to another. It is possible only if full credit card info is stored on aMember side.'));
        $ccPlugins = $echeckPlugins = array();
        foreach ($this->getModule()->getPlugins() as $ps) {
            if ($ps instanceof Am_Paysystem_CreditCard) {
                $ccPlugins[$ps->getId()] = $ps->getTitle();
            } elseif ($ps instanceof Am_Paysystem_Echeck) {
                $echeckPlugins[$ps->getId()] = $ps->getTitle();
            }
        }
        if (count($ccPlugins) < 2) {
            $ccPlugins = array();
        }
        if (count($echeckPlugins) < 2) {
            $echeckPlugins = array();
        }
        $options = array('' => '-- ' . ___('Please select') . ' --') + ($ccPlugins ? array(___('Credit Card Plugins') => $ccPlugins) : array()) + ($echeckPlugins ? array(___('Echeck Plugins') => $echeckPlugins) : array());
        $from = $form->addSelect('from', array('id' => 'paysys_from'))->setLabel('Move Active Invoices From')->loadOptions($options);
        $from->addRule('required');
        $to = $form->addSelect('to', array('id' => 'paysys_to'))->setLabel('Move To')->loadOptions($options);
        $to->addRule('required');
        $to->addRule('neq', ___('Values must not be equal'), $from);
        $form->addScript()->setScript(<<<CUT
jQuery(function(\$){
    \$("#paysys_from").on('change', function(){
        \$("#paysys_to").find('option').removeAttr("disabled");
        \$("#paysys_to").removeAttr("disabled","disabled");
        val_from = \$(this).val();
        if (!val_from){
            \$("#paysys_to").val('');
            \$("#paysys_to").attr("disabled","disabled");
            return;
        }
        val_to = \$("#paysys_to").val();

        if(val_from == val_to)
            \$("#paysys_to").val('');

        obj_to = \$("#paysys_to").find('option[value="'+\$(this).val()+'"]');
        obj_to.attr("disabled","disabled");
        \$("#paysys_to").find('optgroup[label!="'+obj_to.parent().attr('label')+'"]').find('option').attr("disabled","disabled");
    }).change();
});
CUT
);
        $form->addSaveButton();
        if ($form->isSubmitted() && $form->validate()) {
            $vars = $form->getValue();
            $updated = $this->getDi()->db->query("UPDATE ?_invoice SET paysys_id=? WHERE paysys_id=? AND status IN (?a)", $vars['to'], $vars['from'], array(Invoice::RECURRING_ACTIVE));
            $this->view->content = "{$updated} rows changed. New rebills for these invoices will be handled with [{$vars['to']}]";
        } else {
            $this->view->content = (string) $form;
        }
        $this->view->title = ___("Change Paysystem");
        $this->view->display('admin/layout.phtml');
    }
예제 #15
0
 function createForm()
 {
     $form = new Am_Form_Admin();
     $form->addText('comment', array('class' => 'el-wide'))->setLabel(___("Comment\n" . 'for your reference'))->addRule('required');
     $sel = $form->addMagicSelect('conditions[product]')->setLabel(___("Conditions\n" . 'After actual payment aMember will check user invoice and in case ' . 'of it contains one of defined  product or product from defined ' . 'product category this OTO will be shown for him instead of ' . 'ordinary thank you page. In case of you use OTO (Downsell) ' . 'condition it will be matched if user click NO link in defined ' . 'offer and this OTO will be shown for user'));
     $cats = $pr = $oto = array();
     foreach ($this->getDi()->productCategoryTable->getAdminSelectOptions() as $k => $v) {
         $cats['category-' . $k] = ___('Category') . ':' . $v;
     }
     foreach ($this->getDi()->productTable->getOptions() as $k => $v) {
         $pr['product-' . $k] = ___('Product') . ':' . $v;
     }
     foreach ($this->getDi()->otoTable->getOptions() as $k => $v) {
         $oto['oto-' . $k] = ___('OTO') . ':' . $v;
     }
     $options = array(___('Categories') => $cats) + ($pr ? array(___('Products') => $pr) : array()) + ($oto ? array(___('OTO (Downsell)') => $oto) : array());
     $sel->loadOptions($options);
     $sel->addRule('required');
     $bpOptions = array();
     foreach ($this->getDi()->productTable->findBy(array('is_archived' => 0)) as $product) {
         /* @var $product Product */
         foreach ($product->getBillingOptions() as $bp_id => $title) {
             $bpOptions[$product->pk() . '-' . $bp_id] = sprintf('(%d) %s (%s)', $product->pk(), $product->title, $title);
         }
     }
     $form->addSelect('product_id')->setLabel('Product to Offer')->loadOptions($bpOptions)->addRule('required');
     $coupons = array('' => '');
     foreach ($this->getDi()->db->selectCol("\n\t\tSELECT c.coupon_id as ARRAY_KEY,\n\t\tCONCAT(c.code, ' - ' , b.comment)\n\t\tFROM ?_coupon c LEFT JOIN ?_coupon_batch b USING (batch_id)\n\t\tORDER BY c.code\n        ") as $k => $v) {
         $coupons[$k] = $v;
     }
     $form->addSelect('coupon_id')->setLabel(___('Apply Coupon (optional)'))->loadOptions($coupons);
     $psList = array('' => '') + $this->getDi()->paysystemList->getOptionsPublic();
     $form->addSelect('view[paysys_id]')->setLabel(___('Paysystem (optional)'))->loadOptions($psList);
     $fs = $form->addFieldSet()->setLabel(___('Offer Page Settings'));
     $fs->addText('view[title]', array('class' => 'el-wide'))->setLabel(___('Title'));
     $fs->addHtmlEditor('view[html]')->setLabel("Offer Text\nuse %yes% and %no% to insert buttons");
     $fs->addHtmlEditor('view[yes][label]')->setLabel('[Yes] button text');
     $fs->addHtmlEditor('view[no][label]')->setLabel('[No] button code');
     $fs->addAdvCheckbox('view[no_layout]')->setLabel(___("Avoid using standard layout\nyou have to design entire page in the 'Offer Text' field"));
     return $form;
 }
    function createForm()
    {
        $form = new Am_Form_Admin();
        $plugins = $form->addSelect('plugin')->setLabel(___('Plugin'));
        $plugins->addRule('required');
        $plugins->addOption('*** ' . ___('Select a plugin') . ' ***', '');
        foreach (Am_Di::getInstance()->plugins_protect->getAllEnabled() as $plugin) {
            if (!$plugin->isConfigured()) {
                continue;
            }
            $group = $form->addFieldset($plugin->getId())->setId('headrow-' . $plugin->getId());
            $group->setLabel($plugin->getTitle());
            $plugin->getIntegrationFormElements($group);
            // add id[...] around the element name
            foreach ($group->getElements() as $el) {
                $el->setName('_plugins[' . $plugin->getId() . '][' . $el->getName() . ']');
            }
            if (!$group->count()) {
                $form->removeChild($group);
            } else {
                $plugins->addOption($plugin->getTitle(), $plugin->getId());
            }
        }
        $group = $form->addFieldset('access')->setLabel(___('Access'));
        $group->addElement(new Am_Form_Element_ResourceAccess())->setName('_access')->setLabel(___('Access Permissions'))->setAttribute('without_period', 'true');
        $form->addScript()->setScript(<<<CUT
\$(function(){
    \$("select[name='plugin']").change(function(){
        var selected = \$(this).val();
        \$("[id^='headrow-']").hide();
        if (selected) {
            \$("[id^=headrow-"+selected+"]").show();
        }
    }).change();
});
CUT
);
        return $form;
    }
예제 #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;
    }
예제 #18
0
    function askRemoteAccess()
    {
        $form = new Am_Form_Admin();
        $info = $this->loadRemoteAccess();
        if ($info && !empty($info['_tested'])) {
            return true;
        }
        if ($info) {
            $form->addDataSource(new Am_Request($info));
        }
        $method = $form->addSelect('method', null, array('options' => array('ftp' => 'FTP', 'sftp' => 'SFTP')))->setLabel(___('Access Method'));
        $gr = $form->addGroup('hostname')->setLabel(___('Hostname'));
        $gr->addText('host')->addRule('required')->addRule('regex', 'Incorrect hostname value', '/^[\\w\\._-]+$/');
        $gr->addHTML('port-label')->setHTML('&nbsp;<b>Port</b>');
        $gr->addText('port', array('size' => 3));
        $gr->addHTML('port-notice')->setHTML('&nbsp;leave empty if default');
        $form->addText('user')->setLabel(___('Username'))->addRule('required');
        $form->addPassword('pass')->setLabel(___('Password'));
        //        $form->addTextarea('ssh_public_key')->setLabel(___('SSH Public Key'));
        //        $form->addTextarea('ssh_private_key')->setLabel(___('SSH Private Key'));
        $form->addSubmit('', array('value' => ___('Continue')));
        $form->addScript()->setScript(<<<CUT
\$(function(){
    \$('#method-0').change(function(){
        \$('#ssh_public_key-0,#ssh_private_key-0').closest('.row').toggle( \$(this).val() == 'ssh' );
    }).change();
});
CUT
);
        $error = null;
        $vars = $form->getValue();
        if ($form->isSubmitted() && $form->validate() && !($error = $this->tryConnect($vars))) {
            $vars['_tested'] = true;
            $this->storeRemoteAccess($vars);
            return true;
        } else {
            //$this->view->title = ___("File Access Credentials Required");
            $this->view->title = ___('Upgrade');
            $this->view->content = "";
            $this->outStepHeader();
            if ($error) {
                $method->setError($error);
            }
            $this->view->content .= (string) $form;
            $this->view->display('admin/layout.phtml');
            $this->noDisplay = true;
        }
    }
예제 #19
0
 public function createWidgetReportConfigForm()
 {
     $form = new Am_Form_Admin();
     $form->addSelect('type')->setLabel(___('Display Type'))->setValue('graph-line')->loadOptions(array('graph-line' => ___('Graph Line'), 'graph-bar' => ___('Graph Bar'), 'table' => ___('Table')));
     return $form;
 }