summaryrefslogtreecommitdiff
path: root/httemplate/browse/access_user.html
blob: 6a1fea1ce00b438e6564e38d9fb94ef17a458965 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<% 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'   => {},
                                           'order_by' => '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.<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>".
  qq!<A HREF="${p}edit/access_user.html"><I>Add an employee</I></A><BR><BR>!;

#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 $cust_sub = sub {
  my $access_user = shift;
  $access_user->user_custnum ? $access_user->user_cust_main->name : '';
};
my $cust_link = [ $p.'view/cust_main.cgi?custnum=', 'user_custnum' ];

my $count_query = 'SELECT COUNT(*) FROM access_user';

my $link = [ $p.'edit/access_user.html?', 'usernum' ];

my @header = ( '#',       'Username', 'Full name', 'Groups',    'Customer' );
my @fields = ( 'usernum', 'username', 'name',      $groups_sub, $cust_sub, );
my $align = 'rllll';
my @links = ( $link, $link, $link, '', $cust_link );

#if ( FS::Conf->new->config('ticket_system') ) {
#  push @header, 'Ticketing';
#  push @fields, sub {
#    my $access_user = shift;
#
#  };
#  $align .= 'l';
#  push @links, '';
#}

</%init>