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; }