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',
19 my $method = $cgi->param('method');
20 $method =~ /^(cancel|expire|suspend|adjourn)$/ || die "Illegal method";
24 my $pkgnum = $cgi->param('pkgnum');
25 $pkgnum =~ /^(\d+)$/ || die "Illegal pkgnum";
29 my $reasonnum = $cgi->param('reasonnum');
30 $reasonnum =~ /^(-?\d+)$/ || die "Illegal reasonnum";
34 if ($method eq 'expire' || $method eq 'adjourn'){
36 $date = $cgi->param('date');
37 str2time($cgi->param('date')) =~ /^(\d+)$/ || die "Illegal date";
41 my $cust_pkg = qsearchs( 'cust_pkg', {'pkgnum'=>$pkgnum} );
43 #my $otaker = $FS::CurrentUser::CurrentUser->name;
44 #$otaker = $FS::CurrentUser::CurrentUser->username
45 # if ($otaker eq "User, Legacy");
47 if ($reasonnum == -1) {
49 'typenum' => scalar( $cgi->param('newreasonnumT') ),
50 'reason' => scalar( $cgi->param('newreasonnum' ) ),
55 if ($method eq 'expire' || $method eq 'adjourn'){
56 my %hash = $cust_pkg->hash;
57 $hash{$method} = $date;
58 my $new = new FS::cust_pkg \%hash;
59 $error = $new->replace($cust_pkg, 'reason' => $reasonnum);
61 $error = $cust_pkg->$method( 'reason' => $reasonnum );
65 $cgi->param('error', $error);
66 print $cgi->redirect(popurl(2). "cancel_pkg.html?". $cgi->query_string );