diff options
Diffstat (limited to 'htdocs/misc/process')
-rwxr-xr-x | htdocs/misc/process/delete-customer.cgi | 46 | ||||
-rwxr-xr-x | htdocs/misc/process/link.cgi | 71 |
2 files changed, 83 insertions, 34 deletions
diff --git a/htdocs/misc/process/delete-customer.cgi b/htdocs/misc/process/delete-customer.cgi new file mode 100755 index 000000000..0a939c559 --- /dev/null +++ b/htdocs/misc/process/delete-customer.cgi @@ -0,0 +1,46 @@ +#!/usr/bin/perl -Tw +# +# $Id: delete-customer.cgi,v 1.1 1999-04-15 16:44:36 ivan Exp $ +# +# $Log: delete-customer.cgi,v $ +# Revision 1.1 1999-04-15 16:44:36 ivan +# delete customers +# + +use strict; +use vars qw ( $cgi $conf $custnum $new_custnum $cust_main $error ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearchs); +use FS::CGI qw(popurl); +use FS::cust_main; + +$cgi = new CGI; +cgisuidsetup($cgi); + +$conf = new FS::Conf; +die "Customer deletions not enabled" unless $conf->exists('deletecustomers'); + +$cgi->param('custnum') =~ /^(\d+)$/; +$custnum = $1; +if ( $cgi->param('new_custnum') ) { + $cgi->param('new_custnum') =~ /^(\d+)$/ + or die "Illegal new customer number: ". $cgi->param('new_custnum'); + $new_custnum = $1; +} else { + $new_custnum = ''; +} +$cust_main = qsearchs( 'cust_main', { 'custnum' => $custnum } ) + or die "Customer not found: $custnum"; + +$error = $cust_main->delete($new_custnum); + +if ( $error ) { + $cgi->param('error', $error); + print $cgi->redirect(popurl(2). "delete-customer.cgi?". $cgi->query_string ); +} elsif ( $new_custnum ) { + print $cgi->redirect(popurl(3). "view/cust_main.cgi?$new_custnum"); +} else { + print $cgi->redirect(popurl(3)); +} diff --git a/htdocs/misc/process/link.cgi b/htdocs/misc/process/link.cgi index 23fb05386..7d6bd506f 100755 --- a/htdocs/misc/process/link.cgi +++ b/htdocs/misc/process/link.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# process/link.cgi: link to existing customer (process form) +# $Id: link.cgi,v 1.6 2000-07-17 17:59:33 ivan Exp $ # # ivan@voicenet.com 97-feb-5 # @@ -10,64 +10,67 @@ # 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.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 CGI::Request; +use vars qw ( $cgi $old $new $error $pkgnum $svcpart $svcnum ); +use CGI; use CGI::Carp qw(fatalsToBrowser); -use FS::CGI qw(idiot); +use FS::CGI qw(popurl idiot eidiot); use FS::UID qw(cgisuidsetup); use FS::cust_svc; use FS::Record qw(qsearchs); -my($req)=new CGI::Request; # create form object -cgisuidsetup($req->cgi); - -#$req->import_names('R'); #import CGI variables into package 'R'; +$cgi = new CGI; +cgisuidsetup($cgi); -$req->param('pkgnum') =~ /^(\d+)$/; my($pkgnum)=$1; -$req->param('svcpart') =~ /^(\d+)$/; my($svcpart)=$1; +$cgi->param('pkgnum') =~ /^(\d+)$/; +$pkgnum = $1; +$cgi->param('svcpart') =~ /^(\d+)$/; +$svcpart = $1; +$cgi->param('svcnum') =~ /^(\d*)$/; +$svcnum = $1; -$req->param('svcnum') =~ /^(\d*)$/; my($svcnum)=$1; unless ( $svcnum ) { my($part_svc) = qsearchs('part_svc',{'svcpart'=>$svcpart}); my($svcdb) = $part_svc->getfield('svcdb'); - $req->param('link_field') =~ /^(\w+)$/; my($link_field)=$1; - my($svc_acct)=qsearchs($svcdb,{$link_field => $req->param('link_value') }); - idiot("$link_field not found!") unless $svc_acct; + $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($old)=qsearchs('cust_svc',{'svcnum'=>$svcnum}); +$old = qsearchs('cust_svc',{'svcnum'=>$svcnum}); die "svcnum not found!" unless $old; -my($new)=create FS::cust_svc ({ +$new = new FS::cust_svc ({ 'svcnum' => $svcnum, 'pkgnum' => $pkgnum, 'svcpart' => $svcpart, }); -my($error); $error = $new->replace($old); unless ($error) { #no errors, so let's view this customer. - $req->cgi->redirect("../../view/cust_pkg.cgi?$pkgnum"); + print $cgi->redirect(popurl(3). "view/cust_pkg.cgi?$pkgnum"); } else { - CGI::Base::SendHeaders(); # one guess - print <<END; -<HTML> - <HEAD> - <TITLE>Error</TITLE> - </HEAD> - <BODY> - <CENTER> - <H4>Error</H4> - </CENTER> - Your update did not occur because of the following error: - <P><B>$error</B> - <P>Hit the <I>Back</I> button in your web browser, correct this mistake, and submit the form again. - </BODY> -</HTML> -END - + idiot($error); } |