cf1f231536b03d19bddfa3496be362a3de943900
[freeside.git] / htdocs / misc / expire_pkg.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: expire_pkg.cgi,v 1.4 1999-02-28 00:03:50 ivan Exp $
4 #
5 # Usage: post form to:
6 #        http://server.name/path/expire_pkg.cgi
7 #
8 # based on susp_pkg
9 # ivan@voicenet.com 97-jul-29
10 #
11 # ivan@sisd.com 98-mar-17 FS::Search->FS::Record
12 #
13 # Changes to allow page to work at a relative position in server
14 #       bmccane@maxbaud.net     98-apr-3
15
16 # $Log: expire_pkg.cgi,v $
17 # Revision 1.4  1999-02-28 00:03:50  ivan
18 # removed misleading comments
19 #
20 # Revision 1.3  1999/01/19 05:14:05  ivan
21 # for mod_perl: no more top-level my() variables; use vars instead
22 # also the last s/create/new/;
23 #
24 # Revision 1.2  1998/12/17 09:12:44  ivan
25 # s/CGI::(Request|Base)/CGI.pm/;
26 #
27
28 use strict;
29 use vars qw ( $cgi $date $pkgnum $cust_pkg %hash $new $error );
30 use Date::Parse;
31 use CGI;
32 use CGI::Carp qw(fatalsToBrowser);
33 use FS::UID qw(cgisuidsetup);
34 use FS::CGI qw(popurl eidiot);
35 use FS::Record qw(qsearchs);
36 use FS::cust_pkg;
37
38 $cgi = new CGI;
39 &cgisuidsetup($cgi);
40
41 #untaint date & pkgnum
42
43 if ( $cgi->param('date') ) {
44   str2time($cgi->param('date')) =~ /^(\d+)$/ or die "Illegal date";
45   $date=$1;
46 } else {
47   $date='';
48 }
49
50 $cgi->param('pkgnum') =~ /^(\d+)$/ or die "Illegal pkgnum";
51 $pkgnum = $1;
52
53 $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
54 %hash = $cust_pkg->hash;
55 $hash{expire}=$date;
56 $new = new FS::cust_pkg ( \%hash );
57 $error = $new->replace($cust_pkg);
58 &eidiot($error) if $error;
59
60 print $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum'));
61