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;
 }
 function init()
 {
     $this->addElement('hidden', 'product_id');
     $this->addRule('callback', ___('At least one billing plan must be added'), array($this, 'checkBillingPlanExists'));
     /* General Settings */
     $fieldSet = $this->addElement('fieldset', 'general')->setLabel(___('General Settings'));
     $fieldSet->addElement('text', 'title', array('size' => 40, 'class' => 'translate'))->setLabel(___('Title'))->addRule('required');
     $fieldSet->addElement('textarea', 'description', array('class' => 'translate'))->setLabel(___("Description\n" . "displayed to visitors on order page below the title"))->setAttribute('cols', 40)->setAttribute('rows', 2);
     $fieldSet->addElement('textarea', 'comment')->setLabel(___("Comment\nfor admin reference"))->setAttribute('cols', 40)->setAttribute('rows', 2);
     $gr = $fieldSet->addGroup()->setSeparator(' ')->setLabel(___('Product Categories'));
     $gr->addMagicSelect('_categories')->loadOptions(Am_Di::getInstance()->productCategoryTable->getAdminSelectOptions());
     $gr->addStatic()->setContent('<a href="' . Am_Controller::escape(REL_ROOT_URL) . '/admin-product-categories">' . ___('Edit Groups') . '</a>');
     /* Billing Settings */
     $fieldSet = $this->addElement('fieldset', 'billing')->setLabel(___('Billing'));
     if (Am_Di::getInstance()->config->get('use_tax')) {
         $fieldSet->addElement('advcheckbox', 'no_tax')->setLabel(___('Do not Apply Tax?'));
     }
     $fieldSet->addElement('select', 'currency')->setLabel(array(___("Currency"), ___("you can choose from list of currencies supported by paysystems")))->loadOptions(Am_Currency::getSupportedCurrencies('ru_RU'));
     //        if (Am_Di::getInstance()->config->get('product_paysystem')) {
     //            $fieldSet->addElement('select', 'paysys_id')
     //                ->setLabel(array('Payment System',
     //                "choose a payment system to be used exclusively with this product"))
     //                ->loadOptions(array('' => '* Choose a paysystem *') + Am_Di::getInstance()->paysystemList->getOptions());
     //        };
     //
     $this->addBillingPlans();
     /* Advanced Settings */
     //        $fieldSet = $this->addElement('fieldset', 'advanced')
     //                ->setId('advanced')
     //                ->setLabel(___('Advanced'));
     //        $fieldSet->addElement('text', 'trial_group', array('size' => 20))
     //                ->setLabel(___("Trial Group\n".
     //                'If this field is filled-in, user will be unable to order the product
     //                    twice. It is extermelly useful for any trial product. This field
     //                    can have different values for different products, then "trial history"
     //                    will be separate for these groups of products.
     //                    If your site offers only one level of membership,
     //                    just enter "1" to this field. '));
     /* Product availability */
     $fieldSet = $this->addElement('fieldset', 'avail')->setLabel(___('Product Availability'));
     $this->insertAvailablilityFields($fieldSet);
     $sdGroup = $fieldSet->addGroup()->setLabel(___("Start Date Calculation\n" . "rules for subscription start date calculation.\n" . "MAX date from alternatives will be chosen.\n" . "This settings has no effect for recurring subscriptions"));
     $sd = $sdGroup->addSelect('start_date', array('multiple' => 'mutliple', 'id' => 'start-date-edit'));
     $sd->loadOptions(array(Product::SD_PRODUCT => ___('Last existing subscription date of this product'), Product::SD_GROUP => ___('Last expiration date in the renewal group: '), Product::SD_FIXED => ___('Fixed date'), Product::SD_PAYMENT => ___('Payment date')));
     $sdGroup->addSelect('renewal_group', array('style' => 'display:none; font-size: xx-small'), array('intrinsic_validation' => false, 'options' => Am_Di::getInstance()->productTable->getRenewalGroups()));
     $sdGroup->addDate('start_date_fixed', array('style' => 'display:none; font-size: xx-small'));
     $fieldSet->addElement('text', 'sort_order')->setLabel(___("Sorting order\n" . "This is a numeric field. Products are sorted\n" . "according to this field value, then alphabetically"));
     /* Additional Options */
     $fieldSet = $this->addElement('fieldset', 'additional')->setId('additional')->setLabel(___('Additional'));
     $this->insertAdditionalFields();
     Am_Di::getInstance()->hook->call(Am_Event::PRODUCT_FORM, array('form' => $this));
 }
 function init()
 {
     $this->addElement('hidden', 'product_id');
     $this->addRule('callback', ___('At least one billing plan must be added'), array($this, 'checkBillingPlanExists'));
     /* General Settings */
     $fieldSet = $this->addElement('fieldset', 'general')->setLabel(___('General Settings'));
     $fieldSet->addElement('text', 'title', array('size' => 40, 'class' => 'translate'))->setLabel(___('Title'))->addRule('required');
     $fieldSet->addElement('textarea', 'description', array('class' => 'translate'))->setLabel(___("Description\n" . "displayed to visitors on order page below the title"))->setAttribute('cols', 40)->setAttribute('rows', 2);
     $fieldSet->addElement('textarea', 'comment', array('class' => 'el-wide'))->setLabel(___("Comment\nfor admin reference"))->setAttribute('rows', 2);
     $fieldSet->addCategory('_categories', null, array('base_url' => 'admin-product-categories', 'link_title' => ___('Edit Categories'), 'title' => ___('Product Categories'), 'options' => Am_Di::getInstance()->productCategoryTable->getOptions()))->setLabel(___('Product Categories'));
     /* Billing Settings */
     $fieldSet = $this->addElement('fieldset', 'billing', array('id' => 'billing'))->setLabel(___('Billing'));
     $fieldSet->addElement('advcheckbox', 'tax_group', array('value' => IProduct::ALL_TAX))->setLabel(___('Apply Tax?'));
     $fieldSet->addElement('select', 'currency', array('class' => 'am-combobox'))->setLabel(___("Currency\n" . 'you can choose from list of currencies supported by paysystems'))->loadOptions(Am_Currency::getSupportedCurrencies('ru_RU'));
     $this->addBillingPlans();
     //        $fieldSet->addElement('text', 'trial_group', array('size' => 20))
     //                ->setLabel(___("Trial Group\n".
     //                'If this field is filled-in, user will be unable to order the product
     //                    twice. It is extermelly useful for any trial product. This field
     //                    can have different values for different products, then "trial history"
     //                    will be separate for these groups of products.
     //                    If your site offers only one level of membership,
     //                    just enter "1" to this field. '));
     /* Product availability */
     $fieldSet = $this->addAdvFieldset('avail')->setLabel(___('Product Availability'));
     $this->insertAvailablilityFields($fieldSet);
     $sdGroup = $fieldSet->addGroup()->setLabel(___("Start Date Calculation\n" . "rules for subscription start date calculation.\n" . "MAX date from alternatives will be chosen.\n" . "This settings has no effect for recurring subscriptions"));
     $sd = $sdGroup->addSelect('start_date', array('multiple' => 'mutliple', 'id' => 'start-date-edit'));
     $sd->loadOptions(array(Product::SD_PRODUCT => ___('Last existing subscription date of this product'), Product::SD_GROUP => ___('Last expiration date in the renewal group'), Product::SD_FIXED => ___('Fixed date'), Product::SD_PAYMENT => ___('Payment date'), ___('Nearest') => array(Product::SD_WEEKDAY_SUN => ___('Nearest Sunday'), Product::SD_WEEKDAY_MON => ___('Nearest Monday'), Product::SD_WEEKDAY_TUE => ___('Nearest Tuesday'), Product::SD_WEEKDAY_WED => ___('Nearest Wednesday'), Product::SD_WEEKDAY_THU => ___('Nearest Thursday'), Product::SD_WEEKDAY_FRI => ___('Nearest Friday'), Product::SD_WEEKDAY_SAT => ___('Nearest Saturday'), Product::SD_MONTH_1 => ___('Nearest 1st Day of Month'), Product::SD_MONTH_15 => ___('Nearest 15th Day of Month'))));
     $sdGroup->addDate('start_date_fixed', array('style' => 'display:none; font-size: xx-small'));
     $rgroups = Am_Di::getInstance()->productTable->getRenewalGroups();
     $roptions = array('' => ___('-- Please Select --'));
     if ($rgroups) {
         $roptions = array_merge($roptions, array_filter($rgroups));
     }
     $fieldSet->addSelect('renewal_group', array(), array('intrinsic_validation' => false, 'options' => $roptions))->setLabel(___("Renewal Group\n" . "Allows you to set up sequential or parallel subscription periods. " . "Subscriptions from the same group will begin at the end of " . "subscriptions from the same group. Subscriptions from different " . "groups can run side-by-side"));
     /* Additional Options */
     $this->insertAdditionalFields();
     $this->addAdvCheckbox('is_archived')->setLabel(___("Is Archived?\n" . "archived product will be removed from all lists"));
 }