4.x+ self-service API: list and remove cards on file, RT#38919
[freeside.git] / httemplate / browse / router.cgi
1 <% include('elements/browse.html',
2                 'title'           => 'Routers',
3                 'menubar'         => [ @menubar ],
4                 'name_singular'   => 'router',
5                 'query'           => { 'table'     => 'router',
6                                        'hashref'   => {},
7                                        'extra_sql' => $extra_sql,
8                                      },
9                 'count_query'     => "SELECT count(*) from router $count_sql",
10                 'header'          => [ 'Router name',
11                                        'Address block(s)',
12                                        'IP addressing',
13                                        'Action',
14                                      ],
15                 'fields'          => [ 'routername',
16                                        sub { join( '<BR>', map { $_->NetAddr }
17                                                                shift->addr_block
18                                                  );
19                                            },
20                                        sub { shift->manual_addr ? 'Manual' : 'Automatic' },
21                                        sub { 'Delete' },
22                                      ],
23                 'links'           => [ [ "${p2}edit/router.cgi?", 'routernum' ],
24                                        '',
25                                        '',
26                                        [ "${p}misc/delete-router.html?", 'routernum' ],
27                                      ],
28                 'agent_virt'      => 1,
29                 'agent_null_right'=> "Broadband global configuration",
30                 'agent_pos'       => 1,
31           )
32 %>
33 <%init>
34
35 die "access denied"
36   unless $FS::CurrentUser::CurrentUser->access_right('Broadband configuration')
37   || $FS::CurrentUser::CurrentUser->access_right('Broadband global configuration');
38
39 my $p2 = popurl(2);
40 my $extra_sql = '';
41
42 my @menubar = ( 'Add a new router', "${p2}edit/router.cgi" );
43
44 if ($cgi->param('hidecustomerrouters') eq '1') {
45   $extra_sql = 'WHERE svcnum > 0';
46   $cgi->param('hidecustomerrouters', 0);
47   push @menubar, 'Show customer routers', $cgi->self_url();
48 } else {
49   $cgi->param('hidecustomerrouters', 1);
50   push @menubar, 'Hide customer routers', $cgi->self_url();
51 }
52
53 my $count_sql = $extra_sql.  ( $extra_sql =~ /WHERE/ ? ' AND' : 'WHERE' ).
54   $FS::CurrentUser::CurrentUser->agentnums_sql(
55     'null_right' => 'Broadband global configuration',
56   );
57
58
59 </%init>