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