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