public function definition() { global $CFG, $USER; $mform =& $this->_form; $mform->addElement('header', 'header', get_string('purchaser_details', 'block_iomad_commerce')); $strrequired = get_string('required'); $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="50"'); $mform->addRule('firstname', $strrequired, 'required', null, 'client'); $mform->setType('firstname', PARAM_NOTAGS); $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="50"'); $mform->addRule('lastname', $strrequired, 'required', null, 'client'); $mform->setType('lastname', PARAM_NOTAGS); $mform->addElement('text', 'company', get_string('company', 'block_iomad_company_admin'), 'maxlength="40" size="50"'); $mform->addRule('company', $strrequired, 'required', null, 'client'); $mform->setType('company', PARAM_NOTAGS); $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="50"'); $mform->addRule('address', $strrequired, 'required', null, 'client'); $mform->setType('address', PARAM_NOTAGS); $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="50"'); $mform->addRule('city', $strrequired, 'required', null, 'client'); $mform->setType('city', PARAM_NOTAGS); $mform->addElement('text', 'postcode', get_string('postcode', 'block_iomad_commerce'), 'maxlength="20" size="20"'); $mform->addRule('postcode', $strrequired, 'required', null, 'client'); $mform->setType('postcode', PARAM_NOTAGS); $choices = get_string_manager()->get_list_of_countries(); $choices = array('' => get_string('selectacountry') . '...') + $choices; $mform->addElement('select', 'country', get_string('selectacountry'), $choices); $mform->addRule('country', $strrequired, 'required', null, 'client'); $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="50"'); $mform->addRule('email', $strrequired, 'required', null, 'client'); $mform->setType('email', PARAM_NOTAGS); $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="50"'); $mform->setType('phone1', PARAM_NOTAGS); $mform->addElement('header', 'header', get_string('payment_options', 'block_iomad_commerce')); $choices = array(); foreach (get_enabled_payment_providers() as $p) { $choices[$p] = get_payment_provider_displayname($p); } if (!$choices) { $mform->addElement('html', '<div class="alert">' . get_string('noproviders', 'block_iomad_commerce') . '</div>'); } else { $mform->addElement('select', 'paymentprovider', get_string('paymentprovider', 'block_iomad_commerce'), $choices); $mform->addRule('paymentprovider', $strrequired, 'required', null, 'client'); } $mform->addElement('hidden', 'userid', $USER->id); $mform->setType('userid', PARAM_INT); $this->add_action_buttons(true, get_string('continue')); }
public function __construct() { if (!$this->enabled()) { throw new Exception(get_string('payment_provider_disabled', 'block_iomad_commerce', get_payment_provider_displayname($this->name()))); } }