ACLs
[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 %$hashref->{totalbytes} = $cgi->param('totalbytes') * $cgi->param('totalmultiplier');
23 %
24 %$error ||= FS::prepay_credit::generate( $num,
25 %                                        scalar($cgi->param('type')), 
26 %                                        $hashref
27 %                                      );
28 %
29 %unless ( ref($error) ) {
30 %  $cgi->param('error', $error );
31 %
32 <%
33   $cgi->redirect(popurl(3). "edit/prepay_credit.cgi?". $cgi->query_string )
34 %>
35 % } else { 
36
37
38 <% include("/elements/header.html", "$num prepaid cards generated".
39               ( $agent ? ' for '.$agent->agent : '' )
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::bytecount::bytecount_unexact($hashref->{upbytes}) : '' %>
52   <% $hashref->{downbytes} ? FS::UI::bytecount::bytecount_unexact($hashref->{downbytes}) : '' %>
53   <% $hashref->{totalbytes} ? FS::UI::bytecount::bytecount_unexact($hashref->{totalbytes}) : '' %>
54   <br>
55 % } 
56
57
58 </FONT>
59
60 </BODY></HTML>
61 % } 
62 <%init>
63
64 die "access denied"
65   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
66
67 </%init>