better name for svc_acct events
[freeside.git] / httemplate / browse / access_group.html
1 <% include( 'elements/browse.html',
2                  'title'       => 'Employee Groups',
3                  'menubar'     => [ 'View Employees' => $p.'browse/access_user.html', ],
4                  'html_init'   => $html_init,
5                  'name'        => 'employee groups',
6                  'query'       => { 'table'     => 'access_group',
7                                     'hashref'   => {},
8                                     'order_by' => 'ORDER BY groupname', #??
9                                   },
10                  'count_query' => $count_query,
11                  'header'      => [ '#',
12                                     'Group name',
13                                     'Agents',
14                                     'Rights',
15                                   ],
16                  'fields'      => [ 'groupnum',
17                                     'groupname',
18                                     $agents_sub,
19                                     $rights_sub,
20                                   ],
21                  'links'       => [ $link,
22                                     $link,
23                                     '',
24                                     '',
25                                   ],
26              )
27 %>
28 <%once>
29
30 my $html_init = 
31   "Employee groups control access to the back-office interface.  Each employee can be assigned to one or more groups.<BR><BR>".
32   qq!<A HREF="${p}edit/access_group.html"><I>Add an employee group</I></A><BR><BR>!;
33
34 #false laziness w/access_user.html & agent_type.cgi
35 my $agents_sub = sub {
36   my $access_group = shift;
37
38   [ map {
39           my $access_groupagent = $_;
40           my $agent = $access_groupagent->agent;
41           [
42             {
43               'data'  => $agent->agent,
44               'align' => 'left',
45               'link'  => $p. 'edit/agent.cgi?'. $agent->agentnum,
46             },
47           ];
48         }
49     grep { $_->agent } #?
50     $access_group->access_groupagent,
51
52   ];
53   
54 };
55
56 tie my %rights, 'Tie::IxHash', FS::AccessRight->rights_info;
57
58 my $rights_sub = sub {
59   my $access_group = shift;
60
61   #[ map { my $access_right = $_;
62   #        [
63   #          { 
64   #            'data'  => $access_right->rightname,
65   #            'align' => 'left',
66   #          },
67   #        ];
68   #      }
69   #  $access_group->access_rights,
70   #];
71
72   #some false laziness w/edit/access_group.html
73   my $columns = 3;
74   my $count = 0;
75
76   #include('/elements/table-grid.html', bgcolor=>'#cccccc' ).
77   '<TABLE>'.
78   '<TR>'. join( '', map {
79     
80     '<TD CLASS="inv" VALIGN="top"><TABLE WIDTH=100%>'.
81     '<TR><TH BGCOLOR="#dcdcdc">'. $_. '</TH></TR>'.
82     '<TR><TD>'.
83
84      join('<BR>', grep { $access_group->access_right($_); }
85                    map { ref($_) ? $_->{'rightname'} : $_; }
86                        @{ $rights{$_} }
87          ).
88
89     '</TD></TR></TABLE></TD>'.
90     ( ++$count % $columns ? '' : '</TR><TR>')
91   
92   } keys %rights ). '</TR></TABLE>';
93
94 };
95
96 my $count_query = 'SELECT COUNT(*) FROM access_group';
97
98 my $link = [ $p.'edit/access_group.html?', 'groupnum' ];
99
100 </%once>
101 <%init>
102
103 die "access denied"
104   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
105
106 </%init>