1 <% header("Package $past{$method}") %>
2 <SCRIPT TYPE="text/javascript">
3 window.top.location.reload();
9 my %past = ( 'cancel' => 'cancelled',
10 'expire' => 'expired',
11 'suspend' => 'suspended',
12 'adjourn' => 'adjourned',
15 #i'm sure this is false laziness with somewhere, at least w/misc/cancel_pkg.html
16 my %right = ( 'cancel' => 'Cancel customer package immediately',
17 'expire' => 'Cancel customer package later',
18 'suspend' => 'Suspend customer package',
19 'adjourn' => 'Suspend customer package later',
26 my $method = $cgi->param('method');
27 $method =~ /^(cancel|expire|suspend|adjourn)$/ or die "Illegal method";
31 unless $FS::CurrentUser::CurrentUser->access_right($right{$method});
34 my $pkgnum = $cgi->param('pkgnum');
35 $pkgnum =~ /^(\d+)$/ or die "Illegal pkgnum";
39 my $reasonnum = $cgi->param('reasonnum');
40 $reasonnum =~ /^(-?\d+)$/ or die "Illegal reasonnum";
44 if ($method eq 'expire' || $method eq 'adjourn'){
46 $date = $cgi->param('date');
47 str2time($cgi->param('date')) =~ /^(\d+)$/ or die "Illegal date";
51 my $cust_pkg = qsearchs( 'cust_pkg', {'pkgnum'=>$pkgnum} );
53 #my $otaker = $FS::CurrentUser::CurrentUser->name;
54 #$otaker = $FS::CurrentUser::CurrentUser->username
55 # if ($otaker eq "User, Legacy");
57 if ($reasonnum == -1) {
59 'typenum' => scalar( $cgi->param('newreasonnumT') ),
60 'reason' => scalar( $cgi->param('newreasonnum' ) ),
65 if ($method eq 'expire' || $method eq 'adjourn'){
66 my %hash = $cust_pkg->hash;
67 $hash{$method} = $date;
68 my $new = new FS::cust_pkg \%hash;
69 $error = $new->replace($cust_pkg, 'reason' => $reasonnum);
71 $error = $cust_pkg->$method( 'reason' => $reasonnum );
75 $cgi->param('error', $error);
76 print $cgi->redirect(popurl(2). "cancel_pkg.html?". $cgi->query_string );