Option to ignore old CDRs, RT#81480
[freeside.git] / httemplate / browse / access_user.html
index 5b78797..446bfe0 100644 (file)
@@ -1,16 +1,29 @@
-<%
+<% 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>
 
-my $html_init = 
-  "Internal users have access to the back-office interface.  Typically, this is your employees and contractors, but in a VISP setup, you can also add accounts for your reseller's employees.  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 internal user</I></A><BR><BR>!;
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
 
-#false laziness w/part_pkg.cgi
-my %search = ();
-my $search = '';
-unless ( $cgi->param('showdisabled') ) {
-  %search = ( 'disabled' => '' );
-  $search = "( disabled = '' OR disabled IS NULL )";
-}
+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 {
@@ -36,63 +49,37 @@ my $groups_sub = sub {
 
 };
 
-my $posttotal;
-if ( $cgi->param('showdisabled') ) {
-  $cgi->param('showdisabled', 0);
-  $posttotal = '( <a href="'. $cgi->self_url. '">hide disabled users</a> )';
-  $cgi->param('showdisabled', 1);
-} else {
-  $cgi->param('showdisabled', 1);
-  $posttotal = '( <a href="'. $cgi->self_url. '">show disabled users</a> )';
-  $cgi->param('showdisabled', 0);
-}
+my $installer_sub = sub {
+  my $access_user = shift;
+  my @sched_item = $access_user->sched_item or return '';
+  $sched_item[0]->disabled ? '(disabled)' : 'Installer';
+};
+
+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';
-$count_query .= " WHERE $search"
-  if $search;
 
 my $link = [ $p.'edit/access_user.html?', 'usernum' ];
 
-my @header = ( '#', 'Username' );
-my @fields = ( 'usernum', 'username' );
-my $align = 'rl';
-my @links = ( $link, $link );
-my @style = ( '', '' );
+my @header = (
+  'Username', 'Full name', 'Groups',    'Installer',    'Customer' );
+my @fields = (
+  'username', 'name',      $groups_sub, $installer_sub, $cust_sub, );
+my $align = 'lllcl';
+my @links = ( $link, $link, $link, '', '', $cust_link );
 
-#false laziness w/part_pkg.cgi
-#unless ( $cgi->param('showdisabled') ) { #its been reversed already
-if ( $cgi->param('showdisabled') ) { #its been reversed already
-  push @header, 'Status';
-  push @fields, sub { shift->disabled
-                        ? '<FONT COLOR="#FF0000">DISABLED</FONT>'
-                        : '<FONT COLOR="#00CC00">Active</FONT>'
-                    };
-  push @links, '';
-  $align .= 'c';
-  push @style, 'b';
-}
+#if ( FS::Conf->new->config('ticket_system') ) {
+#  push @header, 'Ticketing';
+#  push @fields, sub {
+#    my $access_user = shift;
+#
+#  };
+#  $align .= 'l';
+#  push @links, '';
+#}
 
-push @header, 'Full name', 'Groups';
-push @fields, 'name',      $groups_sub;
-push @links,  $link,       '';
-$align .= 'll';
-
-%><%= include( 'elements/browse.html',
-                 'title'          => 'Internal Users',
-                 'menubar'        => [ #'Main menu' => $p,
-                                       'Internal access groups' => $p.'browse/access_group.html',
-                                     ],
-                 'html_init'      => $html_init,
-                 'html_posttotal' => $posttotal,
-                 'name'           => 'internal users',
-                 'query'          => { 'table'     => 'access_user',
-                                       'hashref'   => \%search,
-                                       'extra_sql' => 'ORDER BY last, first',
-                                     },
-                 'count_query'    => $count_query,
-                 'header'         => \@header,
-                 'fields'         => \@fields,
-                 'links'          => \@links,
-                 'style'          => \@style,
-             )
-%>
+</%init>