function indexAction()
 {
     $form = new Am_Form();
     $form->setAction(REL_ROOT_URL . '/cancel/repeat');
     $psOptions = array();
     foreach ($this->getDi()->paysystemList->getAllPublic() as $ps) {
         $psOptions[$ps->getId()] = $this->renderPaysys($ps);
     }
     $paysys = $form->addAdvRadio('paysys_id')->setLabel(___('Payment System'))->loadOptions($psOptions);
     $paysys->addRule('required', ___('Please choose a payment system'));
     if (count($psOptions) == 1) {
         $paysys->setValue(key($psOptions));
         $paysys->toggleFrozen(true);
     }
     $form->addHidden('id')->setValue($this->getFiltered('id'));
     $form->addSaveButton(___('Make Payment'));
     $this->view->form = $form;
     $this->view->display('cancel.phtml');
 }
Example #2
0
 public function indexAction()
 {
     /* @var $invoice Invoice */
     $invoice = $this->getDi()->invoiceTable->findBySecureId($this->getParam('secure_id'), 'payment-link');
     if (!$invoice || $invoice->status != Invoice::PENDING) {
         throw new Am_Exception_InternalError(sprintf('Unknow invoice [%s] or invoice is already processed', filterId($this->getParam('secure_id'))));
     }
     if (!$invoice->due_date && sqlDate($invoice->tm_added) < sqlDate("-" . Invoice::DEFAULT_DUE_PERIOD . " days")) {
         throw new Am_Exception_InputError(___('Invoice is expired'));
     } elseif ($invoice->due_date && $invoice->due_date < sqlDate('now')) {
         throw new Am_Exception_InputError(___('Invoice is expired'));
     }
     $form = new Am_Form();
     if (!$invoice->paysys_id) {
         $psOptions = array();
         foreach (Am_Di::getInstance()->paysystemList->getAllPublic() as $ps) {
             $psOptions[$ps->getId()] = $this->renderPaysys($ps);
         }
         $paysys = $form->addAdvRadio('paysys_id')->setLabel(___('Payment System'))->loadOptions($psOptions);
         $paysys->addRule('required', ___('Please choose a payment system'));
         if (count($psOptions) == 1) {
             $paysys->toggleFrozen(true);
         }
     }
     $form->addSaveButton(___('Pay'));
     $this->view->invoice = $invoice;
     $this->view->form = $form;
     $form->setDataSources(array($this->getRequest()));
     if ($form->isSubmitted() && $form->validate()) {
         $vars = $form->getValue();
         if (!$invoice->paysys_id) {
             $invoice->setPaysystem($vars['paysys_id']);
             $invoice->save();
         }
         $payProcess = new Am_Paysystem_PayProcessMediator($this, $invoice);
         $result = $payProcess->process();
         throw new Am_Exception_InternalError(sprintf('Error occurred while trying proccess invoice [%s]', filterId($invoice->public_id)));
     }
     $this->view->layoutNoMenu = true;
     $this->view->display('pay.phtml');
 }
Example #3
0
    public function initConfigForm(Am_Form $form)
    {
        $radio = $form->addSelect('type')->setLabel(___('What to Display'));
        $radio->loadOptions(array(self::DISPLAY_ALL => ___('Display All Products'), self::DISPLAY_CATEGORY => ___('Products from selected Categories'), self::DISPLAY_PRODUCT => ___('Only Products selected below'), self::DISPLAY_BP => ___('Only Billing Plans selected below')));
        $groups = $form->addMagicSelect('groups', array('data-type' => self::DISPLAY_CATEGORY))->setLabel(___('Product Gategories'));
        $groups->loadOptions(Am_Di::getInstance()->productCategoryTable->getAdminSelectOptions(array(ProductCategoryTable::COUNT => 1)));
        $products = $form->addSortableMagicSelect('products', array('data-type' => self::DISPLAY_PRODUCT))->setLabel(___('Product(s) to display'));
        $products->loadOptions(Am_Di::getInstance()->productTable->getOptions(true));
        $bpOptions = array();
        foreach (Am_Di::getInstance()->productTable->getVisible() as $product) {
            /* @var $product Product */
            foreach ($product->getBillingOptions() as $bp_id => $title) {
                $bpOptions[$product->pk() . '-' . $bp_id] = sprintf('%s (%s)', $product->title, $title);
            }
        }
        $bps = $form->addSortableMagicSelect('bps', array('data-type' => self::DISPLAY_BP))->setLabel(___('Billing Plan(s) to display'));
        $bps->loadOptions($bpOptions);
        $inputType = $form->addSelect('input-type')->setLabel(___('Input Type'));
        $inputType->loadOptions(array('advradio' => ___('Radio-buttons (one product can be selected)'), 'select' => ___('Select-box (one product can be selected)'), 'checkbox' => ___('Checkboxes (multiple products can be selected)')));
        $form->addAdvCheckbox('display-popup')->setlabel('Display Products in Popup');
        $form->addSelect('display-type')->setLabel(___('If product is not available because of require/disallow settings'))->loadOptions(array('hide' => ___('Remove It From Signup Form'), 'display' => ___('Display It Anyway')));
        $form->addCheckboxedGroup('empty-option')->setLabel(___("Add an 'empty' option to select box\nto do not choose any products"))->addText('empty-option-text');
        $form->addAdvCheckbox('hide_if_one')->setLabel(___("Hide Select\n" . 'if there is only one choice'));
        $form->addAdvRadio('require')->setLabel(___('Require Behaviour'))->loadOptions(array(self::REQUIRE_DEFAULT => sprintf('<strong>%s</strong>: %s', ___('Default'), ___('Make this Brick Required Only in Case There is not any Required Brick on Page Above It')), self::REQUIRE_ALWAYS => sprintf('<strong>%s</strong>: %s', ___('Always'), ___('Force User to Choose Some Product from this Brick')), self::REQUIRE_NEVER => sprintf('<strong>%s</strong>: %s', ___('Never'), ___('Products in this Brick is Optional (Not Required)')), self::REQUIRE_ALTERNATE => sprintf('<strong>%s</strong>: %s', ___('Alternate'), ___('User can Choose Product in any Brick of Such Type on Page but he Should Choose at least One Product still'))))->setValue(self::REQUIRE_DEFAULT);
        $formId = $form->getId();
        $script = <<<EOF
        jQuery(document).ready(function(\$) {
            // there can be multiple bricks like that :)
            if (!window.product_brick_hook_set)
            {
                window.product_brick_hook_set = true;
                \$(document).on('change',"select[name='type']", function (event){
                    var val = \$(event.target).val();
                    var frm = \$(event.target).closest("form");
                    \$("[data-type]", frm).closest(".row").hide();
                    \$("[data-type='"+val+"']", frm).closest(".row").show();
                })
                \$("select[name='type']").change();
                \$(document).on('change',"select[name='input-type']", function (event){
                    var val = \$(event.target).val();
                    var frm = \$(event.target).closest("form");
                    \$("input[name='display-popup']", frm).closest(".row").toggle(val == 'checkbox');
                    \$("input[name='empty-option']", frm).closest(".row").toggle(val == 'advradio' || val == 'select');
                })
                \$("select[name='input-type']").change();
            }
        });
EOF;
        $form->addScript()->setScript($script);
        $form->addAdvCheckbox('no_label')->setLabel(___('Remove Label'));
    }