summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/prepay_credit.cgi
blob: 518f79d8682a69218de10b68158aacf3441ef515 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
%
%my $hashref = {};
%
%my $agent = '';
%if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
%  $agent = qsearchs('agent', { 'agentnum' => $hashref->{agentnum}=$1 } );
%}
%
%my $error = '';
%
%my $num = 0;
%if ( $cgi->param('num') =~ /^\s*(\d+)\s*$/ ) {
%  $num = $1;
%} else {
%  $error = 'Illegal number of prepaid cards: '. $cgi->param('num');
%}
%
%$hashref->{amount}    = $cgi->param('amount');
%$hashref->{seconds}   = $cgi->param('seconds') * $cgi->param('multiplier');
%$hashref->{upbytes}   = $cgi->param('upbytes') * $cgi->param('upmultiplier');
%$hashref->{downbytes} = $cgi->param('downbytes') * $cgi->param('downmultiplier');
%$hashref->{totalbytes} = $cgi->param('totalbytes') * $cgi->param('totalmultiplier');
%
%$error ||= FS::prepay_credit::generate( $num,
%                                        scalar($cgi->param('type')), 
%                                        $hashref
%                                      );
%
%unless ( ref($error) ) {
%  $cgi->param('error', $error );
%
<%
  $cgi->redirect(popurl(3). "edit/prepay_credit.cgi?". $cgi->query_string )
%>
% } else { 


<% include("/elements/header.html", "$num prepaid cards generated".
              ( $agent ? ' for '.$agent->agent : '' ),
            menubar( 'Main menu' => popurl(3) )
          )
%>

<FONT SIZE="+1">
% foreach my $card ( @$error ) { 

  <code><% $card %></code>
  -
  <% $hashref->{amount} ? sprintf('$%.2f', $hashref->{amount} ) : '' %>
  <% $hashref->{amount} && $hashref->{seconds} ? 'and' : '' %>
  <% $hashref->{seconds} ? duration_exact($hashref->{seconds}) : '' %>
  <% $hashref->{upbytes}   ? FS::UI::bytecount::bytecount_unexact($hashref->{upbytes}) : '' %>
  <% $hashref->{downbytes} ? FS::UI::bytecount::bytecount_unexact($hashref->{downbytes}) : '' %>
  <% $hashref->{totalbytes} ? FS::UI::bytecount::bytecount_unexact($hashref->{totalbytes}) : '' %>
  <br>
% } 


</FONT>

</BODY></HTML>
% }