RT# 82949 - changes section name from fees to pricing, better opiton
[freeside.git] / httemplate / browse / access_group.html
index d1c3aea..2df0ba0 100644 (file)
@@ -1,63 +1,11 @@
-%
-%
-%my $html_init = 
-%  "Internal access groups control access to the back-office interface.<BR><BR>".
-%  qq!<A HREF="${p}edit/access_group.html"><I>Add an internal access group</I></A><BR><BR>!;
-%
-%#false laziness w/access_user.html & agent_type.cgi
-%my $agents_sub = sub {
-%  my $access_group = shift;
-%
-%  [ map {
-%          my $access_groupagent = $_;
-%          my $agent = $access_groupagent->agent;
-%          [
-%            {
-%              'data'  => $agent->agent,
-%              'align' => 'left',
-%              'link'  => $p. 'edit/agent.cgi?'. $agent->agentnum,
-%            },
-%          ];
-%        }
-%    grep { $_->agent } #?
-%    $access_group->access_groupagent,
-%
-%  ];
-%  
-%};
-%
-%my $rights_sub = sub {
-%  my $access_group = shift;
-%
-%  [ map { my $access_right = $_;
-%          [
-%            { 
-%              'data'  => $access_right->rightname,
-%              'align' => 'left',
-%            },
-%          ];
-%        }
-%    $access_group->access_rights,
-%
-%  ];
-%
-%};
-%
-%my $count_query = 'SELECT COUNT(*) FROM access_group';
-%
-%my $link = [ $p.'edit/access_group.html?', 'groupnum' ];
-%
-%
 <% include( 'elements/browse.html',
-                 'title'       => 'Internal Access Groups',
-                 'menubar'     => [ # 'Main menu' => $p,
-                                    'Internal users' => $p.'browse/access_user.html',
-                                  ],
+                 'title'       => 'Employee Groups',
+                 'menubar'     => [ 'View Employees' => $p.'browse/access_user.html', ],
                  'html_init'   => $html_init,
-                 'name'        => 'internal access groups',
+                 'name'        => 'employee groups',
                  'query'       => { 'table'     => 'access_group',
                                     'hashref'   => {},
-                                    'extra_sql' => 'ORDER BY groupname', #??
+                                    'order_by' => 'ORDER BY groupname', #??
                                   },
                  'count_query' => $count_query,
                  'header'      => [ '#',
                                   ],
              )
 %>
+<%once>
+
+my $html_init = 
+  "Employee groups control access to the back-office interface.  Each employee can be assigned to one or more groups.<BR><BR>".
+  qq!<A HREF="${p}edit/access_group.html"><I>Add an employee group</I></A><BR><BR>!;
+
+#false laziness w/access_user.html & agent_type.cgi
+my $agents_sub = sub {
+  my $access_group = shift;
+
+  [ map {
+          my $access_groupagent = $_;
+          my $agent = $access_groupagent->agent;
+          [
+            {
+              'data'  => $agent->agent,
+              'align' => 'left',
+              'link'  => $p. 'edit/agent.cgi?'. $agent->agentnum,
+            },
+          ];
+        }
+    grep { $_->agent } #?
+    $access_group->access_groupagent,
+
+  ];
+  
+};
+
+tie my %rights, 'Tie::IxHash', FS::AccessRight->rights_info;
+
+my $rights_sub = sub {
+  my $access_group = shift;
+
+  #[ map { my $access_right = $_;
+  #        [
+  #          { 
+  #            'data'  => $access_right->rightname,
+  #            'align' => 'left',
+  #          },
+  #        ];
+  #      }
+  #  $access_group->access_rights,
+  #];
+
+  #some false laziness w/edit/access_group.html
+  my $columns = 3;
+  my $count = 0;
+
+  #include('/elements/table-grid.html', bgcolor=>'#cccccc' ).
+  '<TABLE>'.
+  '<TR>'. join( '', map {
+    
+    '<TD CLASS="inv" VALIGN="top"><TABLE WIDTH=100%>'.
+    '<TR><TH BGCOLOR="#dcdcdc">'. $_. '</TH></TR>'.
+    '<TR><TD>'.
+
+     join('<BR>', grep { $access_group->access_right($_); }
+                   map { ref($_) ? $_->{'rightname'} : $_; }
+                       @{ $rights{$_} }
+         ).
+
+    '</TD></TR></TABLE></TD>'.
+    ( ++$count % $columns ? '' : '</TR><TR>')
+  
+  } keys %rights ). '</TR></TABLE>';
+
+};
+
+my $count_query = 'SELECT COUNT(*) FROM access_group';
+
+my $link = [ $p.'edit/access_group.html?', 'groupnum' ];
+
+</%once>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+</%init>