diff options
Diffstat (limited to 'httemplate/misc/process')
-rwxr-xr-x | httemplate/misc/process/link.cgi | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index 8b71b893d..32a5360d9 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -12,8 +12,12 @@ unless ( $svcnum ) { my $svcdb = $part_svc->getfield('svcdb'); $cgi->param('link_field') =~ /^(\w+)$/; my $link_field = $1; + my %search = ( $link_field => $cgi->param('link_value') ); + if ( $cgi->param('link_field2') =~ /^(\w+)$/ ) { + $search{$1} = $cgi->param('link_value2'); + } my $svc_x = ( grep { $_->cust_svc->svcpart == $svcpart } - qsearch( $svcdb, { $link_field => $cgi->param('link_value') }) + qsearch( $svcdb, \%search ) )[0]; eidiot("$link_field not found!") unless $svc_x; $svcnum = $svc_x->svcnum; @@ -21,19 +25,24 @@ unless ( $svcnum ) { my $old = qsearchs('cust_svc',{'svcnum'=>$svcnum}); die "svcnum not found!" unless $old; -#die "svcnum $svcnum already linked to package ". $old->pkgnum if $old->pkgnum; -my $new = new FS::cust_svc ({ - 'svcnum' => $svcnum, - 'pkgnum' => $pkgnum, - 'svcpart' => $svcpart, -}); +my $conf = new FS::Conf; +my($error, $new); +if ( $old->pkgnum && ! $conf->exists('legacy_link-steal') ) { + $error = "svcnum $svcnum already linked to package ". $old->pkgnum; +} else { + $new = new FS::cust_svc ({ + 'svcnum' => $svcnum, + 'pkgnum' => $pkgnum, + 'svcpart' => $svcpart, + }); -my $error = $new->replace($old); + $error = $new->replace($old); +} unless ($error) { #no errors, so let's view this customer. my $custnum = $new->cust_pkg->custnum; - print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum" + print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum". "#cust_pkg$pkgnum" ); } else { %> |