7afa94267d79ff3f74ca2bb867d2823948fcf60c
[freeside.git] / httemplate / misc / expire_pkg.cgi
1 <%
2 #
3 # $Id: expire_pkg.cgi,v 1.1 2001-07-30 07:36:04 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.1  2001-07-30 07:36:04  ivan
18 # templates!!!
19 #
20 # Revision 1.4  1999/02/28 00:03:50  ivan
21 # removed misleading comments
22 #
23 # Revision 1.3  1999/01/19 05:14:05  ivan
24 # for mod_perl: no more top-level my() variables; use vars instead
25 # also the last s/create/new/;
26 #
27 # Revision 1.2  1998/12/17 09:12:44  ivan
28 # s/CGI::(Request|Base)/CGI.pm/;
29 #
30
31 use strict;
32 use vars qw ( $cgi $date $pkgnum $cust_pkg %hash $new $error );
33 use Date::Parse;
34 use CGI;
35 use CGI::Carp qw(fatalsToBrowser);
36 use FS::UID qw(cgisuidsetup);
37 use FS::CGI qw(popurl eidiot);
38 use FS::Record qw(qsearchs);
39 use FS::cust_pkg;
40
41 $cgi = new CGI;
42 &cgisuidsetup($cgi);
43
44 #untaint date & pkgnum
45
46 if ( $cgi->param('date') ) {
47   str2time($cgi->param('date')) =~ /^(\d+)$/ or die "Illegal date";
48   $date=$1;
49 } else {
50   $date='';
51 }
52
53 $cgi->param('pkgnum') =~ /^(\d+)$/ or die "Illegal pkgnum";
54 $pkgnum = $1;
55
56 $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
57 %hash = $cust_pkg->hash;
58 $hash{expire}=$date;
59 $new = new FS::cust_pkg ( \%hash );
60 $error = $new->replace($cust_pkg);
61 &eidiot($error) if $error;
62
63 print $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum'));
64
65 %>