1 <% header(emt("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',
13 'resume' => 'scheduled to resume',
16 #i'm sure this is false laziness with somewhere, at least w/misc/cancel_pkg.html
17 my %right = ( 'cancel' => 'Cancel customer package immediately',
18 'expire' => 'Cancel customer package later',
19 'suspend' => 'Suspend customer package',
20 'adjourn' => 'Suspend customer package later',
21 'resume' => 'Unsuspend customer package', #later?
28 my $method = $cgi->param('method');
29 $method =~ /^(cancel|expire|suspend|adjourn|resume)$/ or die "Illegal method";
31 my $past_method = $past{$method};
34 unless $FS::CurrentUser::CurrentUser->access_right($right{$method});
37 my $pkgnum = $cgi->param('pkgnum');
38 $pkgnum =~ /^(\d+)$/ or die "Illegal pkgnum";
42 if ($method eq 'expire' || $method eq 'adjourn' || $method eq 'resume'){
44 $date = $cgi->param('date'); #huh?
45 parse_datetime($cgi->param('date')) =~ /^(\d+)$/ or die "Illegal date";
47 $method = 'cancel' if $method eq 'expire';
48 $method = 'suspend' if $method eq 'adjourn';
49 $method = 'unsuspend' if $method eq 'resume';
54 if ( $method eq 'suspend' ) { #or 'adjourn'
55 $resume_date = parse_datetime($cgi->param('resume_date'))
56 if $cgi->param('resume_date');
58 $options = { map scalar($cgi->param($_)),
59 suspend_bill no_suspend_bill
63 my $cust_pkg = qsearchs( 'cust_pkg', {'pkgnum'=>$pkgnum} );
66 my $reasonnum = $cgi->param('reasonnum');
67 if ( $method ne 'unsuspend' ) { #i.e. 'resume'
68 $reasonnum =~ /^(-?\d+)$/ or die "Illegal reasonnum";
71 if ($reasonnum == -1) {
73 'typenum' => scalar( $cgi->param('newreasonnumT') ),
74 'reason' => scalar( $cgi->param('newreasonnum' ) ),
79 my $error = $cust_pkg->$method( 'reason' => $reasonnum,
81 'resume_date' => $resume_date,
82 'options' => $options,
86 $cgi->param('error', $error);
87 print $cgi->redirect(popurl(2). "cancel_pkg.html?". $cgi->query_string );