import torrus 1.0.9
[freeside.git] / httemplate / browse / access_user.html
1 <% include( 'elements/browse.html',
2                  'title'              => 'Employees',
3                  'menubar'            => [ 'View Employee groups' => $p.'browse/access_group.html', ],
4                  'html_init'          => $html_init,
5                  'name'               => 'employees',
6                  'disableable'        => 1,
7                  'disabled_statuspos' => 2,
8                  'query'              => { 'table'     => 'access_user',
9                                            'hashref'   => {},
10                                            'order_by' => 'ORDER BY last, first'
11                                          },
12                  'count_query'        => $count_query,
13                  'header'             => \@header,
14                  'fields'             => \@fields,
15                  'links'              => \@links,
16                  'align'              => $align,
17              )
18 %>
19 <%init>
20
21 die "access denied"
22   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
23
24 my $html_init = 
25   "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.<BR><BR>It is <B>highly recommended</B> to add a <B>separate account for each person</B> rather than using role accounts.<BR><BR>".
26   qq!<A HREF="${p}edit/access_user.html"><I>Add an employee</I></A><BR><BR>!;
27
28 #false laziness w/access_group.html & agent_type.cgi
29 my $groups_sub = sub {
30   my $access_user = shift;
31
32   [ map {
33           my $access_usergroup = $_;
34           my $access_group = $access_usergroup->access_group;
35           [
36             {
37               'data'  => $access_group->groupname,
38               'align' => 'left',
39               'link'  =>
40                 $p. 'edit/access_group.html?'. $access_usergroup->groupnum,
41             },
42           ];
43         }
44     grep { $_->access_group # and ! $_->access_group->disabled
45          }
46     $access_user->access_usergroup,
47
48   ];
49
50 };
51
52 my $cust_sub = sub {
53   my $access_user = shift;
54   $access_user->user_custnum ? $access_user->user_cust_main->name : '';
55 };
56 my $cust_link = [ $p.'view/cust_main.cgi?custnum=', 'user_custnum' ];
57
58 my $count_query = 'SELECT COUNT(*) FROM access_user';
59
60 my $link = [ $p.'edit/access_user.html?', 'usernum' ];
61
62 my @header = ( '#',       'Username', 'Full name', 'Groups',    'Customer' );
63 my @fields = ( 'usernum', 'username', 'name',      $groups_sub, $cust_sub, );
64 my $align = 'rllll';
65 my @links = ( $link, $link, $link, '', $cust_link );
66
67 #if ( FS::Conf->new->config('ticket_system') ) {
68 #  push @header, 'Ticketing';
69 #  push @fields, sub {
70 #    my $access_user = shift;
71 #
72 #  };
73 #  $align .= 'l';
74 #  push @links, '';
75 #}
76
77 </%init>