From 8ed2714fc50607081d7ac4edf0b17e23902dabba Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 5 Apr 2004 14:06:04 +0000 Subject: [PATCH] add a domain pulldown to svc_acct linking, closes: Bug#277 / prevent "stealing" services with link unless you set legacy_link-steal config option, closes: Bug#321 --- FS/FS/Conf.pm | 7 +++++ httemplate/misc/link.cgi | 67 ++++++++++++++++++++++++++++------------ httemplate/misc/process/link.cgi | 27 ++++++++++------ 3 files changed, 73 insertions(+), 28 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 03b376656..d8191c278 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -934,6 +934,13 @@ httemplate/docs/config.html }, { + 'key' => 'legacy_link-steal', + 'section' => 'UI', + 'description' => 'Allow "stealing" an already-audited service from one customer (or package) to another using the link function.', + 'type' => 'checkbox', + }, + + { 'key' => 'queue_dangerous_controls', 'section' => 'UI', 'description' => 'Enable queue modification controls on account pages and for new jobs. Unless you are a developer working on new export code, you should probably leave this off to avoid causing provisioning problems.', diff --git a/httemplate/misc/link.cgi b/httemplate/misc/link.cgi index 79adce88c..18cd378d3 100755 --- a/httemplate/misc/link.cgi +++ b/httemplate/misc/link.cgi @@ -4,8 +4,16 @@ my %link_field = ( 'svc_acct' => 'username', 'svc_domain' => 'domain', - 'svc_charge' => '', - 'svc_wo' => '', +); + +my %link_field2 = ( + 'svc_acct' => { label => 'Domain', + field => 'domsvc', + type => 'select', + select_table => 'svc_domain', + select_key => 'svcnum', + select_label => 'domain' + }, ); my($query) = $cgi->keywords; @@ -19,27 +27,48 @@ my $part_svc = qsearchs('part_svc',{'svcpart'=>$svcpart}); my $svc = $part_svc->getfield('svc'); my $svcdb = $part_svc->getfield('svcdb'); my $link_field = $link_field{$svcdb}; +my $link_field2 = $link_field2{$svcdb}; + +%> -print header("Link to existing $svc"), - qq!
!; +<%= header("Link to existing $svc") %> + -if ( $link_field ) { - print < - - $link_field of existing service: -END -} else { - print qq!Service # of existing service: !; -} + + <%= $link_field %> of existing service: +
+ <% if ( $link_field2 ) { %> + + <%= $link_field2->{'label'} %> of existing service: + <% if ( $link_field2->{'type'} eq 'select' ) { %> + <% if ( $link_field2->{'select_table'} ) { %> + + <% } else { %> + Don't know how to process secondary link field for <%= $svcdb %> + (type=>select but no select_table) + <% } %> + <% } else { %> + Don't know how to process secondary link field for <%= $svcdb %> + (unknown type <%= $link_field2->{'type'} %>) + <% } %> +
+ <% } %> +<% } else { %> + Service # of existing service: +<% } %> -print < - -

+ + +
-END - -%> 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 { %> -- 2.11.0