summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2006-08-07 02:44:29 +0000
committerivan <ivan>2006-08-07 02:44:29 +0000
commit7aae40398f1c8ed42424f1694640c9796a580d22 (patch)
treee976d4331ca7c117ac96df47c7f1b7b6c2bb5ccf
parent786b78c646f892e1ae80006fb7870960780ea5db (diff)
add internal user disable-ing
-rw-r--r--FS/FS/CurrentUser.pm1
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/access_user.pm3
-rw-r--r--httemplate/browse/access_user.html87
-rwxr-xr-xhttemplate/browse/part_pkg.cgi2
-rw-r--r--httemplate/edit/access_user.html2
-rw-r--r--httemplate/edit/elements/edit.html15
7 files changed, 80 insertions, 31 deletions
diff --git a/FS/FS/CurrentUser.pm b/FS/FS/CurrentUser.pm
index 9f2c93f..bcd337d 100644
--- a/FS/FS/CurrentUser.pm
+++ b/FS/FS/CurrentUser.pm
@@ -36,6 +36,7 @@ sub load_user {
$CurrentUser = qsearchs('access_user', {
'username' => $user,
#'_password' =>
+ 'disabled' => '',
} );
die "unknown user: $user" unless $CurrentUser; # or bad password
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 3e1d68f..04dcb82 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1476,6 +1476,7 @@ sub tables_hashref {
'_password', 'varchar', '', $char_d, '', '',
'last', 'varchar', '', $char_d, '', '',
'first', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'usernum',
'unique' => [ [ 'username' ] ],
diff --git a/FS/FS/access_user.pm b/FS/FS/access_user.pm
index 37b3b2f..5d1e183 100644
--- a/FS/FS/access_user.pm
+++ b/FS/FS/access_user.pm
@@ -47,6 +47,8 @@ FS::Record. The following fields are currently supported:
=item first -
+=item disabled - empty or 'Y'
+
=back
=head1 METHODS
@@ -211,6 +213,7 @@ sub check {
|| $self->ut_text('_password')
|| $self->ut_text('last')
|| $self->ut_text('first')
+ || $self->ut_enum('disabled', [ '', 'Y' ] )
;
return $error if $error;
diff --git a/httemplate/browse/access_user.html b/httemplate/browse/access_user.html
index be11bf8..5b78797 100644
--- a/httemplate/browse/access_user.html
+++ b/httemplate/browse/access_user.html
@@ -4,6 +4,14 @@ 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>!;
+#false laziness w/part_pkg.cgi
+my %search = ();
+my $search = '';
+unless ( $cgi->param('showdisabled') ) {
+ %search = ( 'disabled' => '' );
+ $search = "( disabled = '' OR disabled IS NULL )";
+}
+
#false laziness w/access_group.html & agent_type.cgi
my $groups_sub = sub {
my $access_user = shift;
@@ -28,36 +36,63 @@ 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 $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 = ( '', '' );
+
+#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';
+}
+
+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,
- 'name' => 'internal users',
- 'query' => { 'table' => 'access_user',
- 'hashref' => {},
- 'extra_sql' => 'ORDER BY last, first',
- },
- 'count_query' => $count_query,
- 'header' => [ '#',
- 'Username',
- 'Full name',
- 'Groups'
- ],
- 'fields' => [ 'usernum',
- 'username',
- 'name', # sub { shift->name },
- $groups_sub,
- ],
- 'links' => [ $link,
- $link,
- $link,
- ''
- ],
+ '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,
)
%>
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi
index b67a5e5..a5e212d 100755
--- a/httemplate/browse/part_pkg.cgi
+++ b/httemplate/browse/part_pkg.cgi
@@ -1,5 +1,6 @@
<%
+#false laziness w/access_user.html
my %search = ();
my $search = '';
unless ( $cgi->param('showdisabled') ) {
@@ -71,6 +72,7 @@ my $align = 'rll';
my @links = ( $link, $link, '' );
my @style = ( '', '', '' );
+#false laziness w/access_user.html
#unless ( $cgi->param('showdisabled') ) { #its been reversed already
if ( $cgi->param('showdisabled') ) { #its been reversed already
push @header, 'Status';
diff --git a/httemplate/edit/access_user.html b/httemplate/edit/access_user.html
index 2b19dbf..fb2a971 100644
--- a/httemplate/edit/access_user.html
+++ b/httemplate/edit/access_user.html
@@ -6,6 +6,7 @@
{ field=>'_password', type=>'password' },
'last',
'first',
+ { field=>'disabled', type=>'checkbox', value=>'Y' },
],
'labels' => {
'usernum' => 'User number',
@@ -13,6 +14,7 @@
'_password' => 'Password',
'last' => 'Last name',
'first' => 'First name',
+ 'disabled' => 'Disable employee',
},
'viewall_dir' => 'browse',
'html_bottom' =>
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index f79cc0b..c40a004 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -15,7 +15,9 @@
# 'fields' => [
# 'columname',
# { 'field' => 'another_columname',
- # 'type' => 'text', #text, fixed, hidden
+ # 'type' => 'text', #text, fixed, hidden, checkbox
+ # #eventually more for <SELECT>, etc.
+ # 'value' => 'Y', #only for checkbox
# },
# ]
#
@@ -150,14 +152,17 @@
%>
</TD>
- <%
- #eventually more options for <SELECT>, etc. fields
- if ( $type eq 'fixed' ) {
- %>
+ <% if ( $type eq 'fixed' ) { %>
<TD BGCOLOR="#dddddd"><%= $f->{'value'} %></TD>
<INPUT TYPE="hidden" NAME="<%= $field %>" VALUE="<%= $f->{'value'} %>">
+ <% } elsif ( $type eq 'checkbox' ) { %>
+
+ <TD>
+ <INPUT TYPE="checkbox" NAME="<%= $field %>" VALUE="<%= $f->{'value'} %>" <%= $object->$field() eq $f->{'value'} ? ' CHECKED' : '' %>>
+ </TD>
+
<% } else { %>
<TD>