public function run() { $form = new Am_Form_Admin('form-grid-config'); $form->setAttribute('name', 'customize'); $form->addSortableMagicSelect('fields')->loadOptions($this->getFieldsOptions())->setLabel(___('Fields to Display in Grid'))->setJsOptions(<<<CUT { allowSelectAll:true, sortable: true } CUT ); foreach ($this->grid->getVariablesList() as $k) { $form->addHidden($this->grid->getId() . '_' . $k)->setValue($this->grid->getRequest()->get($k, "")); } $form->addSaveButton(); $form->setDataSources(array($this->grid->getCompleteRequest())); if ($form->isSubmitted()) { $values = $form->getValue(); $this->setConfig($values['fields']); $this->grid->redirectBack(); } else { $form->setDataSources(array(new HTML_QuickForm2_DataSource_Array(array('fields' => $this->getSelectedFields())))); echo $this->renderTitle(); echo sprintf('<div class="info">%s</div>', ___('You can change Number of %sRecords per Page%s in section %sSetup/Configuration%s', '<strong>', '</strong>', '<a class="link" href="' . REL_ROOT_URL . '/admin-setup" target="_top">', '</a>')); echo $form; } }
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; }
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; }
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; }
function run() { $form = new Am_Form_Admin('form-grid-payout'); $form->setAttribute('name', 'payout'); $date = $form->addDate('payout_date')->setLabel(___('Payout Date'))->setValue(sqlDate($this->getDi()->dateTime)); foreach ($this->grid->getVariablesList() as $k) { $form->addHidden($this->grid->getId() . '_' . $k)->setValue($this->grid->getRequest()->get($k, "")); } $form->addSaveButton(___("Run Payout")); $form->setDataSources(array($this->grid->getCompleteRequest())); if ($form->isSubmitted() && $form->validate()) { $values = $form->getValue(); $this->getDi()->affCommissionTable->runPayout($values['payout_date']); $this->grid->redirectBack(); } else { echo $this->renderTitle(); echo $form; } }
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; } }
protected function createForm() { $f = new Am_Form_Admin(); $f->addText('user')->setLabel(___('Enter username of existing user'))->addRule('required'); $f->addScript()->setScript(<<<CUT \$(function(){ \$("#user-0" ).autocomplete({ minLength: 2, source: window.rootUrl + "/admin-users/autocomplete" }); }); CUT ); $f->addSaveButton(___('Preview')); foreach ($this->grid->getVariablesList() as $k) { $kk = $this->grid->getId() . '_' . $k; if ($v = @$_REQUEST[$kk]) { $f->addHidden($kk)->setValue($v); } } return $f; }
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 replaceProductAction() { $this->getDi()->authAdmin->getUser()->checkPermission('_payment', 'edit'); $item = $this->getDi()->invoiceItemTable->load($this->_request->getInt('id')); $pr = $this->getDi()->productTable->load($item->item_id); $form = new Am_Form_Admin('replace-product-form'); $form->setDataSources(array($this->_request)); $form->method = 'post'; $form->addHidden('id'); $form->addHidden('user_id'); $form->addStatic()->setLabel(___('Replace Product'))->setContent("#{$pr->product_id} [{$pr->title}]"); $sel = $form->addSelect('product_id')->setLabel('To Product'); $options = array('' => '-- ' . ___('Please select') . ' --'); foreach ($this->getDi()->billingPlanTable->getProductPlanOptions() as $k => $v) { if (strpos($k, $pr->pk() . '-') !== 0) { $options[$k] = $v; } } $sel->loadOptions($options); $sel->addRule('required'); $form->addSubmit('_save', array('value' => ___('Save'))); if ($form->isSubmitted() && $form->validate()) { try { list($p, $b) = explode("-", $sel->getValue(), 2); $item->replaceProduct(intval($p), intval($b)); $this->getDi()->adminLogTable->log("Inside invoice: product #{$item->item_id} replaced to product #{$p} (plan #{$b})", 'invoice', $item->invoice_id); return $this->ajaxResponse(array('ok' => true)); } catch (Am_Exception $e) { $sel->setError($e->getMessage()); } } echo $form->__toString(); }
protected function createForm() { $f = new Am_Form_Admin(); $f->addText('user')->setLabel('Enter username of existing user')->addRule('required', 'This field is required'); $f->addText('aff')->setLabel('Enter username of existing affiliate')->addRule('required', 'This field is required'); $f->addText('coupon')->setLabel('Enter coupon code or leave field empty'); $f->addCheckbox('is_first')->setLabel('Is first user invoice?'); $f->addElement(new Am_Form_Element_ProductsWithQty('product_id'))->setLabel(___('Choose products to include into test invoice'))->loadOptions(Am_Di::getInstance()->billingPlanTable->selectAllSorted())->addRule('required'); $f->addSelect('paysys_id')->setLabel(___('Payment System'))->loadOptions(Am_Di::getInstance()->paysystemList->getOptions()); $f->addSubmit('', array('value' => 'Test')); $f->addScript()->setScript(<<<CUT \$(function(){ \$("#user-0, #aff-0" ).autocomplete({ minLength: 2, source: window.rootUrl + "/admin-users/autocomplete" }); }); CUT ); foreach ($this->grid->getVariablesList() as $k) { $kk = $this->grid->getId() . '_' . $k; if ($v = @$_REQUEST[$kk]) { $f->addHidden($kk)->setValue($v); } } return $f; }
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; }
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; } }
public function getForm() { $languageTranslation = Am_Locale::getSelfNames(); $avalableLocaleList = Zend_Locale::getLocaleList(); $existingLanguages = Am_Di::getInstance()->languagesListUser; $languageOptions = array(); foreach ($avalableLocaleList as $k => $v) { $locale = new Zend_Locale($k); if (!array_key_exists($locale->getLanguage(), $existingLanguages) && isset($languageTranslation[$locale->getLanguage()])) { $languageOptions[$locale->getLanguage()] = "({$k}) " . $languageTranslation[$locale->getLanguage()]; } } asort($languageOptions); $form = new Am_Form_Admin(); $form->setAction($this->grid->makeUrl(null)); $form->addElement('select', 'new_language')->setLabel(___('Language'))->loadOptions($languageOptions)->setId('languageSelect'); $form->addElement('hidden', 'a')->setValue('new'); $form->addSaveButton(); foreach ($this->grid->getVariablesList() as $k) { if ($val = $this->grid->getRequest()->get($k)) { $form->addHidden($this->grid->getId() . '_' . $k)->setValue($val); } } return $form; }
protected function createForm() { $f = new Am_Form_Admin(); $f->addText('user')->setLabel('Enter username of existing user')->addRule('required', 'This field is required'); $f->addText('aff')->setLabel('Enter username of existing affiliate')->addRule('required', 'This field is required'); $f->addMagicSelect('product_ids')->setLabel('Choose products to include into test invoice')->loadOptions(Am_Di::getInstance()->productTable->getOptions())->addRule('required', 'This field is required'); $f->addSubmit('', array('value' => 'Test')); $f->addScript()->setScript(<<<CUT \$(function(){ \$("#user-0, #aff-0" ).autocomplete({ minLength: 2, source: window.rootUrl + "/admin-users/autocomplete" }); }); CUT ); foreach ($this->grid->getVariablesList() as $k) { $kk = $this->grid->getId() . '_' . $k; if ($v = @$_REQUEST[$kk]) { $f->addHidden($kk)->setValue($v); } } return $f; }