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