for mod_perl: no more top-level my() variables; use vars instead
[freeside.git] / htdocs / misc / cancel_pkg.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: cancel_pkg.cgi,v 1.4 1999-01-19 05:14:04 ivan Exp $
4 #
5 # Usage: cancel_pkg.cgi pkgnum
6 #        http://server.name/path/cancel_pkg.cgi pkgnum
7 #
8 # Note: Should be run setuid freeside as user nobody
9 #
10 # IT DOESN'T RUN THE APPROPRIATE PROGRAMS YET!!!!
11 #
12 # probably should generalize this to do cancels, suspensions, unsuspensions, etc.
13 #
14 # ivan@voicenet.com 97-jan-2
15 #
16 # still kludgy, but now runs /dbin/cancel $pkgnum
17 # ivan@voicenet.com 97-feb-27
18 #
19 # doesn't run if pkgnum doesn't match regex
20 # ivan@voicenet.com 97-mar-6
21 #
22 # now redirects to enter comments
23 # ivan@voicenet.com 97-may-8
24 #
25 # rewrote for new API
26 # ivan@voicenet.com 97-jul-21
27 #
28 # Changes to allow page to work at a relative position in server
29 #       bmccane@maxbaud.net     98-apr-3
30 #
31 # $Log: cancel_pkg.cgi,v $
32 # Revision 1.4  1999-01-19 05:14:04  ivan
33 # for mod_perl: no more top-level my() variables; use vars instead
34 # also the last s/create/new/;
35 #
36 # Revision 1.3  1998/12/23 03:02:54  ivan
37 # $cgi->keywords instead of $cgi->query_string
38 #
39 # Revision 1.2  1998/12/17 09:12:43  ivan
40 # s/CGI::(Request|Base)/CGI.pm/;
41 #
42
43 use strict;
44 use vars qw ( $cgi $query $pkgnum $cust_pkg $error );
45 use CGI;
46 use CGI::Carp qw(fatalsToBrowser);
47 use FS::UID qw(cgisuidsetup);
48 use FS::CGI qw(eidiot popurl);
49 use FS::Record qw(qsearchs);
50 use FS::cust_pkg;
51
52 $cgi = new CGI;
53 &cgisuidsetup($cgi);
54  
55 #untaint pkgnum
56 ($query) = $cgi->keywords;
57 $query =~ /^(\d+)$/ || die "Illegal pkgnum";
58 $pkgnum = $1;
59
60 $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
61
62 $error = $cust_pkg->cancel;
63 eidiot($error) if $error;
64
65 print $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum'));
66