X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fcancel-unaudited.cgi;h=6f070a4446c9e884563f9c97717ed480241a3fd8;hb=5dcbdb568e7aadabf49b8821a7d50f508a675a7d;hp=9b90967d9d938ae4a6e5f4443a88c39bd47c3ce6;hpb=3d671921441ba8422650b54435a1959ad1d4c71d;p=freeside.git diff --git a/httemplate/misc/cancel-unaudited.cgi b/httemplate/misc/cancel-unaudited.cgi index 9b90967d9..6f070a444 100755 --- a/httemplate/misc/cancel-unaudited.cgi +++ b/httemplate/misc/cancel-unaudited.cgi @@ -1,56 +1,36 @@ -<% -# +% +% +%my $dbh = dbh; +% +%#untaint svcnum +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/; +%my $svcnum = $1; +% +%#my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum}); +%#die "Unknown svcnum!" unless $svc_acct; +% +%my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); +%die "Unknown svcnum!" unless $cust_svc; +%my $cust_pkg = $cust_svc->cust_pkg; +%if ( $cust_pkg ) { +% &eidiot( 'This account has already been audited. Cancel the '. +% qq!'. +% 'package instead.'); +%} +% +%my $error = $cust_svc->cancel; +% +%if ( $error ) { +% + + +% +% &eidiot($error); +%} else { +% print $cgi->redirect(popurl(2)); +%} +% +% -use strict; -use vars qw( $cgi $query $svcnum $svc_acct $cust_svc $error $dbh ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); -use FS::CGI qw(popurl eidiot); -use FS::Record qw(qsearchs); -use FS::cust_svc; -use FS::svc_acct; - -$cgi = new CGI; -$dbh = &cgisuidsetup($cgi); - -#untaint svcnum -($query) = $cgi->keywords; -$query =~ /^(\d+)$/; -$svcnum = $1; - -$svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum}); -die "Unknown svcnum!" unless $svc_acct; - -$cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); -&eidiot(qq!This account has already been audited. Cancel the - package instead.!) - if $cust_svc->pkgnum ne '' && $cust_svc->pkgnum ne '0'; - -local $SIG{HUP} = 'IGNORE'; -local $SIG{INT} = 'IGNORE'; -local $SIG{QUIT} = 'IGNORE'; -local $SIG{TERM} = 'IGNORE'; -local $SIG{TSTP} = 'IGNORE'; - -local $FS::UID::AutoCommit = 0; - -$error = $svc_acct->cancel; -&myeidiot($error) if $error; -$error = $svc_acct->delete; -&myeidiot($error) if $error; - -$error = $cust_svc->delete; -&myeidiot($error) if $error; - -$dbh->commit or die $dbh->errstr; - -print $cgi->redirect(popurl(2)); - -sub myeidiot { - $dbh->rollback; - &eidiot(@_); -} - -%>