stray closing /TABLE in the no-ticket case
[freeside.git] / httemplate / elements / cust_pkg_usageprice.html
1 % unless ( $opt{'js_only'} ) {
2
3   <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
4
5   <INPUT TYPE  = "hidden"
6          NAME  = "<%$name%>_usagepricepart"
7          ID    = "<%$id%>_usagepricepart"
8          VALUE = "<% $part_pkg_usageprice->usagepricepart %>"
9   >
10
11   <TABLE STYLE="display:inline">
12     <TR>
13
14 %     ###
15 %     # action
16 %     ###
17       <TD>
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"
22                 <% $onchange %>
23         >
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 ).
31               ' '.
32               'for'. #( $part_pkg_usageprice->action eq 'increment' ? 'per' : 'for' ).
33               ' '.
34               ( $_ * $amount ). ' '. $info->{label}
35             %></OPTION>
36 %         }
37         </SELECT>
38       </TD>
39
40     </TR>
41   </TABLE>
42
43 % }
44 <%init>
45
46 my( %opt ) = @_;
47
48 my $conf = new FS::Conf;
49 my $money_char = $conf->config('money_char') || '$';
50
51 my $name = $opt{'element_name'} || $opt{'field'} || 'usagepricenum';
52 my $id = $opt{'id'} || $opt{'field'} || 'usagepricenum';
53
54 my $curr_value = $opt{'curr_value'} || $opt{'value'};
55
56 my $onchange = '';
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. '"';
63 }
64
65 my $cust_pkg_usageprice = $curr_value
66   ? qsearchs('cust_pkg_usageprice', { 'usagepricenum' => $curr_value } )
67   : new FS::cust_pkg_usageprice { 'usagepricepart' => $opt{usagepricepart} };
68
69 my $part_pkg_usageprice = $cust_pkg_usageprice->part_pkg_usageprice;
70
71 </%init>