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;
 }
Ejemplo n.º 2
0
 function createForm()
 {
     $form = new Am_Form_Admin();
     $form->addInteger("tag")->setLabel(___("Sort order"))->addRule('required');
     $form->addAdvCheckbox('_is_disabled')->setLabel(___('Is 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;
 }
Ejemplo n.º 3
0
 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;
     }
 }
 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`='am3:id'");
     $total = $this->db3->selectCell("SELECT COUNT(*) FROM ?_products");
     if ($total_products = $this->getDi()->db->selectCell("SELECT COUNT(*) FROM ?_product")) {
         $form->addStatic()->setLabel(___('Clean up v4 Database'))->setContent(sprintf(___('Use this %slink%s to delete data from aMember v4 database and use clean database for import'), '<a href="' . REL_ROOT_URL . '/admin-import3/clean">', '</a>'));
     }
     $cb = $form->addGroup();
     if ($imported_products >= $total) {
         $cb->addStatic()->setContent("Imported ({$imported_products} of {$total})");
     } else {
         $cb->addRadio('import', array('value' => 'product'));
     }
     $cb->setLabel('Import Products');
     $cb->addStatic()->setContent('<br />Keep the same Product  IDs');
     $keep_id_chkbox = $cb->addCheckbox('product[keep_product_id]');
     if ($imported_products < $total && $this->db3->selectCell("SELECT COUNT(*) FROM ?_products WHERE data like '%subusers_count%'") && !in_array('subusers', $this->getDi()->modules->getEnabled())) {
         $cb->addStatic()->setContent('<br />Enable [subusers] module in Setup/Configuration to import subusers information');
     }
     if ($total_products) {
         $keep_id_chkbox->setAttribute('disabled');
         $cb->addStatic()->setContent('Product table have records already. Please use Clean Up if you want to keep the same product IDs');
     }
     // Import coupons
     $imported_coupons = $this->getDi()->db->selectCell("SELECT COUNT(id) FROM ?_data WHERE `table`='coupon' AND `key`='am3:id'");
     $totalc = $this->db3->selectCell("SELECT COUNT(*) FROM ?_coupon");
     if ($imported_products) {
         if ($imported_coupons >= $totalc) {
             $cb = $form->addStatic()->setContent("Imported ({$imported_coupons} of {$totalc})");
         } else {
             $cb = $form->addRadio('import', array('value' => 'coupon'));
         }
         $cb->setLabel('Import Coupons');
     }
     //import folders without actual protection
     /*if ($imported_products)
       {
           $total = $this->db3->selectCell("SELECT COUNT(*) FROM ?_folders");
           if ($total){
               $cb = $form->addRadio('import', array('value' => 'folder'));
               $cb->setLabel('Import Folders');
           }
       }
       //import integrations
       if ($imported_products)
       {
           $cb = $form->addRadio('import', array('value' => 'integration'));
           $cb->setLabel('Import Integrations');
       }
       //import product links
       if ($imported_products)
       {
           $cb = $form->addRadio('import', array('value' => 'productlinks'));
           $cb->setLabel('Import Product Links');
       }*/
     if ($imported_products && ($imported_coupons || !$totalc)) {
         $imported_users = $this->getDi()->db->selectCell("SELECT COUNT(id) FROM ?_data WHERE `table`='user' AND `key`='am3:id'");
         $total = $this->db3->selectCell("SELECT COUNT(*) FROM ?_members");
         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 />Do not import pending users');
             $cb->addCheckbox('user[exclude_pending]');
             $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');
         if ($imported_users) {
             if ($this->getDi()->modules->isEnabled('aff')) {
                 $imported_comm = $this->getDi()->db->selectCell("SELECT COUNT(id) FROM ?_data WHERE `table`='aff_commission' AND `key`='am3:id'");
                 $total = $this->db3->selectCell("SELECT COUNT(*) FROM ?_aff_commission");
                 $imported_clicks = $this->getDi()->db->selectCell("SELECT COUNT(id) FROM ?_data WHERE `table`='aff_click' AND `key`='am3:id'");
                 $total_clicks = $this->db3->selectCell("SELECT COUNT(*) FROM ?_aff_clicks");
                 $gr = $form->addGroup()->setLabel('Import Affiliate Commissions and Refs');
                 if ($imported_comm >= $total) {
                     $gr->addStatic()->setContent("Imported ({$imported_comm} of {$total})");
                 } else {
                     if ($imported_comm) {
                         $gr->addStatic()->setContent("partially imported ({$imported_comm} of {$total} total)<br /><br />");
                     }
                     $gr->addRadio('import', array('value' => 'aff'));
                 }
                 $gr = $form->addGroup()->setLabel('Import Affiliate Clicks');
                 if ($imported_clicks >= $total_clicks) {
                     $gr->addStatic()->setContent("Imported ({$imported_clicks} of {$total_clicks})");
                 } else {
                     if ($imported_clicks) {
                         $gr->addStatic()->setContent("partially imported ({$imported_clicks} of {$total_clicks} total)<br /><br />");
                     }
                     $gr->addRadio('import', array('value' => 'affclicks'));
                 }
                 $gr = $form->addGroup()->setLabel('Import Affiliate Banners and Links');
                 $gr->addRadio('import', array('value' => 'affbanners'));
                 $gr->addStatic()->setContent("Workaround to have old links working");
             } else {
                 $form->addStatic()->setContent('Enable [aff] module in Setup/Configuration to import information');
             }
             if ($this->getDi()->modules->isEnabled('newsletter')) {
                 $form->addRadio('import', array('value' => 'newsletter'))->setLabel('Import Newsletter Threads and Subscriptions');
             } else {
                 $form->addStatic()->setContent('Enable [newsletter] module in Setup/Configuration to import information');
             }
         }
     }
     //import PAYPAL_PROFILE_ID for previously wrongly imported invoices
     /*if ($imported_users)
       {
           $total = $this->db3->selectCell("SELECT COUNT(*) FROM ?_folders");
           if ($total){
               $cb = $form->addRadio('import', array('value' => 'paypalprofileid'));
               $cb->setLabel("Import Paypal Profile ID's");
           }
       }*/
     $form->addSaveButton('Run');
     $defaults = array();
     return $form;
 }
Ejemplo n.º 5
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;
    }
    public function createForm()
    {
        $form = new Am_Form_Admin();
        $record = $this->getRecord();
        $name = empty($record->name) ? $this->getCompleteRequest()->getFiltered('name') : $record->name;
        $form->addHidden('name');
        $form->addStatic()->setContent(nl2br($this->comment[$name]))->setLabel(___('Description'));
        $form->addStatic()->setLabel(___('E-Mail Type'))->setContent($name);
        $recipient = $form->addGroup(null)->setLabel(___('Recipients'));
        $recipient->addAdvCheckbox('recipient_user')->setContent(___('User Email'));
        $recipient->addStatic()->setContent('<br>');
        $recipient->addAdvCheckbox('recipient_admin')->setContent(___('Admin Email'));
        $recipient->addStatic()->setContent('<br>');
        $recipient->addAdvCheckbox('recipient_other', array('id' => 'checkbox-recipient-other'))->setContent(___('Other'));
        $form->addText('recipient_emails', array('class' => 'el-wide', 'id' => 'input-recipient-emails', 'placeholder' => ___('Email Addresses Separated by Comma')))->setLabel(___('Emails'))->addRule('callback2', ___('Please enter valid e-mail addresses'), array($this, 'validateOtherEmails'));
        $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
);
        $form->addElement(new Am_Form_Element_MailEditor($name, array('upload-prefix' => 'email-messages')));
        switch ($name) {
            case EmailTemplate::AUTORESPONDER:
                $access_desc = ___('Send E-Mail if customer has subscription (required)');
                break;
            case EmailTemplate::EXPIRE:
                $access_desc = ___('Send E-Mail when subscription expires (required)');
                break;
            case EmailTemplate::PRODUCTWELCOME:
                $access_desc = ___('Send E-Mail when the next subscription is started (required)');
                break;
        }
        $access_el = $form->addElement(new Am_Form_Element_ResourceAccess('_access'))->setLabel($access_desc)->setAttribute('without_period', true)->setAttribute('without_free', true);
        $group = $form->addGroup()->setLabel(___('Send E-Mail only if customer has no subscription (optional)'));
        $select = $group->addMagicSelect('_not_conditions', array('class' => 'am-combobox'))->setAttribute('without_period', true)->setAttribute('without_free', true);
        $this->addCategoriesProductsList($select);
        $group->addAdvCheckbox('not_conditions_expired')->setContent(___('check expired subscriptions too'));
        if ($name != EmailTemplate::PRODUCTWELCOME) {
            $group = $form->addGroup('day')->setLabel(___('Send E-Mail Message'));
            $options = $name == EmailTemplate::AUTORESPONDER ? array('' => ___('..th subscription day (starts from 2)'), '1' => ___('immediately after subscription is started')) : array('-' => ___('days before expiration'), '0' => ___('on expiration day'), '+' => ___('days after expiration'));
            $group->addInteger('count', array('size' => 3, 'id' => 'days-count'));
            $group->addSelect('type', array('id' => 'days-type'))->loadOptions($options);
            $group->addScript()->setScript(<<<CUT
\$("#days-type").change(function(){
    var sel = \$(this);
    if (\$("input[name='name']").val() == 'autoresponder')
        \$("#days-count").toggle( sel.val() != '1' );
    else
        \$("#days-count").toggle( sel.val() != '0' );
}).change();
CUT
);
        }
        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`='ym:id'");
     $memberTypes = unserialize($this->db_yourmembers->selectCell("SELECT option_value  FROM ?_options where option_name='ym_packs'"));
     $total = $memberTypes->getCount();
     if ($imported_products >= $total) {
         $cb = $form->addStatic()->setContent("Imported ({$imported_products} of {$total})");
     } else {
         $cb = $form->addRadio('import', array('value' => 'product'));
     }
     $cb->setLabel('Import Products');
     // Import coupons
     $imported_coupons = $this->getDi()->db->selectCell("SELECT COUNT(id) FROM ?_data WHERE `table`='coupon' AND `key`='ym:id'");
     $totalc = $this->db_yourmembers->selectCell("SELECT COUNT(*) FROM ?_ym_coupon");
     if ($imported_products) {
         if ($imported_coupons >= $totalc) {
             $cb = $form->addStatic()->setContent("Imported ({$imported_coupons} of {$totalc})");
         } else {
             $cb = $form->addRadio('import', array('value' => 'coupon'));
         }
         $cb->setLabel('Import Coupons');
     }
     if ($imported_products && ($imported_coupons || !$totalc)) {
         $imported_users = $this->getDi()->db->selectCell("SELECT COUNT(id) FROM ?_data WHERE `table`='user' AND `key`='ym:id'");
         $total = $this->db_yourmembers->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->setLabel('Import User and Payment Records');
     }
     $form->addSaveButton('Run');
     $defaults = array();
     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`='am3:id'");
     $total = $this->db3->selectCell("SELECT COUNT(*) FROM ?_products");
     if ($imported_products >= $total) {
         $cb = $form->addStatic()->setContent("Imported ({$imported_products} of {$total})");
     } else {
         $cb = $form->addRadio('import', array('value' => 'product'));
     }
     $cb->setLabel('Import Products');
     if ($imported_products) {
         $imported_users = $this->getDi()->db->selectCell("SELECT COUNT(id) FROM ?_data WHERE `table`='user' AND `key`='am3:id'");
         $total = $this->db3->selectCell("SELECT COUNT(*) FROM ?_members");
         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 />Do not import pending users');
             $cb->addCheckbox('user[exclude_pending]');
         }
         $cb->setLabel('Import User and Payment Records');
         if ($imported_users) {
             if ($this->getDi()->modules->isEnabled('aff')) {
                 $imported_comm = $this->getDi()->db->selectCell("SELECT COUNT(id) FROM ?_data WHERE `table`='aff_commission' AND `key`='am3:id'");
                 $total = $this->db3->selectCell("SELECT COUNT(*) FROM ?_aff_commission");
                 $gr = $form->addGroup()->setLabel('Import Affiliate Commissions and Refs');
                 if ($imported_comm) {
                     $gr->addStatic()->setContent("Imported ({$imported_comm} of {$total})");
                 } else {
                     $gr->addRadio('import', array('value' => 'aff'));
                 }
             } else {
                 $form->addStatic()->setContent('Enable [aff] module in Setup/Configuration to import information');
             }
             if ($this->getDi()->modules->isEnabled('newsletter')) {
                 $form->addRadio('import', array('value' => 'newsletter'))->setLabel('Import Newsletter Threads and Subscriptions');
             } else {
                 $form->addStatic()->setContent('Enable [newsletter] module in Setup/Configuration to import information');
             }
         }
     }
     $form->addSaveButton('Run');
     $defaults = array();
     return $form;
 }
Ejemplo n.º 9
0
    function createForm()
    {
        $form = new Am_Form_Admin('am-form-email');
        $form->setDataSources(array($this->getRequest()));
        $form->setAction($this->getUrl(null, 'preview'));
        if ($options = $this->getDi()->emailTemplateLayoutTable->getOptions()) {
            $form->addSelect('email_template_layout_id')->setLabel(___('Layout'))->loadOptions(array('' => ___('No Layout')) + $options);
        }
        $gr = $form->addGroup()->setLabel(___("Reply To\n" . "mailbox for replies to message"))->setSeparator(' ');
        $sel = $gr->addSelect('reply_to')->loadOptions($this->getReplyToOptions());
        $id = $sel->getId();
        $gr->addText('reply_to_other', array('placeholder' => ___('Email Address')))->setId($id . '-other')->persistentFreeze(true);
        // ??? why is it necessary? but it is
        $gr->addScript()->setScript(<<<CUT
\$('#{$id}').change(function(){
   \$('#{$id}-other').toggle(\$(this).val() == 'other');
}).change();
CUT
);
        $subj = $form->addText('subject', array('class' => 'el-wide'))->setLabel(___('Email Subject'));
        $subj->persistentFreeze(true);
        // ??? why is it necessary? but it is
        $subj->addRule('required', ___('Subject is required'));
        //        $arch = $form->addElement('advcheckbox', 'do_archive')->setLabel(array('Archive Message', 'if you are sending it to newsletter subscribers'));
        $format = $form->addGroup(null)->setLabel(___('E-Mail Format'));
        $format->setSeparator(' ');
        $format->addRadio('format', array('value' => 'html'))->setContent(___('HTML Message'));
        $format->addRadio('format', array('value' => 'text'))->setContent(___('Plain-Text Message'));
        $group = $form->addGroup('', array('id' => 'body-group', 'class' => 'no-label'))->setLabel(___('Message Text'));
        $group->addStatic()->setContent('<div class="mail-editor">');
        $group->addStatic()->setContent('<div class="mail-editor-element">');
        $group->addElement('textarea', 'body', array('id' => 'body-0', 'rows' => '15', 'class' => 'el-wide'));
        $group->addStatic()->setContent('</div>');
        $group->addStatic()->setContent('<div class="mail-editor-element">');
        $this->tagsOptions = Am_Mail_TemplateTypes::getInstance()->getTagsOptions('send_signup_mail');
        $tagsOptions = array();
        foreach ($this->tagsOptions as $k => $v) {
            $tagsOptions[$k] = "{$k} - {$v}";
        }
        $sel = $group->addSelect('', array('id' => 'insert-tags'));
        $sel->loadOptions(array_merge(array('' => ''), $tagsOptions));
        $group->addStatic()->setContent('</div>');
        $group->addStatic()->setContent('</div>');
        $fileChooser = new Am_Form_Element_Upload('files', array('multiple' => '1'), array('prefix' => 'email'));
        $form->addElement($fileChooser)->setLabel(___('Attachments'));
        foreach ($this->searchUi->getHidden() as $k => $v) {
            $form->addHidden($k)->setValue($v);
        }
        $id = 'body-0';
        $vars = "";
        foreach ($this->tagsOptions as $k => $v) {
            $vars .= sprintf("[%s, %s],\n", Am_Controller::getJson($v), Am_Controller::getJson($k));
        }
        $vars = trim($vars, "\n\r,");
        if ($this->queue_id) {
            $form->addHidden('queue_id')->setValue($this->queue_id);
        }
        $form->addScript('_bodyscript')->setScript(<<<CUT
\$(function(){
    \$('select#insert-tags').change(function(){
        var val = \$(this).val();
        if (!val) return;
        \$("#{$id}").insertAtCaret(val);
        \$(this).prop("selectedIndex", -1);
    });

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

CUT
);
        $this->getDi()->hook->call(Am_Event::MAIL_SIMPLE_INIT_FORM, array('form' => $form));
        $buttons = $form->addGroup('buttons');
        $buttons->addSubmit('send', array('value' => ___('Preview')));
        return $form;
    }
    public function createForm()
    {
        $form = new Am_Form_Admin();
        $record = $this->getRecord();
        $name = empty($record->name) ? $this->getCompleteRequest()->getFiltered('name') : $record->name;
        $form->addHidden('name');
        $form->addStatic()->setContent(nl2br($this->comment[$name]))->setLabel(___('Description'));
        $form->addStatic()->setLabel(___('E-Mail Type'))->setContent($name);
        $form->addElement(new Am_Form_Element_MailEditor($name));
        $form->addElement(new Am_Form_Element_ResourceAccess('_access'))->setAttribute('without_period', true)->setLabel(___('Access Permissions'));
        $group = $form->addGroup('day')->setLabel(___('Send E-Mail Message'));
        $options = $name == EmailTemplate::AUTORESPONDER ? array('' => ___('..th subscription day (starts from 1)'), '1' => ___('immediately after purchase')) : array('-' => ___('days before expiration'), '0' => ___('on expiration day'), '+' => ___('days after expiration'));
        $group->addInteger('count', array('size' => 3, 'id' => 'days-count'));
        $group->addSelect('type', array('id' => 'days-type'))->loadOptions($options);
        $group->addScript()->setScript(<<<CUT
\$("#days-type").change(function(){
    var sel = \$(this);
    if (\$("input[name='name']").val() == 'autoresponder')
        \$("#days-count").toggle( sel.val() != '1' );  
    else
        \$("#days-count").toggle( sel.val() != '0' );  
}).change();
CUT
);
        return $form;
    }
 function createForm()
 {
     $form = new Am_Form_Admin('am-form-email');
     $form->setDataSources(array($this->_request));
     $form->setAction($this->getUrl(null, 'preview'));
     $subj = $form->addElement('text', 'subject', array('size' => 80))->setLabel(array(___('Email Subject')));
     $subj->persistentFreeze(true);
     // ??? why is it necessary? but it is
     $subj->addRule('required', 'Subject is required');
     //        $arch = $form->addElement('advcheckbox', 'do_archive')->setLabel(array('Archive Message', 'if you are sending it to newsletter subscribers'));
     $format = $form->addGroup(null)->setLabel(___('E-Mail Format'));
     $format->addRadio('format', array('value' => 'html'))->setContent(___('HTML Message'));
     $format->addRadio('format', array('value' => 'text'))->setContent(___('Plain-Text Message'));
     $group = $form->addGroup('', array('id' => 'body-group', 'class' => 'no-label'))->setLabel('Message Text');
     $group->addElement('textarea', 'body', array('id' => 'body-0', 'rows' => '15', 'cols' => '80', 'style' => 'width: 90%;'));
     $fileChooser = new Am_Form_Element_Upload('files', array('multiple' => '1'), array('prefix' => 'email'));
     $form->addElement($fileChooser)->setLabel(___('Attach Uploaded File'));
     foreach ($this->searchUi->getHidden() as $k => $v) {
         $form->addHidden($k)->setValue($v);
     }
     $form->addElement('submit', 'send', array('value' => ___('Preview'), 'style' => 'width: 200px'));
     return $form;
 }
Ejemplo n.º 12
0
 protected function createConfirmForm($force_submited = false)
 {
     $form = new Am_Form_Admin('confirm');
     $form->setAction($this->getUrl(null, 'confirm'));
     $form->addAdvRadio('mode')->setLabel(___('Import Mode'))->loadOptions(self::getImportModeOptions())->setValue(self::MODE_SKIP);
     $group = $form->addGroup();
     $group->setSeparator(' ');
     $group->addElement('inputbutton', 'back', array('value' => ___('Back')))->setId('back');
     $group->addElement('submit', '_submit_', array('value' => ___('Do Import')))->setId('_submit_');
     if ($force_submited || $form->isSubmitted()) {
         $form->setDataSources(array($this->getRequest()));
     } else {
         $form->setDataSources(array(new HTML_QuickForm2_DataSource_Array(array())));
     }
     return $form;
 }
 protected function createconfirmForm()
 {
     $form = new Am_Form_Admin('confirm');
     $form->setAction($this->getUrl(null, 'confirm'));
     $form->addElement('select', 'mode')->setLabel('Import Mode')->loadOptions(self::getImportModeOptions());
     $group = $form->addGroup();
     $group->addElement('inputbutton', 'back', array('value' => 'Back'))->setId('back');
     $group->addElement('submit', '_submit_', array('value' => 'Do Import'))->setId('_submit_');
     if ($form->isSubmitted()) {
         $form->setDataSources(array($this->_request));
     } else {
         $form->setDataSources(array(new HTML_QuickForm2_DataSource_Array(array())));
     }
     return $form;
 }
 public function stepConfirmUpgrades()
 {
     $form = new Am_Form_Admin();
     $upgrades = $form->addGroup('upgrades', array('class' => 'no-label'));
     $options = array();
     $static = '';
     $upgrades->addStatic()->setContent('<h2>' . ___('Available Upgrades') . '</h2>');
     foreach ($this->getSession()->upgrades as $k => $upgrade) {
         if (!empty($upgrade->new)) {
             $upgrades->addStatic()->setContent('<br /><h2>' . ___('New Modules Available') . '</h2>');
         }
         $text = sprintf('%s%s, ' . ___('version') . ' %s - %s' . '<br />', '<b>' . $upgrade->title . '</b>', $upgrade->type == 'core' ? '' : sprintf(' [%s - %s]', $upgrade->type, $upgrade->id), '<i>' . $upgrade->version . '</i>', '<i>' . amDate($upgrade->date) . '</i>');
         $upgrades->addCheckbox($k, empty($upgrade->checked) ? null : array('checked' => 'checked'))->setContent($text);
         $static .= "<div class='changelog' style='' data-for='{$k}'><pre>" . $upgrade->text . "</pre></div>\n";
         $upgrades->addStatic()->setContent($static);
     }
     $form->addCheckbox('_confirm', array('class' => 'no-label'))->setContent(___('I understand that upgrade may overwrite customized PHP files and templates, I have already made a backup of aMember Pro folder and database'))->addRule('required');
     $form->addSubmit('', array('value' => ___('Install Updates')));
     if ($form->isSubmitted() && $form->validate()) {
         $confirmed = array_keys(array_filter($upgrades->getValue()));
         if (!$confirmed) {
             $this->view->title = ___('No upgrades to install');
             $this->view->content = '<a href="' . REL_ROOT_URL . '/admin">' . ___('Back') . '</a>';
             return false;
         }
         $upgrades = $this->getSession()->upgrades;
         foreach ($upgrades as $k => $v) {
             if (!in_array($k, $confirmed)) {
                 unset($upgrades[$k]);
             }
         }
         $this->getSession()->upgrades = $upgrades;
         return true;
     } else {
         $this->view->content = (string) $form;
         $this->view->title = ___('Choose Upgrades to Install');
         $this->view->display('admin/layout.phtml');
         $this->noDisplay = true;
         return false;
     }
 }
Ejemplo n.º 15
0
 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`='oss6:id'");
     $total = $this->db_oss->selectCell("SELECT COUNT(*) FROM ?_groups");
     if ($imported_products >= $total) {
         $cb = $form->addStatic()->setContent("Imported ({$imported_products} of {$total})");
     } else {
         $cb = $form->addRadio('import', array('value' => 'product'));
     }
     $cb->setLabel('Import Products');
     if ($imported_products) {
         $imported_users = $this->getDi()->db->selectCell("SELECT COUNT(id) FROM ?_data WHERE `table`='user' AND `key`='oss6:id'");
         $total = $this->db_oss->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->setLabel('Import User and Payment Records');
     }
     $form->addSaveButton('Run');
     $defaults = array();
     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;
 }
Ejemplo n.º 17
0
 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`='ipb_nexus:id'");
     $total = $this->db_ipb_nexus->selectCell("SELECT COUNT(*) FROM ?_nexus_packages");
     if ($this->getDi()->db->selectCell("SELECT COUNT(*) FROM ?_product")) {
         $form->addStatic()->setLabel(___('Clean up v4 Database'))->setContent(sprintf(___('Use this %slink%s to delete data from aMember v4 database and use clean database for import'), '<a href="' . REL_ROOT_URL . '/admin-import-ipb-nexus/clean">', '</a>'));
     }
     if ($imported_products >= $total) {
         $cb = $form->addStatic()->setContent("Imported ({$imported_products} of {$total})");
     } else {
         $cb = $form->addRadio('import', array('value' => 'product'));
     }
     $cb->setLabel('Import Products');
     if ($imported_products) {
         $imported_users = $this->getDi()->db->selectCell("SELECT COUNT(id) FROM ?_data WHERE `table`='user' AND `key`='ipb_nexus:id'");
         $total = $this->db_ipb_nexus->selectCell("SELECT COUNT(*) FROM ?_members");
         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->setLabel('Import User and Payment Records');
     }
     $form->addSaveButton('Run');
     $defaults = array();
     return $form;
 }
Ejemplo n.º 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;
        }
    }
Ejemplo n.º 19
0
    public function addInvoiceAction()
    {
        $this->getDi()->authAdmin->getUser()->checkPermission('grid_invoice', 'insert');
        $form = new Am_Form_Admin('add-invoice');
        $tm_added = $form->addDate('tm_added')->setLabel(___('Date'));
        $tm_added->setValue($this->getDi()->sqlDate);
        $tm_added->addRule('required');
        $comment = $form->addText('comment', array('class' => 'el-wide'))->setLabel(___("Comment\nfor your reference"));
        $form->addElement(new Am_Form_Element_ProductsWithQty('product_id'))->setLabel(___('Products'))->loadOptions($this->getDi()->billingPlanTable->selectAllSorted())->addRule('required');
        $form->addSelect('paysys_id')->setLabel(___('Payment System'))->setId('add-invoice-paysys_id')->loadOptions(array('' => '') + $this->getDi()->paysystemList->getOptions());
        $couponEdit = $form->addText('coupon')->setLabel(___('Coupon'))->setId('p-coupon');
        $gr = $form->addGroup()->setLabel(___("Discount\n" . 'additional discount to invoice total besides coupon'));
        $gr->setSeparator(' ');
        $gr->addStatic()->setContent(___('First Price'));
        $gr->addText('d_first', array('size' => 4, 'placeholder' => '0'));
        $gr->addStatic()->setContent(___('Second Price'));
        $gr->addText('d_second', array('size' => 4, 'placeholder' => '0'));
        $action = $form->addAdvRadio('_action')->setLabel(___('Action'))->setId('add-invoice-action')->loadOptions(array('pending' => ___('Just Add Pending Invoice'), 'pending-payment' => ___('Add Invoice and Payment/Access Manually'), 'pending-send' => ___('Add Pending Invoice and Send Link to Pay It to Customer')))->setValue('pending');
        $receipt = $form->addText('receipt')->setLabel(___('Receipt#'))->setId('add-invoice-receipt');
        $tm_due = $form->addDate('tm_due')->setLabel(___('Due Date'));
        $tm_due->setValue(sqlDate('+7 days'));
        $tm_due->setId('add-invoice-due');
        $message = $form->addTextarea('message', array('class' => 'el-wide'))->setLabel(___("Message\nwill be included to email to user"));
        $message->setId('add-invoice-message');
        $form->addElement('email_link', 'invoice_pay_link')->setLabel(___('Email Template with Payment Link'));
        $form->addScript()->setScript('
            $("[name=_action]").change(function(){
                var val = $("[name=_action]:checked").val();
                $("#add-invoice-receipt").closest("div.row").toggle(val == "pending-payment")
                $("#add-invoice-due").closest("div.row").toggle(val == "pending-send")
                $("#add-invoice-message").closest("div.row").toggle(val == "pending-send")
                $("[name=invoice_pay_link]").closest("div.row").toggle(val == "pending-send")
            }).change();

        ');
        $script = <<<CUT
        \$("input#p-coupon").autocomplete({
                minLength: 2,
                source: window.rootUrl + "/admin-coupons/autocomplete"
        });
CUT;
        $form->addScript('script')->setScript($script);
        $form->addAdvCheckbox('skip_pr', null, array('content' => ___('do not validate product requirements for this invoice')));
        $form->addSaveButton();
        $form->setDataSources(array($this->getRequest()));
        do {
            if ($form->isSubmitted() && $form->validate()) {
                $vars = $form->getValue();
                $invoice = $this->getDi()->invoiceRecord;
                $invoice->setUser($this->getDi()->userTable->load($this->user_id));
                $invoice->tm_added = sqlTime($vars['tm_added']);
                if ($vars['coupon']) {
                    $invoice->setCouponCode($vars['coupon']);
                    $error = $invoice->validateCoupon();
                    if ($error) {
                        $couponEdit->setError($error);
                        break;
                    }
                }
                foreach ($vars['product_id'] as $plan_id => $qty) {
                    $p = $this->getDi()->billingPlanTable->load($plan_id);
                    $pr = $p->getProduct();
                    try {
                        $invoice->add($pr, $qty);
                    } catch (Am_Exception_InputError $e) {
                        $form->setError($e->getMessage());
                        break 2;
                    }
                }
                $invoice->comment = $vars['comment'];
                if ($vars['skip_pr']) {
                    $invoice->toggleValidateProductRequirements(false);
                }
                if ($vars['d_first'] || $vars['d_second']) {
                    $invoice->setDiscount($vars['d_first'], $vars['d_second']);
                }
                $invoice->calculate();
                switch ($vars['_action']) {
                    case 'pending':
                        if (!$this->_addPendingInvoice($invoice, $form, $vars)) {
                            break 2;
                        }
                        break;
                    case 'pending-payment':
                        if (!$this->_addPendingInvoiceAndPayment($invoice, $form, $vars)) {
                            break 2;
                        }
                        break;
                    case 'pending-send':
                        if (!$this->_addPendingInvoiceAndSend($invoice, $form, $vars)) {
                            break 2;
                        }
                        break;
                    default:
                        throw new Am_Exception_InternalError(sprintf('Unknown action [%s] as %s::%s', $vars['_action'], __CLASS__, __METHOD__));
                }
                $this->getDi()->adminLogTable->log("Add Invoice (#{$invoice->invoice_id}/{$invoice->public_id}, Billing Terms: " . new Am_TermsText($invoice) . ")", 'invoice', $invoice->invoice_id);
                return $this->redirectLocation(REL_ROOT_URL . '/admin-user-payments/index/user_id/' . $this->user_id);
            }
            // if
        } while (false);
        $this->view->content = '<h1>' . ___('Add Invoice') . ' (<a href="' . REL_ROOT_URL . '/admin-user-payments/index/user_id/' . $this->user_id . '">' . ___('return') . '</a>)</h1>' . (string) $form;
        $this->view->display('admin/user-layout.phtml');
    }