public function addPayoutInputs(HTML_QuickForm2_Container $fieldSet) { $el = $fieldSet->addSelect('aff_payout_type')->setLabel(___('Affiliate Payout Type'))->loadOptions(array_merge(array('' => ___('Not Selected')))); foreach (Am_Aff_PayoutMethod::getEnabled() as $method) { $el->addOption($method->getTitle(), $method->getId()); } $fieldSet->addScript()->setScript(' /**** show only options for selected payout method */ $(function(){ $("#' . $el->getId() . '").change(function() { for (i in this.options) { var v = this.options[i].value; (i == this.selectedIndex) ? $(":input[name^=aff_"+v+"_]").parents(".row").show() : $(":input[name^=aff_"+v+"_]").parents(".row").hide(); } }).change(); }); /**** end of payout method options */ '); foreach ($this->getDi()->userTable->customFields()->getAll() as $f) { if (strpos($f->name, 'aff_') === 0) { $f->addToQf2($fieldSet); } } }
/** @return Am_Aff_PayoutMethod|null */ function getPayoutMethod() { foreach (Am_Aff_PayoutMethod::getEnabled() as $k => $p) { if ($k == $this->type) { return $p; } } }
public function addPayoutInputs(HTML_QuickForm2_Container $fieldSet) { $el = $fieldSet->addSelect('aff_payout_type')->setLabel(___('Affiliate Payout Type'))->loadOptions(array_merge(array('' => ___('Not Selected')))); foreach (Am_Aff_PayoutMethod::getEnabled() as $method) { $el->addOption($method->getTitle(), $method->getId()); } $fieldSet->addScript()->setScript(' /**** show only options for selected payout method */ $(function(){ $("#' . $el->getId() . '").change(function() { var selected = $("#' . $el->getId() . '").val(); $("option", $(this)).each(function(){ var option = $(this).val(); if(option == selected){ $("input[name^=aff_"+option+"_]").closest(".row").show(); }else{ $("input[name^=aff_"+option+"_]").closest(".row").hide(); } }); }).change(); }); /**** end of payout method options */ '); foreach ($this->getDi()->userTable->customFields()->getAll() as $f) { if (strpos($f->name, 'aff_') === 0) { $f->addToQf2($fieldSet); } } }