public function createForm(Am_Grid_Editable $grid)
 {
     $id = substr($grid->getId(), 1);
     $form = new Am_Form_Admin();
     $form->addText("value", array('size' => 40))->setLabel(___("Value\nuse % as wildcard mask"));
     $form->addHidden("type")->setValue($id);
     $form->addText('comment', array('size' => 40))->setLabel(___("Comment"));
     return $form;
 }
예제 #2
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');
        }
    }
예제 #3
0
 function createForm()
 {
     $form = new Am_Form_Admin();
     $form->addInteger("tag")->setLabel(___("Sort order"))->addRule('required');
     $form->addAdvCheckbox('_is_disabled')->setLabel(___('Is&nbsp;Disabled?'));
     $form->addText("title")->setLabel(___("Title"))->addRule('required');
     return $form;
 }
예제 #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
 function createForm()
 {
     $form = new Am_Form_Admin();
     $form->addText('comment', 'size=60')->setLabel(___('Comment'))->addRule('required');
     $form->addText('key', 'size=60 maxlength=50')->setLabel(___('Api Key'))->addRule('required')->addRule('regex', ___('Digits and latin letters only please'), '/^[a-zA-Z0-9]+$/')->addRule('minlength', ___('Key must be 20 chars or longer'), 20);
     $form->addAdvCheckbox('is_disabled')->setLabel(___('Is Disabled'));
     $fs = $form->addFieldset('perms')->setLabel(___('Permissions'));
     $gr = $fs->addGroup('', array('class' => 'no-label'));
     $module = $this->getModule();
     foreach ($module->getControllers() as $alias => $record) {
         $gr->addStatic()->setContent("<div style='width: 30%; font-weight: bold;'>{$alias}  - " . $record['comment'] . '</div>');
         foreach ($record['methods'] as $method) {
             $gr->addCheckbox("_perms[{$alias}][{$method}]")->setContent($method);
         }
         $gr->addStatic()->setContent("<br />");
     }
     return $form;
 }
 public function createForm()
 {
     $f = new Am_Form_Admin();
     $g = $f->addGroup()->setLabel('Name');
     $g->addText('name_f', array('size' => 40));
     $g->addText('name_l', array('size' => 40));
     $f->addText('email', array('size' => 40))->setLabel('E-Mail Address')->addRule('required')->addRule('callback', ___("Please enter valid e-mail address"), array('Am_Validate', 'email'));
     $f->addMagicSelect('_s')->setLabel('Lists')->loadOptions($this->lists);
     return $f;
 }
 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;
 }
 public function createForm()
 {
     $form = new Am_Form_Admin();
     $form->setAttribute('enctype', 'multipart/form-data');
     $file = $form->addElement('file', 'upload[]')->setLabel(___('File'))->setAttribute('class', 'styled');
     $file->addRule('required');
     $form->addText('desc', array('class' => 'el-wide'))->setLabel(___('Description'));
     $form->addHidden('prefix')->setValue($this->prefix);
     return $form;
 }
 public function createForm($grid)
 {
     $form = new Am_Form_Admin();
     $name = $form->addText('name', array('class' => 'el-wide'))->setLabel(___('Title'));
     $r = $grid->getRecord();
     if ($r->isLoaded() && $r->pk() < self::DEFAULT_LAYOUT_THRESHOLD) {
         $name->toggleFrozen('true');
     } else {
         $name->addRule('required');
     }
     $form->addTextarea('layout', array('rows' => 25, 'class' => 'row-wide el-wide'))->setLabel(___("Layout\n" . "use placholder %content% for email output"))->addRule('callback', ___('Your layout has not %content% placeholder'), array($this, 'checkLayout'));
     return $form;
 }
예제 #10
0
 function createForm()
 {
     $form = new Am_Form_Admin();
     $form->addInteger("tag")->setLabel(___("Sort order"))->addRule('required');
     $form->addAdvCheckbox('_is_disabled')->setLabel(___('Is&nbsp;Disabled?'));
     $form->addText('title')->setLabel(___('Title'))->addRule('required');
     if (!$this->grid->getRecord()->pk()) {
         $gr = $form->addGroup();
         $gr->addStatic()->setContent('<span>' . $this->country . '-</span>');
         $gr->addText('state', array('size' => 5))->addRule('required');
         $gr->setLabel(___('Code'));
     }
     $form->addHidden('country');
     return $form;
 }
 public function getAddForm()
 {
     $form = new Am_Form_Admin();
     $form->setAction($url = $this->getUrl(null, 'c', null, 'payments', 'addpayment', 'user_id', $this->user_id));
     $form->addText("receipt_id", array('tabindex' => 2))->setLabel("Receipt#")->addRule('required');
     $amt = $form->addSelect("amount", array('tabindex' => 3), array('intrinsic_validation' => false))->setLabel("Amount");
     $amt->addRule('required', 'This field is required');
     if ($this->_request->getInt('invoice_id')) {
         $invoice = $this->getDi()->invoiceTable->load($this->_request->getInt('invoice_id'));
         if (!$invoice->first_total || $invoice->getPaymentsCount()) {
             $amt->addOption($invoice->second_total, $invoice->second_total);
         } else {
             $amt->addOption($invoice->first_total, $invoice->first_total);
         }
     }
     $form->addSelect("paysys_id", array('tabindex' => 1))->setLabel("Payment System")->loadOptions($this->getDi()->paysystemList->getOptions());
     $date = $form->addDate("dattm", array('tabindex' => 4))->setLabel("Date Of Transaction");
     $date->addRule('required', 'This field is required');
     $date->setValue(sqlDate('now'));
     $form->addHidden("invoice_id");
     $form->addSaveButton();
     return $form;
 }
예제 #12
0
파일: Void.php 프로젝트: grlf/eyedock
 function run()
 {
     $form = new Am_Form_Admin('form-vomm-void');
     $form->setAttribute('name', 'void');
     $comm = $this->grid->getRecord();
     $form->addText('amount', array('size' => 6))->setlabel(___('Void Amount'));
     foreach ($this->grid->getVariablesList() as $k) {
         $form->addHidden($this->grid->getId() . '_' . $k)->setValue($this->grid->getRequest()->get($k, ""));
     }
     $g = $form->addGroup();
     $g->setSeparator(' ');
     $g->addSubmit('_save', array('value' => ___("Void")));
     $g->addStatic()->setContent(sprintf('<a href="%s" class="link" style="margin-left:0.5em">%s</a>', $this->grid->getBackUrl(), ___('Cancel')));
     $form->setDataSources(array($this->grid->getCompleteRequest(), new HTML_QuickForm2_DataSource_Array(array('amount' => $comm->amount))));
     if ($form->isSubmitted() && $form->validate()) {
         $values = $form->getValue();
         $this->void($values['amount']);
         $this->grid->redirectBack();
     } else {
         echo $this->renderTitle();
         echo $form;
     }
 }
예제 #13
0
    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;
    }
예제 #14
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;
 }
예제 #15
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;
    }
예제 #16
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;
    }
예제 #18
0
    function run()
    {
        $form = new Am_Form_Admin('form-grid-merge');
        $form->setAttribute('name', 'merge');
        $user = $this->grid->getRecord();
        $login = $form->addText('login');
        $login->setId('login')->setLabel(___("Username of Source User\nmove information from"));
        $login->addRule('callback', ___('Can not find user with such username'), array($this, 'checkUser'));
        $login->addRule('callback', ___('You can not merge user with itself'), array($this, 'checkIdenticalUser'));
        $target = $form->addStatic()->setContent(sprintf('<div>%s</div>', Am_Controller::escape($user->login)));
        $target->setLabel(___("Target User\nmove information to"));
        $script = <<<CUT
        \$("input#login").autocomplete({
                minLength: 2,
                source: window.rootUrl + "/admin-users/autocomplete"
        });
CUT;
        $form->addStatic('', array('class' => 'no-label'))->setContent('<div class="info"><strong>' . ___("WARNING! Once [Merge] button clicked, all invoices, payments, logs\n" . "and other information regarding 'Source User' will be moved\n" . "to the 'Target User' account. 'Source User' account will be deleted.\n" . "There is no way to undo this operation!") . '</strong></div>');
        $form->addScript('script')->setScript($script);
        foreach ($this->grid->getVariablesList() as $k) {
            $form->addHidden($this->grid->getId() . '_' . $k)->setValue($this->grid->getRequest()->get($k, ""));
        }
        $form->addSaveButton(___("Merge"));
        $form->setDataSources(array($this->grid->getCompleteRequest()));
        if ($form->isSubmitted() && $form->validate()) {
            $values = $form->getValue();
            $this->merge($this->grid->getRecord(), Am_Di::getInstance()->userTable->findFirstByLogin($values['login']));
            $this->grid->redirectBack();
        } else {
            echo $this->renderTitle();
            echo $form;
        }
    }
예제 #19
0
 function createSaveReportForm($title)
 {
     $form = new Am_Form_Admin();
     $form->addText('title', array('class' => 'el-wide'))->setLabel(___('Title of Report for your Reference'))->setValue($title)->addRule('required');
     $form->addAdvCheckbox('add-to-dashboard')->setLabel(___('Add Report to My Dashboard'))->setValue(1);
     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;
 }
예제 #21
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;
    }
예제 #22
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;
    }
예제 #23
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();
        $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;
    }
 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;
 }
예제 #26
0
파일: Controller.php 프로젝트: grlf/eyedock
 public function createForm()
 {
     $form = new Am_Form_Admin();
     $form->addText('title', array('class' => 'el-wide'))->setLabel(___('Title'))->addRule('required');
     $form->addTextarea('content', array('class' => 'el-wide', 'rows' => 10))->setLabel(___('Content'))->addRule('required');
     return $form;
 }
 /** @return Am_Form_Admin */
 function createMysqlForm()
 {
     $form = new Am_Form_Admin();
     $el = $form->addText('host')->setLabel('Wordpress  MySQL Hostname');
     $el->addRule('required', 'This field is required');
     $form->addText('user')->setLabel('Wordpress  MySQL Username')->addRule('required', 'This field is required');
     $form->addPassword('pass')->setLabel('Wordpress MySQL Password');
     $form->addText('db')->setLabel('Wordpress MySQL Database Name')->addRule('required', 'This field is required');
     $form->addText('prefix')->setLabel('Wordpress Tables Prefix');
     $dbConfig = $this->getDi()->getParameter('db');
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('host' => $dbConfig['mysql']['host'], 'user' => $dbConfig['mysql']['user'], 'prefix' => 'wp_')));
     $el->addRule('callback2', '-', array($this, 'validateDbConnect'));
     $form->addSubmit(null, array('value' => 'Continue...'));
     return $form;
 }
예제 #28
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;
        }
    }
    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;
    }