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 createAccessForm() { static $form; if (!$form) { $form = new Am_Form_Admin(); $form->setAction($url = $this->getUrl(null, 'c', null, 'payments', 'addaccess', 'user_id', $this->user_id)); $sel = $form->addSelect('product_id'); $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->addDate('begin_date')->addRule('required', 'this field is required'); $form->addDate('expire_date')->addRule('required', 'this field is required'); $form->addSaveButton('Add Access Manually'); } return $form; }
function createForm() { $form = new Am_Form_Admin(); $form->setAction($this->getUrl(null, 'clear')); $form->addDate('dat')->setLabel(___("Date to Purge\nall records prior to this date will be removed from selected tables"))->addRule('required'); $section = $form->addFieldset('tables')->setLabel(___('Tables to Purge')); foreach ($this->getItems() as $id => $item) { $section->addAdvCheckbox($id)->setLabel(array($item['title'], $item['desc'])); } $form->addSaveButton(___('Clear')); 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; } }
protected function createForm() { $f = new Am_Form_Admin(); $f->addText('user')->setLabel(___('Enter username of existing user'))->addRule('required'); $f->addSelect('product_id')->setLabel(___('Product'))->loadOptions(Am_Di::getInstance()->productTable->getOptions()); $f->addScript()->setScript(<<<CUT \$(function(){ \$("#user-0" ).autocomplete({ minLength: 2, source: window.rootUrl + "/admin-users/autocomplete" }); }); CUT ); $tmp = $this->grid->getRecord(); if ($tmp->name == EmailTemplate::EXPIRE) { $f->addDate('expires')->setLabel(___('Expiration Date'))->addRule('required'); } $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; }
function changeRebillDateAction() { $this->getDi()->authAdmin->getUser()->checkPermission('grid_invoice', 'edit'); $invoice_id = $this->_request->getInt('invoice_id'); $form = new Am_Form_Admin(); $form->addDate('rebill_date'); $vals = $form->getValue(); $rebill_date = $vals['rebill_date']; try { if (!$invoice_id) { throw new Am_Exception_InputError('No invoice provided'); } $invoice = $this->getDi()->invoiceTable->load($invoice_id); // Invoice must be recurring active and rebills should be controlled by paylsystem, // otherwise this doesn't make any sence if ($invoice->status != Invoice::RECURRING_ACTIVE || $invoice->getPaysystem()->getRecurringType() != Am_Paysystem_Abstract::REPORTS_CRONREBILL) { throw new Am_Exception_InputError('Unable to change rebill_date for this invoice!'); } $rebill_date = new DateTime($rebill_date); $old_rebill_date = $invoice->rebill_date; $invoice->updateQuick('rebill_date', $rebill_date->format('Y-m-d')); $invoice->data()->set('first_rebill_failure', null)->update(); $this->getDi()->invoiceLogTable->log($invoice_id, null, ___('Rebill Date changed from %s to %s', $old_rebill_date, $invoice->rebill_date)); Am_Controller::ajaxResponse(array('ok' => true, 'msg' => ___('Rebill date has been changed!'))); } catch (Exception $e) { Am_Controller::ajaxResponse(array('ok' => false, 'msg' => $e->getMessage())); } }