merge NG auth, RT#21563
[freeside.git] / httemplate / edit / access_user.html
1 <% include( 'elements/edit.html',
2                  'name'   => 'Employee',
3                  'table'  => 'access_user',
4                  'fields' => [
5                                'username',
6                                @pw_fields,
7                                'last',
8                                'first',
9                                { field=>'user_custnum', type=>'search-cust_main', },
10                                { field=>'disabled', type=>'checkbox', value=>'Y' },
11                              ],
12                  'labels' => { 
13                                'usernum'      => 'User number',
14                                'username'     => 'Username',
15                                '_password'    => 'Password',
16                                '_password2'   => 'Re-enter Password',
17                                'last'         => 'Last name',
18                                'first'        => 'First name',
19                                'user_custnum' => 'Customer (optional)',
20                                'disabled'     => 'Disable employee',
21                              },
22                  'edit_callback' => \&edit_callback,
23                  'field_callback'=> \&field_callback,
24                  'viewall_dir' => 'browse',
25                  'html_bottom' =>
26                    sub {
27                      my $access_user = shift;
28
29                      '<BR>Employee Groups<BR>'.
30                      ntable("#cccccc",2).
31                      '<TR><TD>'.
32                      include( '/elements/checkboxes-table.html',
33                                 'source_obj'   => $access_user,
34                                 'link_table'   => 'access_usergroup',
35                                 'target_table' => 'access_group',
36                                 'name_col'     => 'groupname',
37                                 'target_link'  => $p.'edit/access_group.html?',
38                                 #'disable-able' => 1,
39                             ).
40                      '</TR></TD></TABLE>'
41                      ;
42                    },
43                  'onsubmit'  => 'check_user_custnum_search',
44                  'html_foot' => $check_user_custnum_search,
45            )
46 %>
47 <%init>
48
49 die "access denied"
50   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
51
52 my @pw_fields =
53   FS::Auth->auth_class->can('change_password')
54     ? ( { field=>'_password',  type=>'password' },
55         { field=>'_password2', type=>'password' },
56       )
57     : ();
58
59 my $check_user_custnum_search = <<END;
60   <SCRIPT TYPE="text/javascript">
61     function check_user_custnum_search(what) {
62       while ( user_custnum_search_active ) {
63         // javascript needs ambien
64       }
65       return true;
66     }
67   </SCRIPT>
68 END
69
70 sub edit_callback {
71   my ($c, $o, $f, $opt) = @_;
72   $o->set('_password', '');
73 }
74
75 sub field_callback {
76   my ($c, $o, $f) = @_;
77   if($f->{'type'} eq 'password' and $o->is_system_user) {
78     $f->{'type'} = 'hidden';
79     $f->{'disabled'} = 1;
80   }
81 }
82
83 </%init>