summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/part_svc.cgi
blob: 31ab13438362f2472afc2ee789bbc045d66cb4ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<%

my $svcpart = $cgi->param('svcpart');

my $old = qsearchs('part_svc',{'svcpart'=>$svcpart}) if $svcpart;

$cgi->param( 'svc_acct__usergroup',
             join(',', $cgi->param('svc_acct__usergroup') ) );

my $new = new FS::part_svc ( {
  map {
    $_, scalar($cgi->param($_));
#  } qw(svcpart svc svcdb)
  } ( fields('part_svc'),
      map { my $svcdb = $_;
            my @fields = fields($svcdb);
            push @fields, 'usergroup' if $svcdb eq 'svc_acct'; #kludge
            map { ( $svcdb.'__'.$_, $svcdb.'__'.$_.'_flag' )  } @fields;
          } grep defined( $FS::Record::dbdef->table($_) ),
                 qw( svc_acct svc_domain svc_acct_sm svc_forward svc_www )
    )
} );

my $error;
if ( $svcpart ) {
  $error = $new->replace($old, '1.3-COMPAT', [ 'usergroup' ] );
} else {
  $error = $new->insert( [ 'usergroup' ] );
  $svcpart=$new->getfield('svcpart');
}

if ( $error ) {
  $cgi->param('error', $error);
  print $cgi->redirect(popurl(2). "part_svc.cgi?". $cgi->query_string );
} else {
  print $cgi->redirect(popurl(3)."browse/part_svc.cgi");
}

%>