RT# 82949 - changes section name from fees to pricing, better opiton
[freeside.git] / httemplate / edit / process / prepay_credit.cgi
1 %unless ( ref($error) ) {
2 %  $cgi->param('error', $error );
3 <% $cgi->redirect(popurl(3). "edit/prepay_credit.cgi?". $cgi->query_string ) %>
4 % } else { 
5
6 <% include('/elements/header.html', "$num prepaid cards generated".
7               ( $agent ? ' for '.$agent->agent : '' )
8           )
9 %>
10
11 <FONT SIZE="+1">
12 % foreach my $card ( @$error ) { 
13
14   <code><% $card %></code>
15   -
16   <% $hashref->{amount} ? sprintf('$%.2f', $hashref->{amount} ) : '' %>
17   <% $hashref->{amount} && $hashref->{seconds} ? 'and' : '' %>
18   <% $hashref->{seconds} ? duration_exact($hashref->{seconds}) : '' %>
19   <% $hashref->{upbytes}   ? FS::UI::bytecount::bytecount_unexact($hashref->{upbytes}) : '' %>
20   <% $hashref->{downbytes} ? FS::UI::bytecount::bytecount_unexact($hashref->{downbytes}) : '' %>
21   <% $hashref->{totalbytes} ? FS::UI::bytecount::bytecount_unexact($hashref->{totalbytes}) : '' %>
22   <br>
23 % } 
24
25 </FONT>
26
27 <% include('/elements/footer.html') %>
28
29 % } 
30 <%init>
31
32 die "access denied"
33   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
34
35 my $hashref = {};
36
37 my $agent = '';
38 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
39   $agent = qsearchs('agent', { 'agentnum' => $hashref->{agentnum}=$1 } );
40 }
41
42 my $error = '';
43
44 my $num = 0;
45 if ( $cgi->param('num') =~ /^\s*(\d+)\s*$/ ) {
46   $num = $1;
47 } else {
48   $error = 'Illegal number of prepaid cards: '. $cgi->param('num');
49 }
50
51 $hashref->{amount}    = $cgi->param('amount');
52 $hashref->{seconds}   = $cgi->param('seconds') * $cgi->param('multiplier');
53 $hashref->{upbytes}   = $cgi->param('upbytes') * $cgi->param('upmultiplier');
54 $hashref->{downbytes} = $cgi->param('downbytes') * $cgi->param('downmultiplier');
55 $hashref->{totalbytes} = $cgi->param('totalbytes') * $cgi->param('totalmultiplier');
56
57 $error ||= FS::prepay_credit::generate( $num,
58                                         scalar($cgi->param('type')), 
59                                         $cgi->param('length'),
60                                         $hashref
61                                       );
62
63 </%init>