4 %my $method = $cgi->param('method');
5 %$method =~ /^(cancel|expire|suspend)$/ || die "Illegal method";
9 %my $pkgnum = $cgi->param('pkgnum');
10 %$pkgnum =~ /^(\d+)$/ || die "Illegal pkgnum";
14 %my $reasonnum = $cgi->param('reasonnum');
15 %$reasonnum =~ /^(-?\d+)$/ || die "Illegal reasonnum";
19 %if ($method eq 'expire'){
21 % $date = $cgi->param('date');
22 % str2time($cgi->param('date')) =~ /^(\d+)$/ || die "Illegal date";
26 %my $cust_pkg = qsearchs( 'cust_pkg', {'pkgnum'=>$pkgnum} );
29 %my $oldAutoCommit = $FS::UID::AutoCommit;
30 %local $FS::UID::AutoCommit = 0;
33 %my $otaker = $FS::CurrentUser::CurrentUser->name;
34 %$otaker = $FS::CurrentUser::CurrentUser->username
35 % if ($otaker eq "User, Legacy");
38 %if ($reasonnum == -1) {
40 % my $nr = $cgi->param('newreasonnum');
41 % $nr =~ /^([\w\s]+)$/ || die "Illegal new reason";
44 % #untaint new reason type
45 % my $nrtype = $cgi->param('newreasonnumT');
46 % $nrtype =~ /^(\d+)$/ || die "Illegal new reason type";
49 % my $reason = new FS::reason({ 'reason_type' => $nrtype,
52 % $error = $reason->insert;
53 % $reasonnum = $reason->reasonnum
58 % my $cust_pkg_reason = new FS::cust_pkg_reason({ 'pkgnum' => $pkgnum,
59 % 'reasonnum' => $reasonnum,
60 % 'otaker' => $otaker,
63 % $error = $cust_pkg_reason->insert;
67 % if ($method eq 'expire'){
68 % my %hash = $cust_pkg->hash;
69 % $hash{'expire'}=$date;
70 % my $new = new FS::cust_pkg (\%hash);
71 % $error = $new->replace($cust_pkg);
73 % $error = $cust_pkg->$method
78 % $cgi->param('error', $error);
79 % $dbh->rollback if $oldAutoCommit;
80 % print $cgi->redirect(popurl(2). "cancel_pkg.html?". $cgi->query_string );
83 %$dbh->commit or die $dbh->errstr if $oldAutoCommit;
85 % my %past = ( 'cancel' => 'cancelled',
86 % 'expire' => 'expired',
87 % 'suspend' => 'suspended',
89 <% header("Package $past{$method}") %>
90 <SCRIPT TYPE="text/javascript">
91 window.top.location.reload();