2 % $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(2). "svc_acct.cgi?". $cgi->query_string ) %>
5 <% $cgi->redirect(popurl(3). "view/svc_acct.cgi?" . $svcnum ) %>
10 unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
12 $cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
17 $old = qsearchs('svc_acct', { 'svcnum' => $svcnum } )
18 or die "fatal: can't find account (svcnum $svcnum)!";
24 $cgi->param('popnum', (split(/:/, $cgi->param('popnum') ))[0] );
27 $cgi->param('usergroup', [ $cgi->param('radius_usergroup') ] );
30 foreach (map { $_,$_."_threshold" } qw( upbytes downbytes totalbytes )) {
31 $cgi->param($_, FS::UI::bytecount::parse_bytecount($cgi->param($_)) );
34 #for slipip, convert '(automatic)' to null
35 my $ip_addr = $cgi->param('slipip');
36 $ip_addr =~ s/[^\d\.]//g;
37 $cgi->param('slipip', $ip_addr);
39 #unmunge cgp_accessmodes (falze laziness-ish w/part_svc.pm::process &svc_domain)
40 unless ( $cgi->param('cgp_accessmodes') ) {
41 $cgi->param('cgp_accessmodes',
43 sort map { /^cgp_accessmodes_([\w\/]+)$/ or die "no way"; $1; }
45 grep /^cgp_accessmodes_([\w\/]+)$/,
51 my %hash = $svcnum ? $old->hash : ();
52 for ( fields('svc_acct'), qw( pkgnum svcpart usergroup ) ) {
53 $hash{$_} = scalar($cgi->param($_));
56 for ( grep $old->$_, qw( cf_privatekey ) ) {
60 my $new = new FS::svc_acct ( \%hash );
64 my $part_svc = $svcnum ?
67 { 'svcpart' => $cgi->param('svcpart') }
71 if ( $cgi->param('captcha_response') ) {
72 my ($export) = $part_svc->part_export('acct_google');
74 ! $export->captcha_auth($cgi->param('captcha_response')) ) {
75 $error = 'Re-enter the security word.';
79 # check whether the password is set as "fixed" in the service def. if so,
80 # ignore the password that was submitted and use the fixed value.
82 my $psc = $part_svc->part_svc_column('_password');
83 if ( $psc->columnflag eq 'F' ) {
85 $new->set('_password', $psc->columnvalue);
89 $new->_password($old->_password) if $old;
90 if ( $cgi->param('clear_password') eq '*HIDDEN*'
91 || $cgi->param('clear_password') =~ /^\(.* encrypted\)$/ ) {
92 die "fatal: no previous account to recall hidden password from!"
95 my $newpass = $cgi->param('clear_password');
96 if ( !$old or ! $old->check_password($newpass) ) {
97 # then the password is being changed
98 $error ||= $new->is_password_allowed($newpass)
99 || $new->set_password($newpass);
107 my $export_info = FS::part_export::export_info();
110 map FS::svc_export_machine->new({
112 'exportnum' => $_->exportnum,
113 'machinenum' => scalar($cgi->param('exportnum'.$_->exportnum.'machinenum')),
115 grep { $_->machine eq '_SVC_MACHINE' }
116 $part_svc->part_export;
118 if ( $part_svc->has_router ) {
119 my $router = FS::router->new({
120 map { $_ => $cgi->param("router_$_") }
121 qw( routernum routername blocknum )
123 if (length($router->routername) == 0) {
125 $router->set('routername', $new->label);
127 if (length($router->blocknum) == 0) {
129 $router->set('blocknum', 0);
131 push @child_objects, $router;
136 foreach ( grep { $old->$_ != $new->$_ }
137 qw( seconds upbytes downbytes totalbytes )
140 my %hash = map { $_ => $new->$_ }
142 qw( seconds upbytes downbytes totalbytes );
144 $error ||= "invalid $_" foreach grep { $hash{$_} !~ /^-?\d+$/ } keys %hash;
145 $error ||= $new->set_usage(\%hash); #unoverlimit and trigger radius changes
146 last; #once is enough
148 $error ||= $new->replace($old, 'child_objects'=>\@child_objects);
150 $error ||= $new->insert('child_objects'=>\@child_objects);
151 $svcnum = $new->svcnum;