X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fbrowse%2Frouter.cgi;h=c7713f31340f28f531ee5f3947e21bea1a4df7ba;hb=0df2eac272aa26a62431f5cd830c1cb7b1018e32;hp=149db49031d08fc05367cd8838644e73289e6748;hpb=5fc8c5edf574ab024d4646914b6432d458e2ffbd;p=freeside.git diff --git a/httemplate/browse/router.cgi b/httemplate/browse/router.cgi index 149db4903..c7713f313 100644 --- a/httemplate/browse/router.cgi +++ b/httemplate/browse/router.cgi @@ -1,57 +1,68 @@ -<%= header('Routers', menubar('Main Menu' => $p)) %> -<% +<% include('elements/browse.html', + 'title' => 'Routers', + 'menubar' => [ @menubar ], + 'name_singular' => 'router', + 'query' => { 'table' => 'router', + 'hashref' => {}, + 'extra_sql' => $extra_sql, + }, + 'count_query' => "SELECT count(*) from router $count_sql", + 'header' => [ @header_fields ], + 'fields' => [ @fields ], + 'links' => [ @links ], + 'agent_virt' => 1, + 'agent_null_right'=> "Broadband global configuration", + 'agent_pos' => 1, + ) +%> +<%init> -my @router = qsearch('router', {}); -my $p2 = popurl(2); +use CGI qw(escapeHTML); -%> +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Broadband configuration') + || $FS::CurrentUser::CurrentUser->access_right('Broadband global configuration'); -<% if ($cgi->param('error')) { %> - Error: <%=$cgi->param('error')%> -

-<% } %> +my $p2 = popurl(2); +my $extra_sql = ''; + +my @menubar = ( 'Add a new router', "${p2}edit/router.cgi" ); -<% -my $hidecustomerrouters = 0; -my $hideurl = ''; if ($cgi->param('hidecustomerrouters') eq '1') { - $hidecustomerrouters = 1; - $cgi->param('hidecustomerrouters', 0); - $hideurl = 'Show customer routers'; + $extra_sql = 'WHERE svcnum > 0'; + $cgi->delete('hidecustomerrouters'); + push @menubar, 'Show customer routers', $cgi->self_url(); + $cgi->param('hidecustomerrouters', 1); } else { - $hidecustomerrouters = 0; $cgi->param('hidecustomerrouters', 1); - $hideurl = 'Hide customer routers'; + push @menubar, 'Hide customer routers', $cgi->self_url(); + $cgi->delete('hidecustomerrouters'); } -%> -Add a new router | <%=$hideurl%> - -<%=table()%> - - Router name - Address block(s) - -<% foreach my $router (sort {$a->routernum <=> $b->routernum} @router) { - next if $hidecustomerrouters && $router->svcnum; - my @addr_block = $router->addr_block; - if (scalar(@addr_block) == 0) { - push @addr_block, ' '; - } -%> - - - <%=$router->routername%> - - - <% foreach my $block ( @addr_block ) { %> - - <%=UNIVERSAL::isa($block, 'FS::addr_block') ? $block->NetAddr : ' '%> - - <% } %> - -<% } %> - - - +my @header_fields = ('Router name', 'Address block(s)', 'IP addressing'); +my @fields = ( 'routername', + sub { join( '
', map { $_->NetAddr } shift->addr_block); }, + sub { shift->manual_addr ? 'Manual' : 'Automatic' }, + ); +my @links = ( [ "${p2}edit/router.cgi?", 'routernum' ], + '', + '', + ); + +foreach (FS::router->virtual_fields_hash) { + push @header_fields, escapeHTML($_->{'label'}); + push @fields, escapeHTML($_->{'name'}); + push @links, ''; +} + +push @header_fields, 'Action'; +push @fields, sub { 'Delete' }; +push @links, [ "${p}misc/delete-router.html?", 'routernum' ]; + +my $count_sql = $extra_sql. ( $extra_sql =~ /WHERE/ ? ' AND' : 'WHERE' ). + $FS::CurrentUser::CurrentUser->agentnums_sql( + 'null_right' => 'Broadband global configuration', + ); + +