From 51984ac3d3da3006809c6866fdecd4ad83610731 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 30 Jul 2001 07:36:04 +0000 Subject: templates!!! --- httemplate/misc/process/link.cgi | 80 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 httemplate/misc/process/link.cgi (limited to 'httemplate/misc/process/link.cgi') diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi new file mode 100755 index 000000000..94afa289a --- /dev/null +++ b/httemplate/misc/process/link.cgi @@ -0,0 +1,80 @@ +<% +# +# $Id: link.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ +# +# ivan@voicenet.com 97-feb-5 +# +# rewrite ivan@sisd.com 98-mar-18 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# can also link on some other fields now (about time) ivan@sisd.com 98-jun-24 +# +# $Log: link.cgi,v $ +# Revision 1.1 2001-07-30 07:36:04 ivan +# templates!!! +# +# Revision 1.6 2000/07/17 17:59:33 ivan +# oops +# +# Revision 1.5 1999/04/15 14:09:17 ivan +# get rid of top-level my() variables +# +# Revision 1.4 1999/02/07 09:59:35 ivan +# more mod_perl fixes, and bugfixes Peter Wemm sent via email +# +# Revision 1.3 1999/01/19 05:14:10 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.2 1998/12/17 09:15:00 ivan +# s/CGI::Request/CGI.pm/; +# + +use strict; +use vars qw ( $cgi $old $new $error $pkgnum $svcpart $svcnum ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::CGI qw(popurl idiot eidiot); +use FS::UID qw(cgisuidsetup); +use FS::cust_svc; +use FS::Record qw(qsearchs); + +$cgi = new CGI; +cgisuidsetup($cgi); + +$cgi->param('pkgnum') =~ /^(\d+)$/; +$pkgnum = $1; +$cgi->param('svcpart') =~ /^(\d+)$/; +$svcpart = $1; +$cgi->param('svcnum') =~ /^(\d*)$/; +$svcnum = $1; + +unless ( $svcnum ) { + my($part_svc) = qsearchs('part_svc',{'svcpart'=>$svcpart}); + my($svcdb) = $part_svc->getfield('svcdb'); + $cgi->param('link_field') =~ /^(\w+)$/; my($link_field)=$1; + my($svc_acct)=qsearchs($svcdb,{$link_field => $cgi->param('link_value') }); + eidiot("$link_field not found!") unless $svc_acct; + $svcnum=$svc_acct->svcnum; +} + +$old = qsearchs('cust_svc',{'svcnum'=>$svcnum}); +die "svcnum not found!" unless $old; +$new = new FS::cust_svc ({ + 'svcnum' => $svcnum, + 'pkgnum' => $pkgnum, + 'svcpart' => $svcpart, +}); + +$error = $new->replace($old); + +unless ($error) { + #no errors, so let's view this customer. + print $cgi->redirect(popurl(3). "view/cust_pkg.cgi?$pkgnum"); +} else { + idiot($error); +} + +%> -- cgit v1.2.1 From 3d671921441ba8422650b54435a1959ad1d4c71d Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 21 Aug 2001 02:31:57 +0000 Subject: remove $Log$ messages. whew. --- httemplate/misc/process/link.cgi | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) (limited to 'httemplate/misc/process/link.cgi') diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index 94afa289a..6b34e8a5d 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -1,36 +1,5 @@ <% -# -# $Id: link.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ -# -# ivan@voicenet.com 97-feb-5 -# -# rewrite ivan@sisd.com 98-mar-18 -# -# Changes to allow page to work at a relative position in server -# bmccane@maxbaud.net 98-apr-3 -# -# can also link on some other fields now (about time) ivan@sisd.com 98-jun-24 -# -# $Log: link.cgi,v $ -# Revision 1.1 2001-07-30 07:36:04 ivan -# templates!!! -# -# Revision 1.6 2000/07/17 17:59:33 ivan -# oops -# -# Revision 1.5 1999/04/15 14:09:17 ivan -# get rid of top-level my() variables -# -# Revision 1.4 1999/02/07 09:59:35 ivan -# more mod_perl fixes, and bugfixes Peter Wemm sent via email -# -# Revision 1.3 1999/01/19 05:14:10 ivan -# for mod_perl: no more top-level my() variables; use vars instead -# also the last s/create/new/; -# -# Revision 1.2 1998/12/17 09:15:00 ivan -# s/CGI::Request/CGI.pm/; -# +# use strict; use vars qw ( $cgi $old $new $error $pkgnum $svcpart $svcnum ); -- cgit v1.2.1 From 1fd6d8cf5d7854860ef4fd10ed89828e0c04ec39 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 30 Jan 2002 14:18:09 +0000 Subject: remove use Module; and $cgi = new CGI; &cgisuidsetup(); from all templates. should work better under Mason. --- httemplate/misc/process/link.cgi | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'httemplate/misc/process/link.cgi') diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index 6b34e8a5d..80a5de81f 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -1,24 +1,12 @@ + <% -# - -use strict; -use vars qw ( $cgi $old $new $error $pkgnum $svcpart $svcnum ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::CGI qw(popurl idiot eidiot); -use FS::UID qw(cgisuidsetup); -use FS::cust_svc; -use FS::Record qw(qsearchs); - -$cgi = new CGI; -cgisuidsetup($cgi); $cgi->param('pkgnum') =~ /^(\d+)$/; -$pkgnum = $1; +my $pkgnum = $1; $cgi->param('svcpart') =~ /^(\d+)$/; -$svcpart = $1; +my $svcpart = $1; $cgi->param('svcnum') =~ /^(\d*)$/; -$svcnum = $1; +my $svcnum = $1; unless ( $svcnum ) { my($part_svc) = qsearchs('part_svc',{'svcpart'=>$svcpart}); @@ -29,15 +17,15 @@ unless ( $svcnum ) { $svcnum=$svc_acct->svcnum; } -$old = qsearchs('cust_svc',{'svcnum'=>$svcnum}); +my $old = qsearchs('cust_svc',{'svcnum'=>$svcnum}); die "svcnum not found!" unless $old; -$new = new FS::cust_svc ({ +my $new = new FS::cust_svc ({ 'svcnum' => $svcnum, 'pkgnum' => $pkgnum, 'svcpart' => $svcpart, }); -$error = $new->replace($old); +my $error = $new->replace($old); unless ($error) { #no errors, so let's view this customer. -- cgit v1.2.1 From 4c18a45810f000bb013d23d4738cfca012794c4b Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 9 Feb 2002 17:45:26 +0000 Subject: have FS::cust_svc::check look up & check pkg_svc.quantity like httemplate/view/cust_pkg.cgi (closes: Bug#43) --- httemplate/misc/process/link.cgi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'httemplate/misc/process/link.cgi') diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index 80a5de81f..f8b7812e1 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -1,4 +1,4 @@ - + <% $cgi->param('pkgnum') =~ /^(\d+)$/; @@ -12,13 +12,14 @@ unless ( $svcnum ) { my($part_svc) = qsearchs('part_svc',{'svcpart'=>$svcpart}); my($svcdb) = $part_svc->getfield('svcdb'); $cgi->param('link_field') =~ /^(\w+)$/; my($link_field)=$1; - my($svc_acct)=qsearchs($svcdb,{$link_field => $cgi->param('link_value') }); - eidiot("$link_field not found!") unless $svc_acct; - $svcnum=$svc_acct->svcnum; + my($svc_x)=qsearchs($svcdb,{$link_field => $cgi->param('link_value') }); + eidiot("$link_field not found!") unless $svc_x; + $svcnum=$svc_x->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, -- cgit v1.2.1 From 22a35047ecdffff80110e06cc08fc84f9ddba9b0 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 10 Feb 2002 13:21:31 +0000 Subject: removed from all files to fix any redirects, whew Mason handler.pl overrides CGI::redirect fixed strict; problems in edit/part_pkg.cgi & edit/process/part_pkg.cgi --- httemplate/misc/process/link.cgi | 1 - 1 file changed, 1 deletion(-) (limited to 'httemplate/misc/process/link.cgi') diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index f8b7812e1..af96c0bcd 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -1,4 +1,3 @@ - <% $cgi->param('pkgnum') =~ /^(\d+)$/; -- cgit v1.2.1 From a4c96748eb6eab29a70f3a944c6520283a635c78 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 10 Feb 2002 16:05:22 +0000 Subject: *finally* seems to be working under Mason. sheesh. *finally* seems to be working under Mason. sheesh. *finally* seems to be working under Mason. sheesh. *finally* seems to be working under Mason. sheesh. *finally* seems to be working under Mason. sheesh. *finally* seems to be working under Mason. sheesh. *finally* seems to be working under Mason. sheesh. *finally* seems to be working under Mason. sheesh. --- httemplate/misc/process/link.cgi | 3 +++ 1 file changed, 3 insertions(+) (limited to 'httemplate/misc/process/link.cgi') diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index af96c0bcd..4b220a867 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -31,6 +31,9 @@ unless ($error) { #no errors, so let's view this customer. print $cgi->redirect(popurl(3). "view/cust_pkg.cgi?$pkgnum"); } else { +%> + +<% idiot($error); } -- cgit v1.2.1 From 69a956aecd4bc89c683e60f9ec3fe0c9e11ea0d7 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 26 Nov 2002 11:58:14 +0000 Subject: link by username now only links to same svcpart --- httemplate/misc/process/link.cgi | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'httemplate/misc/process/link.cgi') diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index 4b220a867..5d80adeb9 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -8,12 +8,15 @@ $cgi->param('svcnum') =~ /^(\d*)$/; my $svcnum = $1; unless ( $svcnum ) { - my($part_svc) = qsearchs('part_svc',{'svcpart'=>$svcpart}); - my($svcdb) = $part_svc->getfield('svcdb'); - $cgi->param('link_field') =~ /^(\w+)$/; my($link_field)=$1; - my($svc_x)=qsearchs($svcdb,{$link_field => $cgi->param('link_value') }); + my $part_svc = qsearchs('part_svc',{'svcpart'=>$svcpart}); + my $svcdb = $part_svc->getfield('svcdb'); + $cgi->param('link_field') =~ /^(\w+)$/; + my $link_field = $1; + my $svc_x = ( grep { $_->cust_svc->svcpart == $svcpart } + qsearch( $svcdb, { $link_field => $cgi->param('link_value') }) + )[0]; eidiot("$link_field not found!") unless $svc_x; - $svcnum=$svc_x->svcnum; + $svcnum = $svc_x->svcnum; } my $old = qsearchs('cust_svc',{'svcnum'=>$svcnum}); -- cgit v1.2.1 From e3f327b2af9e6a591bae41d315fda731ec7f5128 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 22 Mar 2004 11:05:58 +0000 Subject: remove everything that links to package view also, closes: Bug#569 --- httemplate/misc/process/link.cgi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'httemplate/misc/process/link.cgi') diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index 5d80adeb9..8b71b893d 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -32,7 +32,9 @@ my $error = $new->replace($old); unless ($error) { #no errors, so let's view this customer. - print $cgi->redirect(popurl(3). "view/cust_pkg.cgi?$pkgnum"); + my $custnum = $new->cust_pkg->custnum; + print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum" + "#cust_pkg$pkgnum" ); } else { %> -- cgit v1.2.1 From 8ed2714fc50607081d7ac4edf0b17e23902dabba Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 5 Apr 2004 14:06:04 +0000 Subject: 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 --- httemplate/misc/process/link.cgi | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'httemplate/misc/process/link.cgi') 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 { %> -- cgit v1.2.1 From 918bbc9ce36a3dc5943f521e26751ea94a5a5539 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 30 Jul 2004 04:54:41 +0000 Subject: svcpart changes now trigger all necessary export actions, manual svcpart changing on svc_acct view, linking changes svcpart if you ask it to, closes: Bug#671, Bug#644 --- httemplate/misc/process/link.cgi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'httemplate/misc/process/link.cgi') diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index 32a5360d9..acdd1ad03 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -16,8 +16,11 @@ unless ( $svcnum ) { if ( $cgi->param('link_field2') =~ /^(\w+)$/ ) { $search{$1} = $cgi->param('link_value2'); } - my $svc_x = ( grep { $_->cust_svc->svcpart == $svcpart } - qsearch( $svcdb, \%search ) + my $svc_x = ( sort { ($b->cust_svc->pkgnum > 0) <=> ($a->cust_svc->pkgnum > 0) + or ($b->cust_svc->svcpart == $svcpart) + <=> ($a->cust_svc->svcpart == $svcpart) + } + qsearch( $svcdb, \%search ) )[0]; eidiot("$link_field not found!") unless $svc_x; $svcnum = $svc_x->svcnum; -- cgit v1.2.1 From 21e9127d3a16335907d1102793b294446e07120b Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 17 Jun 2005 04:42:06 +0000 Subject: add debugging for accounts picked to pick --- httemplate/misc/process/link.cgi | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'httemplate/misc/process/link.cgi') diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index acdd1ad03..7768b3bd4 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -1,5 +1,7 @@ <% +my $DEBUG = 0; + $cgi->param('pkgnum') =~ /^(\d+)$/; my $pkgnum = $1; $cgi->param('svcpart') =~ /^(\d+)$/; @@ -16,14 +18,30 @@ unless ( $svcnum ) { if ( $cgi->param('link_field2') =~ /^(\w+)$/ ) { $search{$1} = $cgi->param('link_value2'); } - my $svc_x = ( sort { ($b->cust_svc->pkgnum > 0) <=> ($a->cust_svc->pkgnum > 0) + + my @svc_x = ( sort { ($b->cust_svc->pkgnum > 0) <=> ($a->cust_svc->pkgnum > 0) or ($b->cust_svc->svcpart == $svcpart) <=> ($a->cust_svc->svcpart == $svcpart) } qsearch( $svcdb, \%search ) - )[0]; + ); + + if ( $DEBUG ) { + warn scalar(@svc_x). " candidate accounts found for linking ". + "(svcpart $svcpart):\n"; + foreach my $svc_x ( @svc_x ) { + warn " ". $svc_x->email. + " (pkgnum ". $_->cust_svc->pkgnum. + ", svcpart ". $_->cust_svc->svcpart. ")\n"; + } + } + + my $svc_x = $svc_x[0]; + eidiot("$link_field not found!") unless $svc_x; + $svcnum = $svc_x->svcnum; + } my $old = qsearchs('cust_svc',{'svcnum'=>$svcnum}); -- cgit v1.2.1 From ed9ae05f8f25eb26fa7279cc8548041af19e1e1b Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 17 Jun 2005 05:04:29 +0000 Subject: fix debugging --- httemplate/misc/process/link.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/misc/process/link.cgi') diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index 7768b3bd4..aaa434a57 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -31,8 +31,8 @@ unless ( $svcnum ) { "(svcpart $svcpart):\n"; foreach my $svc_x ( @svc_x ) { warn " ". $svc_x->email. - " (pkgnum ". $_->cust_svc->pkgnum. - ", svcpart ". $_->cust_svc->svcpart. ")\n"; + " (pkgnum ". $svc_x->cust_svc->pkgnum. + ", svcpart ". $svc_x->cust_svc->svcpart. ")\n"; } } -- cgit v1.2.1 From da25a477f5708005668c6eb3f12efbb2a40eefdd Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 17 Jun 2005 05:07:48 +0000 Subject: add more info to debugging --- httemplate/misc/process/link.cgi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'httemplate/misc/process/link.cgi') diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index aaa434a57..2a3b3bbf9 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -31,8 +31,9 @@ unless ( $svcnum ) { "(svcpart $svcpart):\n"; foreach my $svc_x ( @svc_x ) { warn " ". $svc_x->email. - " (pkgnum ". $svc_x->cust_svc->pkgnum. - ", svcpart ". $svc_x->cust_svc->svcpart. ")\n"; + " (svcnum". $svc_x->svcnum. ",". + " pkgnum ". $svc_x->cust_svc->pkgnum. ",". + " svcpart ". $svc_x->cust_svc->svcpart. ")\n"; } } -- cgit v1.2.1 From 6e8f3245e71ed4484d5d289f2a455c9a08a900ee Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 17 Jun 2005 05:31:50 +0000 Subject: fix preference sort order for linking: sort unaudited services first, secondary sort by svcaprt --- httemplate/misc/process/link.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'httemplate/misc/process/link.cgi') diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index 2a3b3bbf9..c3d79e22c 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -19,7 +19,7 @@ unless ( $svcnum ) { $search{$1} = $cgi->param('link_value2'); } - my @svc_x = ( sort { ($b->cust_svc->pkgnum > 0) <=> ($a->cust_svc->pkgnum > 0) + my @svc_x = ( sort { ($a->cust_svc->pkgnum > 0) <=> ($b->cust_svc->pkgnum > 0) or ($b->cust_svc->svcpart == $svcpart) <=> ($a->cust_svc->svcpart == $svcpart) } @@ -31,7 +31,7 @@ unless ( $svcnum ) { "(svcpart $svcpart):\n"; foreach my $svc_x ( @svc_x ) { warn " ". $svc_x->email. - " (svcnum". $svc_x->svcnum. ",". + " (svcnum ". $svc_x->svcnum. ",". " pkgnum ". $svc_x->cust_svc->pkgnum. ",". " svcpart ". $svc_x->cust_svc->svcpart. ")\n"; } -- cgit v1.2.1