summaryrefslogtreecommitdiff
path: root/httemplate/misc/cancel-unaudited.cgi
blob: a73b2ce974dc27f1fbc4b407411be837eeca08ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<%

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});
&eidiot(qq!This account has already been audited.  Cancel the 
    <A HREF="!. popurl(2). qq!view/cust_pkg.cgi?! . $cust_svc->getfield('pkgnum') .
    qq!pkgnum"> package</A> 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;

my $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(@_);
}

%>