function addBillingPlanElements(HTML_QuickForm2_Container $fieldSet, $plan) { $prefix = '_plan[' . $plan . ']['; $suffix = ']'; $firstPrice = $fieldSet->addElement('text', $prefix . 'first_price' . $suffix)->setLabel(___("First Price\n" . "price of first period of subscription")); $firstPrice->addRule('gte', ___('must be equal or greather than 0'), 0.0)->addRule('regex', ___('must be a number in format 99 or 99.99'), '/^(\\d+(\\.\\d+)?|)$/'); $firstPeriod = $fieldSet->addElement('period', $prefix . 'first_period' . $suffix)->setLabel(___('First Period')); $group = $fieldSet->addGroup()->setLabel(___("Rebill Times\n" . "This is the number of payments which\n" . "will occur at the Second Price")); $group->setSeparator(' '); $sel = $group->addElement('select', $prefix . '_rebill_times' . $suffix)->setId('s_rebill_times'); $sel->addOption(___('No more charges'), 0); $sel->addOption(___('Charge Second Price Once'), 1); $sel->addOption(___('Charge Second Price x Times'), 'x'); $sel->addOption(___('Rebill Second Price until cancelled'), IProduct::RECURRING_REBILLS); $txt = $group->addElement('text', $prefix . 'rebill_times' . $suffix, array('size' => 5, 'maxlength' => 6))->setId('t_rebill_times'); $secondPrice = $fieldSet->addElement('text', $prefix . 'second_price' . $suffix)->setLabel(___("Second Price\n" . "price that must be billed for second and\n" . "the following periods of subscription")); $secondPrice->addRule('gte', ___('must be equal or greather than 0.0'), 0.0)->addRule('regex', ___('must be a number in format 99 or 99.99'), '/^\\d+(\\.\\d+)?$/'); $secondPeriod = $fieldSet->addElement('period', $prefix . 'second_period' . $suffix)->setLabel(___('Second Period')); $secondPeriod = $fieldSet->addElement('text', $prefix . 'terms' . $suffix, array('size' => 40, 'class' => 'translate'))->setLabel(___("Terms Text\nautomatically calculated if empty")); $fs = $fieldSet->addGroup()->setLabel(___("Quantity\ndefault - 1, normally you do not need to change it\nFirst and Second Price is the total for specified qty")); $fs->setSeparator(' '); $fs->addInteger($prefix . 'qty' . $suffix, array('placeholder' => 1)); $fs->addCheckbox($prefix . 'variable_qty' . $suffix, array('class' => 'variable_qty'))->setContent(___('allow user to change quantity')); if (Am_Di::getInstance()->config->get('product_paysystem')) { $fieldSet->addMagicSelect($prefix . 'paysys_id' . $suffix)->setLabel(___("Payment System\n" . "Choose payment system to be used with this product"))->loadOptions(Am_Di::getInstance()->paysystemList->getOptions()); } foreach (Am_Di::getInstance()->billingPlanTable->customFields()->getAll() as $k => $f) { $el = $f->addToQf2($fieldSet); $el->setName($prefix . $el->getName() . $suffix); } }