3 my $method = $cgi->param('method');
4 $method =~ /^(cancel|expire|suspend)$/ || die "Illegal method";
8 my $pkgnum = $cgi->param('pkgnum');
9 $pkgnum =~ /^(\d+)$/ || die "Illegal pkgnum";
13 my $reasonnum = $cgi->param('reasonnum');
14 $reasonnum =~ /^(-?\d+)$/ || die "Illegal reasonnum";
18 if ($method eq 'expire'){
20 $date = $cgi->param('date');
21 str2time($cgi->param('date')) =~ /^(\d+)$/ || die "Illegal date";
25 my $cust_pkg = qsearchs( 'cust_pkg', {'pkgnum'=>$pkgnum} );
27 my $oldAutoCommit = $FS::UID::AutoCommit;
28 local $FS::UID::AutoCommit = 0;
31 my $otaker = $FS::CurrentUser::CurrentUser->name;
32 $otaker = $FS::CurrentUser::CurrentUser->username
33 if ($otaker eq "User, Legacy");
36 if ($reasonnum == -1) {
38 $error = 'Enter a new reason (or select an existing one)'
39 unless $cgi->param('newreasonnum') !~ /^\s*$/;
41 my $reason = new FS::reason({ 'reason_type' => $cgi->param('newreasonnumT'),
42 'reason' => $cgi->param('newreasonnum'),
44 $error ||= $reason->insert;
45 $reasonnum = $reason->reasonnum
50 if ($method eq 'expire'){
51 my %hash = $cust_pkg->hash;
52 $hash{'expire'}=$date;
53 my $new = new FS::cust_pkg (\%hash);
54 $error = $new->replace($cust_pkg, 'reason' => $reasonnum);
56 $error = $cust_pkg->$method( 'reason' => $reasonnum );
61 $cgi->param('error', $error);
62 $dbh->rollback if $oldAutoCommit;
63 print $cgi->redirect(popurl(2). "cancel_pkg.html?". $cgi->query_string );
66 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
68 my %past = ( 'cancel' => 'cancelled',
69 'expire' => 'expired',
70 'suspend' => 'suspended',
73 <% header("Package $past{$method}") %>
74 <SCRIPT TYPE="text/javascript">
75 window.top.location.reload();