break _bytecount subroutines out of FS::UI::Web
[freeside.git] / httemplate / search / prepay_credit.html
index c79acb0..43fc6a9 100644 (file)
@@ -1,14 +1,3 @@
-%
-%my $agent = '';
-%my $hashref = {};
-%if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
-%  $hashref->{agentnum} = $1;
-%  $agent = qsearchs('agent', { 'agentnum' => $1 } );
-%}
-%
-%my $count_query = 'SELECT COUNT(*) FROM prepay_credit';
-%$count_query .= ' WHERE agentnum = '. $agent->agentnum if $agent;
-%
 <% include( 'elements/search.html',
                  'title'       => 'Unused Prepaid Cards'.
                                   ($agent ? ' for '. $agent->agent : ''),
                        },
                    sub { my $c = shift;
                          $c->upbytes 
-                           ? FS::UI::Web::bytecount_unexact($c->upbytes)
+                           ? FS::UI::bytecount::bytecount_unexact($c->upbytes)
                            : ''
                        },
                    sub { my $c = shift;
                          $c->downbytes
-                           ? FS::UI::Web::bytecount_unexact($c->downbytes)
+                           ? FS::UI::bytecount::bytecount_unexact($c->downbytes)
                            : ''
                        },
                    sub { my $c = shift;
                          $c->totalbytes
-                           ? FS::UI::Web::bytecount_unexact($c->totalbytes)
+                           ? FS::UI::bytecount::bytecount_unexact($c->totalbytes)
                            : ''
                        },
                    sub { my $agent = shift->agent;
                  ],
       )
 %>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $agent = '';
+my $hashref = {};
+if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
+$hashref->{agentnum} = $1;
+$agent = qsearchs('agent', { 'agentnum' => $1 } );
+}
+
+my $count_query = 'SELECT COUNT(*) FROM prepay_credit';
+$count_query .= ' WHERE agentnum = '. $agent->agentnum if $agent;
+
+</%init>