blob: 5bad5e73707b6718cc2985915eb263b71fb7197c (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
<%
#
# $Id: cancel-unaudited.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $
#
# Usage: cancel-unaudited.cgi svcnum
# http://server.name/path/cancel-unaudited.cgi pkgnum
#
# ivan@voicenet.com 97-apr-23
#
# rewrote for new API
# ivan@voicenet.com 97-jul-21
#
# Search->Record, cgisuidsetup($cgi) ivan@sids.com 98-mar-19
#
# Changes to allow page to work at a relative position in server
# bmccane@maxbaud.net 98-apr-3
#
# $Log: cancel-unaudited.cgi,v $
# Revision 1.1 2001-07-30 07:36:04 ivan
# templates!!!
#
# Revision 1.8 2001/04/09 23:05:16 ivan
# Transactions Part I!!!
#
# Revision 1.7 2000/06/15 12:30:37 ivan
# bugfix from Jeff Finucane, thanks!
#
# Revision 1.6 1999/02/28 00:03:48 ivan
# removed misleading comments
#
# Revision 1.5 1999/02/07 09:59:34 ivan
# more mod_perl fixes, and bugfixes Peter Wemm sent via email
#
# Revision 1.4 1999/01/19 05:14:03 ivan
# for mod_perl: no more top-level my() variables; use vars instead
# also the last s/create/new/;
#
# Revision 1.3 1998/12/23 03:02:05 ivan
# $cgi->keywords instead of $cgi->query_string
#
# Revision 1.2 1998/12/17 09:12:42 ivan
# s/CGI::(Request|Base)/CGI.pm/;
#
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
<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;
$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(@_);
}
%>
|