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