retouch bandwidth countdown
[freeside.git] / httemplate / search / prepay_credit.html
1 %
2 %my $agent = '';
3 %my $hashref = {};
4 %if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
5 %  $hashref->{agentnum} = $1;
6 %  $agent = qsearchs('agent', { 'agentnum' => $1 } );
7 %}
8 %
9 %my $count_query = 'SELECT COUNT(*) FROM prepay_credit';
10 %$count_query .= ' WHERE agentnum = '. $agent->agentnum if $agent;
11 %
12 <% include( 'elements/search.html',
13                  'title'       => 'Unused Prepaid Cards'.
14                                   ($agent ? ' for '. $agent->agent : ''),
15                  'menubar'     => [
16                    'Main menu'      => $p,
17                    'Generate cards' => $p.'edit/prepay_credit.cgi',
18                  ],
19                  'name'        => 'prepaid cards',
20                  'query'       => {  'table'   => 'prepay_credit',
21                                      'hashref' => $hashref,
22                                   },
23                  'count_query' => $count_query,
24                  #'redirect'    => $link,
25                  'header'      => [ '#', qw(Amount Time Upload Download Total Agent) ],
26                  'fields'      => [
27                    'identifier',
28                    sub { sprintf('$%.2f', shift->amount ) },
29                    sub { my $c = shift;
30                          $c->seconds ? duration_exact($c->seconds) : ''
31                        },
32                    sub { my $c = shift;
33                          $c->upbytes 
34                            ? FS::UI::Web::bytecount_unexact($c->upbytes)
35                            : ''
36                        },
37                    sub { my $c = shift;
38                          $c->downbytes
39                            ? FS::UI::Web::bytecount_unexact($c->downbytes)
40                            : ''
41                        },
42                    sub { my $c = shift;
43                          $c->totalbytes
44                            ? FS::UI::Web::bytecount_unexact($c->totalbytes)
45                            : ''
46                        },
47                    sub { my $agent = shift->agent;
48                          $agent ? $agent->agent : '';
49                        },
50                  ],
51                  'links' => [
52                    '',
53                    '',
54                    '',
55                    '',
56                    '',
57                    '',
58                    sub { my $agent = shift->agent;
59                          $agent ? [ "${p}view/agent.cgi?", 'agentnum' ] : '';
60                        },
61                  ],
62       )
63 %>