1 % unless ( $opt{'js_only'} ) {
3 <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
6 field => "${name}_cycle",
7 options => [ '', 1 .. 12 ],
13 map { $_ => $_.'th' } 4 .. 12
15 onchange => $onchange,
16 curr_value => $commission_rate->get("cycle"),
18 <B><% $money_char %></B>
20 field => "${name}_amount",
22 curr_value => $commission_rate->get("amount")
24 'text-align' => 'right'
28 field => "${name}_percent",
30 curr_value => $commission_rate->get("percent")
32 'text-align' => 'right'
39 my $conf = new FS::Conf;
40 my $money_char = $conf->config('money_char') || '$';
42 my $name = $opt{'field'} || 'commissionratenum';
43 my $id = $opt{'id'} || 'commissionratenum';
45 my $curr_value = $opt{'curr_value'} || $opt{'value'};
48 if ( $opt{'onchange'} ) {
49 $onchange = $opt{'onchange'};
50 $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
51 $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange
52 #callbacks should act the same
53 $onchange = 'onChange="'. $onchange. '"';
58 $commission_rate = qsearchs('commission_rate', { 'commissionratenum' => $curr_value } );
60 $commission_rate = new FS::commission_rate {};
63 foreach my $field (qw( amount percent cycle)) {
64 my $value = $cgi->param("${name}_${field}");
65 $commission_rate->set($field, $value) if $value;