Optimize "Customer has a referring customer" condition, RT#74452
[freeside.git] / httemplate / edit / access_group.html
1 <% include( 'elements/edit.html',
2               'name'   => 'Employee Group',
3               'table'  => 'access_group',
4               'labels' => { 
5                             'groupnum'   => 'Group number',
6                             'groupname'  => 'Group name',
7                           },
8
9               'viewall_dir' => 'browse',
10
11               'html_bottom' => $html_bottom_sub,
12           )
13 %>
14 <%once>
15
16 tie my %rights, 'Tie::IxHash', FS::AccessRight->rights_info;
17
18 </%once>
19 <%init>
20
21 die "access denied"
22   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
23
24 my $html_bottom_sub = sub {
25   my $access_group = shift;
26
27   #some false laziness w/browse/access_group.html
28   my $columns = 3;
29   my $count = 0;
30
31   '<BR>'.
32   '<FONT SIZE="+1">Group limited to these agent(s)</FONT><BR>'.
33   'Employees in this group will only see customers of the selected agents in the system and reports.<BR>'.
34   ntable("#cccccc",2).
35   '<TR><TD>'.
36   include( '/elements/checkboxes-table.html',
37              'source_obj'   => $access_group,
38              'link_table'   => 'access_groupagent',
39              'target_table' => 'agent',
40              'name_col'     => 'agent',
41              'target_link'  => $p.'edit/agent.cgi?',
42              'disable-able' => 1,
43          ).
44   '</TD></TR></TABLE>'.
45
46   '<BR><FONT SIZE="+1">Group access rights</FONT><BR>'.
47   include('/elements/table-grid.html', bgcolor=>'#cccccc' ).
48   '<TR>'. join( '', map {
49     '<TD CLASS="inv" VALIGN="top"><TABLE BGCOLOR="#cccccc" WIDTH=100%>'.
50     '<TR><TH BGCOLOR="#dcdcdc">'. $_. '</TH></TR>'.
51     '<TR><TD>'.
52     include( '/elements/checkboxes-table-name.html',
53                'source_obj'   => $access_group,
54                'link_table'   => 'access_right',
55                'link_static'  => { 'righttype' =>
56                                      'FS::access_group',
57                                  },
58                'num_col'      => 'rightobjnum',
59                'name_col'     => 'rightname',
60                'names_list'   => [ map { 
61                                          my $rn =
62                                            ref($_) ? $_->{'rightname'} : $_;
63                                          my %hash = ();
64                                          $hash{'note'} = '&nbsp;*'
65                                            if ref($_) && $_->{'global'};
66                                          $hash{'desc'} = $_->{'desc'}
67                                            if ref($_) &&  $_->{'desc'};
68                                          [ $rn => \%hash ];
69                                        }
70                                        @{ $rights{$_} }
71                                  ],
72            ).
73     '<BR>'.
74     '</TD></TR></TABLE></TD>'.
75     ( ++$count % $columns ? '' : '</TR><TR>')
76   
77   } keys %rights ). '</TR></TABLE>'.
78   
79   '* Global rights.  These rights provide access to global data which is shared among all agents.  Their use is not recommended for groups which are limited to a subset of agents.<BR>';
80
81 };
82
83 </%init>