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} %></OPTION>
27 % for (1..100) { #100? arbitrary.
28 % my $selected = ($opt{'curr_quantity'} == $_) ? ' SELECTED' : '';
29 <OPTION VALUE="<% $_ %>"<% $selected %>><%
30 $money_char. sprintf('%.2f', $_ * $part_pkg_usageprice->price ).
32 'for'. #( $part_pkg_usageprice->action eq 'increment' ? 'per' : 'for' ).
34 ( $_ * $amount ). ' '. $info->{label}
48 my $conf = new FS::Conf;
49 my $money_char = $conf->config('money_char') || '$';
51 my $name = $opt{'element_name'} || $opt{'field'} || 'usagepricenum';
52 my $id = $opt{'id'} || $opt{'field'} || 'usagepricenum';
54 my $curr_value = $opt{'curr_value'} || $opt{'value'};
57 if ( $opt{'onchange'} ) {
58 $onchange = $opt{'onchange'};
59 $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
60 $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange
61 #callbacks should act the same
62 $onchange = 'onChange="'. $onchange. '"';
65 my $cust_pkg_usageprice = $curr_value
66 ? qsearchs('cust_pkg_usageprice', { 'usagepricenum' => $curr_value } )
67 : new FS::cust_pkg_usageprice { 'usagepricepart' => $opt{usagepricepart} };
69 my $part_pkg_usageprice = $cust_pkg_usageprice->part_pkg_usageprice;