1 % unless ( $opt{'js_only'} ) {
3 <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
6 NAME = "<%$name%>_usagepricepart"
7 ID = "<%$id%>_usagepricepart"
8 VALUE = "<% $part_pkg_usageprice->usagepricepart %>"
11 <TABLE STYLE="display:inline">
18 % # maybe we should be a quantity entry instead of a select? even more
19 % # javascript auto-calculation need to display a subtotal & total
20 <SELECT NAME = "<%$name%>_quantity"
21 ID = "<%$id%>_quantity"
24 % my $info = $part_pkg_usageprice->target_info;
25 % my $amount = $part_pkg_usageprice->amount / ($info->{multiplier}||1);
26 <OPTION VALUE="">Additional <% $info->{label} %>
27 % for (1..100) { #100? arbitrary.
28 <OPTION VALUE="<% $_ %>"><%
29 $money_char. sprintf('%.2f', $_ * $part_pkg_usageprice->price ).
31 'for'. #( $part_pkg_usageprice->action eq 'increment' ? 'per' : 'for' ).
33 ( $_ * $amount ). ' '. $info->{label}
45 #my $targets = FS::part_pkg_usageprice->targets;
49 my $conf = new FS::Conf;
50 my $money_char = $conf->config('money_char') || '$';
52 my $name = $opt{'element_name'} || $opt{'field'} || 'usagepricenum';
53 my $id = $opt{'id'} || $opt{'field'} || 'usagepricenum';
55 my $curr_value = $opt{'curr_value'} || $opt{'value'};
58 if ( $opt{'onchange'} ) {
59 $onchange = $opt{'onchange'};
60 $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
61 $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange
62 #callbacks should act the same
63 $onchange = 'onChange="'. $onchange. '"';
66 my $cust_pkg_usageprice = $curr_value
67 ? qsearchs('cust_pkg_usageprice', { 'usagepricenum' => $curr_value } )
68 : new FS::cust_pkg_usageprice { 'usagepricepart' => $opt{usagepricepart} };
70 my $part_pkg_usageprice = $cust_pkg_usageprice->part_pkg_usageprice;