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 $new->_password($old->_password) if $old;
80 if ( $cgi->param('clear_password') eq '*HIDDEN*'
81 || $cgi->param('clear_password') =~ /^\(.* encrypted\)$/ ) {
82 die "fatal: no previous account to recall hidden password from!" unless $old;
84 $error ||= $new->set_password($cgi->param('clear_password'));
89 my $export_info = FS::part_export::export_info();
92 map FS::svc_export_machine->new({
94 'exportnum' => $_->exportnum,
95 'machinenum' => scalar($cgi->param('exportnum'.$_->exportnum.'machinenum')),
97 grep { $_->machine eq '_SVC_MACHINE' }
98 $part_svc->part_export;
100 if ( $part_svc->has_router ) {
101 my $router = FS::router->new({
102 map { $_ => $cgi->param("router_$_") }
103 qw( routernum routername blocknum )
105 if (length($router->routername) == 0) {
107 $router->set('routername', $new->label);
109 if (length($router->blocknum) == 0) {
111 $router->set('blocknum', 0);
113 push @child_objects, $router;
118 foreach ( grep { $old->$_ != $new->$_ }
119 qw( seconds upbytes downbytes totalbytes )
122 my %hash = map { $_ => $new->$_ }
124 qw( seconds upbytes downbytes totalbytes );
126 $error ||= "invalid $_" foreach grep { $hash{$_} !~ /^-?\d+$/ } keys %hash;
127 $error ||= $new->set_usage(\%hash); #unoverlimit and trigger radius changes
128 last; #once is enough
130 $error ||= $new->replace($old, 'child_objects'=>\@child_objects);
132 $error ||= $new->insert('child_objects'=>\@child_objects);
133 $svcnum = $new->svcnum;