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