default to a session cookie instead of setting an explicit timeout, weird timezone...
[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 $goog_auth_sub = sub {
53   my $access_user = shift;
54   $access_user->totp_secret32 ? 'Enabled' : '';
55 };
56
57 my $installer_sub = sub {
58   my $access_user = shift;
59   my @sched_item = $access_user->sched_item or return '';
60   $sched_item[0]->disabled ? '(disabled)' : 'Installer';
61 };
62
63 my $cust_sub = sub {
64   my $access_user = shift;
65   $access_user->user_custnum ? $access_user->user_cust_main->name : '';
66 };
67 my $cust_link = [ $p.'view/cust_main.cgi?custnum=', 'user_custnum' ];
68
69 my $count_query = 'SELECT COUNT(*) FROM access_user';
70
71 my $link = [ $p.'edit/access_user.html?', 'usernum' ];
72
73 my @header = (
74   'Username',
75   'Full name',
76   'Groups',
77   'Google Auth',
78   'Installer',
79   'Customer',
80 );
81 my @fields = (
82   'username',
83   'name',
84   $groups_sub,
85   $goog_auth_sub,
86   $installer_sub,
87   $cust_sub,
88 );
89 my $align = 'lllccl';
90 my @links = ( $link, $link, $link, '', '', '', $cust_link );
91
92 #if ( FS::Conf->new->config('ticket_system') ) {
93 #  push @header, 'Ticketing';
94 #  push @fields, sub {
95 #    my $access_user = shift;
96 #
97 #  };
98 #  $align .= 'l';
99 #  push @links, '';
100 #}
101
102 </%init>