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',
14 'uncancel' => 'un-cancelled',
17 #i'm sure this is false laziness with somewhere, at least w/misc/cancel_pkg.html
18 my %right = ( 'cancel' => 'Cancel customer package immediately',
19 'expire' => 'Cancel customer package later',
20 'suspend' => 'Suspend customer package',
21 'adjourn' => 'Suspend customer package later',
22 'resume' => 'Unsuspend customer package', #later?
23 'uncancel' => 'Un-cancel customer package',
30 my $method = $cgi->param('method');
31 $method =~ /^(cancel|expire|suspend|adjourn|resume|uncancel)$/
32 or die "Illegal method";
34 my $past_method = $past{$method};
37 unless $FS::CurrentUser::CurrentUser->access_right($right{$method});
40 my $pkgnum = $cgi->param('pkgnum');
41 $pkgnum =~ /^(\d+)$/ or die "Illegal pkgnum";
45 if ($method eq 'expire' || $method eq 'adjourn' || $method eq 'resume') {
47 $date = $cgi->param('date'); #huh?
48 parse_datetime($cgi->param('date')) =~ /^(\d+)$/ or die "Illegal date";
50 $method = 'cancel' if $method eq 'expire';
51 $method = 'suspend' if $method eq 'adjourn';
52 $method = 'unsuspend' if $method eq 'resume';
57 if ( $method eq 'suspend' ) { #or 'adjourn'
58 $resume_date = parse_datetime($cgi->param('resume_date'))
59 if $cgi->param('resume_date');
61 $options = { map { $_ => scalar($cgi->param($_)) }
62 qw( suspend_bill no_suspend_bill )
66 my $cust_pkg = qsearchs( 'cust_pkg', {'pkgnum'=>$pkgnum} );
68 #untaint reasonnum, and set up new reason if appropriate
69 my ($reasonnum, $error);
70 if ($method ne 'resume' and $method ne 'uncancel') {
71 ($reasonnum, $error) = $m->comp('elements/reason');
73 $error ||= 'Reason required';
79 $cgi->param('last_bill') ? parse_datetime($cgi->param('last_bill')) : '';
81 $cgi->param('bill') ? parse_datetime($cgi->param('bill')) : '';
83 my $svc_fatal = ( $cgi->param('svc_not_fatal') ne 'Y' );
85 $error ||= $cust_pkg->$method( 'reason' => $reasonnum,
87 'resume_date' => $resume_date,
88 'last_bill' => $last_bill,
90 'svc_fatal' => $svc_fatal,
91 'options' => $options,
95 $cgi->param('error', $error);
96 print $cgi->redirect(popurl(2). "cancel_pkg.html?". $cgi->query_string );