Reverted menu-left-example.png back to original and cleaned up menu-top-example to...
[freeside.git] / httemplate / browse / agent_type.cgi
1 <& elements/browse.html,
2      'title'              => 'Agent Types',
3      'menubar'            => [ 'Agents' => "${p}browse/agent.cgi" ],
4      'html_init'          => $html_init,
5      'name'               => 'agent types',
6      'disableable'        => 1,
7      'disabled_statuspos' => 2,
8      'query'              => { 'table'     => 'agent_type',
9                                'hashref'   => {},
10                                'order_by' => 'ORDER BY typenum', # 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 <%init>
27
28 die "access denied"
29   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
30
31 my $html_init = 
32 'Agent types define groups of packages that you can then assign to'.
33 ' particular agents.<BR><BR>'.
34 qq!<A HREF="${p}edit/agent_type.cgi"><I>Add a new agent type</I></A><BR><BR>!;
35
36 my $count_query = 'SELECT COUNT(*) FROM agent_type';
37
38 #false laziness w/access_user.html
39 my $packages_sub = sub {
40   my $agent_type = shift;
41   my @type_pkgs = $agent_type->type_pkgs_enabled;
42   return '(lots; edit agent type to view)' if scalar(@type_pkgs) > 32;
43
44   [ map {
45           my $type_pkgs = $_;
46           #my $part_pkg = $type_pkgs->part_pkg;
47           [
48             {
49               #'data'  => $part_pkg->pkg. ' - '. $part_pkg->comment,
50               'data'  => encode_entities($type_pkgs->pkg). ' - '.
51                          ( $type_pkgs->custom ? '(CUSTOM) ' : '' ).
52                          encode_entities($type_pkgs->comment),
53               'align' => 'left',
54               'link'  => $p. 'edit/part_pkg.cgi?'. $type_pkgs->pkgpart,
55             },
56           ];
57         }
58       @type_pkgs
59   ];
60
61 };
62
63 my $link = [ $p.'edit/agent_type.cgi?', 'typenum' ];
64
65 </%init>