add router and addr_block delete features, RT13197
[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                                        'Action',
13                                      ],
14                 'fields'          => [ 'routername',
15                                        sub { join( '<BR>', map { $_->NetAddr }
16                                                                shift->addr_block
17                                                  );
18                                            },
19                                        sub { 'Delete' },
20                                      ],
21                 'links'           => [ [ "${p2}edit/router.cgi?", 'routernum' ],
22                                        '',
23                                        [ "${p}misc/delete-router.html?", 'routernum' ],
24                                      ],
25                 'agent_virt'      => 1,
26                 'agent_null_right'=> "Broadband global configuration",
27                 'agent_pos'       => 1,
28           )
29 %>
30 <%init>
31
32 die "access denied"
33   unless $FS::CurrentUser::CurrentUser->access_right('Broadband configuration')
34   || $FS::CurrentUser::CurrentUser->access_right('Broadband global configuration');
35
36 my $p2 = popurl(2);
37 my $extra_sql = '';
38
39 my @menubar = ( 'Add a new router', "${p2}edit/router.cgi" );
40
41 if ($cgi->param('hidecustomerrouters') eq '1') {
42   $extra_sql = 'WHERE svcnum > 0';
43   $cgi->param('hidecustomerrouters', 0);
44   push @menubar, 'Show customer routers', $cgi->self_url();
45 } else {
46   $cgi->param('hidecustomerrouters', 1);
47   push @menubar, 'Hide customer routers', $cgi->self_url();
48 }
49
50 my $count_sql = $extra_sql.  ( $extra_sql =~ /WHERE/ ? ' AND' : 'WHERE' ).
51   $FS::CurrentUser::CurrentUser->agentnums_sql(
52     'null_right' => 'Broadband global configuration',
53   );
54
55 </%init>