% include( 'elements/browse.html',
                 'title'              => 'Employees',
                 'menubar'            => [ 'View Employee groups' => $p.'browse/access_group.html', ],
                 'html_init'          => $html_init,
                 'name'               => 'employees',
                 'disableable'        => 1,
                 'disabled_statuspos' => 2,
                 'query'              => { 'table'     => 'access_user',
                                           'hashref'   => {},
                                           'extra_sql' => 'ORDER BY last, first'
                                         },
                 'count_query'        => $count_query,
                 'header'             => \@header,
                 'fields'             => \@fields,
                 'links'              => \@links,
                 'align'              => $align,
             )
%>
<%init>
die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
my $html_init = 
  "Employees have access to the back-office interface.  Typically, this is your employees and contractors.  In a virtualized setup, you can also add accounts for your reseller's employees.
It is highly recommended to add a separate account for each person rather than using role accounts.
".
  qq!Add an employee
!;
#false laziness w/access_group.html & agent_type.cgi
my $groups_sub = sub {
  my $access_user = shift;
  [ map {
          my $access_usergroup = $_;
          my $access_group = $access_usergroup->access_group;
          [
            {
              'data'  => $access_group->groupname,
              'align' => 'left',
              'link'  =>
                $p. 'edit/access_group.html?'. $access_usergroup->groupnum,
            },
          ];
        }
    grep { $_->access_group # and ! $_->access_group->disabled
         }
    $access_user->access_usergroup,
  ];
};
my $count_query = 'SELECT COUNT(*) FROM access_user';
my $link = [ $p.'edit/access_user.html?', 'usernum' ];
my @header = ( '#',       'Username', 'Full name', 'Groups'    );
my @fields = ( 'usernum', 'username', 'name',      $groups_sub );
my $align = 'rlll';
my @links = ( $link, $link, $link, '' );
%init>