prepaid download/upload tracking
[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 Agent) ],
26                  'fields'      => [
27                    'identifier',
28                    sub { sprintf('$%.2f', shift->amount ) },
29                    sub { my $c = shift; $c ? duration_exact($c->seconds) : '' },
30                    sub { my $c = shift;
31                          $c ? FS::UI::Web::bytecount_unexact($c->upbytes) : ''
32                        },
33                    sub { my $c = shift;
34                          $c ? FS::UI::Web::bytecount_unexact($c->downbytes) : ''
35                        },
36                    sub { my $agent = shift->agent;
37                          $agent ? $agent->agent : '';
38                        },
39                  ],
40                  'links' => [
41                    '',
42                    '',
43                    '',
44                    '',
45                    '',
46                    sub { my $agent = shift->agent;
47                          $agent ? [ "${p}view/agent.cgi?", 'agentnum' ] : '';
48                        },
49                  ],
50       )
51 %>