summaryrefslogtreecommitdiff
path: root/httemplate/browse/router.cgi
blob: 541e967ddf34ef2b6cebe1fdcaf83b7df4792139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<% 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'          => [ 'Router name',
                                       'Address block(s)',
                                     ],
                'fields'          => [ 'routername',
                                       sub { join( '<BR>', map { $_->NetAddr }
                                                               shift->addr_block
                                                 );
                                           },
                                     ],
                'links'           => [ [ "${p2}edit/router.cgi?", 'routernum' ],
                                       '',
                                     ],
                'agent_virt'      => 1,
                'agent_null_right'=> "Broadband global configuration",
                'agent_pos'       => 1,
          )
%>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Broadband configuration')
  || $FS::CurrentUser::CurrentUser->access_right('Broadband global configuration');

my $p2 = popurl(2);
my $extra_sql = '';

my @menubar = ( 'Add a new router', "${p2}edit/router.cgi" );

if ($cgi->param('hidecustomerrouters') eq '1') {
  $extra_sql = 'WHERE svcnum > 0';
  $cgi->param('hidecustomerrouters', 0);
  push @menubar, 'Show customer routers', $cgi->self_url();
} else {
  $cgi->param('hidecustomerrouters', 1);
  push @menubar, 'Hide customer routers', $cgi->self_url();
}

my $count_sql = $extra_sql.  ( $extra_sql =~ /WHERE/ ? ' AND' : 'WHERE' ).
  $FS::CurrentUser::CurrentUser->agentnums_sql(
    'null_right' => 'Broadband global configuration',
  );

</%init>