its all about control
[freeside.git] / httemplate / browse / agent_type.cgi
1 <% include( 'elements/browse.html',
2                  'title'   => 'Agent Types',
3                  'menubar'     => [ #'Main menu' => $p,
4                                     'Agents'    =>"${p}browse/agent.cgi",
5                                   ],
6                  'html_init'   => $html_init,
7                  'name'        => 'agent types',
8                  'query'       => { 'table'     => 'agent_type',
9                                     'hashref'   => {},
10                                     'extra_sql' => 'ORDER BY typenum', # 'ORDER BY atype',
11                                   },
12                  'count_query' => $count_query,
13                  'header'      => [ '#',
14                                     'Agent Type',
15                                     'Packages',
16                                   ],
17                  'fields'      => [ 'typenum',
18                                     'atype',
19                                     $packages_sub,
20                                   ],
21                  'links'       => [ $link,
22                                     $link,
23                                     '',
24                                   ],
25              )
26 %>
27 <%init>
28
29 die "access denied"
30   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
31
32 my $html_init = 
33 'Agent types define groups of packages that you can then assign to'.
34 ' particular agents.<BR><BR>'.
35 qq!<A HREF="${p}edit/agent_type.cgi"><I>Add a new agent type</I></A><BR><BR>!;
36
37 my $count_query = 'SELECT COUNT(*) FROM agent_type';
38
39 #false laziness w/access_user.html
40 my $packages_sub = sub {
41 my $agent_type = shift;
42
43 [ map  {
44          my $type_pkgs = $_;
45          #my $part_pkg = $type_pkgs->part_pkg;
46          [
47            {
48              #'data'  => $part_pkg->pkg. ' - '. $part_pkg->comment,
49              'data'  => $type_pkgs->pkg. ' - '. $type_pkgs->comment,
50              'align' => 'left',
51              'link'  => $p. 'edit/part_pkg.cgi?'. $type_pkgs->pkgpart,
52            },
53          ];
54        }
55
56   $agent_type->type_pkgs_enabled
57 ];
58
59 };
60
61 my $link = [ $p.'edit/agent_type.cgi?', 'typenum' ];
62
63 </%init>