add internal user disable-ing
authorivan <ivan>
Mon, 7 Aug 2006 02:44:29 +0000 (02:44 +0000)
committerivan <ivan>
Mon, 7 Aug 2006 02:44:29 +0000 (02:44 +0000)
FS/FS/CurrentUser.pm
FS/FS/Schema.pm
FS/FS/access_user.pm
httemplate/browse/access_user.html
httemplate/browse/part_pkg.cgi
httemplate/edit/access_user.html
httemplate/edit/elements/edit.html

index 9f2c93f..bcd337d 100644 (file)
@@ -36,6 +36,7 @@ sub load_user {
   $CurrentUser = qsearchs('access_user', {
     'username' => $user,
     #'_password' =>
+    'disabled' => '',
   } );
 
   die "unknown user: $user" unless $CurrentUser; # or bad password
index 3e1d68f..04dcb82 100644 (file)
@@ -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' ] ],
index 37b3b2f..5d1e183 100644 (file)
@@ -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;
 
index be11bf8..5b78797 100644 (file)
@@ -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,
              )
 %>
index b67a5e5..a5e212d 100755 (executable)
@@ -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';
index 2b19dbf..fb2a971 100644 (file)
@@ -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' =>
index f79cc0b..c40a004 100644 (file)
@@ -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
   #               },
   #             ]
   #
       %>
     </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>