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