1 <& /elements/popup-topreload.html, et("Package $past_method") &>
4 my %past = ( 'cancel' => 'cancelled',
6 'suspend' => 'suspended',
7 'adjourn' => 'adjourned',
8 'resume' => 'scheduled to resume',
9 'uncancel' => 'un-cancelled',
12 #i'm sure this is false laziness with somewhere, at least w/misc/cancel_pkg.html
13 my %right = ( 'cancel' => 'Cancel customer package immediately',
14 'expire' => 'Cancel customer package later',
15 'suspend' => 'Suspend customer package',
16 'adjourn' => 'Suspend customer package later',
17 'resume' => 'Unsuspend customer package', #later?
18 'uncancel' => 'Un-cancel customer package',
25 my $method = $cgi->param('method');
26 $method =~ /^(cancel|expire|suspend|adjourn|resume|uncancel)$/
27 or die "Illegal method";
29 my $past_method = $past{$method};
31 my $curuser = $FS::CurrentUser::CurrentUser;
34 unless $curuser->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 qw( suspend_bill no_suspend_bill )
61 if $curuser->access_right('Customize billing during suspension');
64 my $cust_pkg = qsearchs( 'cust_pkg', {'pkgnum'=>$pkgnum} );
66 #untaint reasonnum, and set up new reason if appropriate
67 my ($reasonnum, $error);
68 if ($method ne 'unsuspend' and $method ne 'uncancel') {
69 ($reasonnum, $error) = $m->comp('elements/reason');
71 $error ||= 'Reason required';
77 $cgi->param('last_bill') ? parse_datetime($cgi->param('last_bill')) : '';
79 $cgi->param('bill') ? parse_datetime($cgi->param('bill')) : '';
81 my $svc_fatal = ( $cgi->param('svc_not_fatal') ne 'Y' );
83 my $only_svcnum = ($method eq 'uncancel') ? [ $cgi->param('only_svcnum') ] : undef;
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,
92 'only_svcnum' => $only_svcnum,
96 $cgi->param('error', $error);
97 print $cgi->redirect(popurl(2). "cancel_pkg.html?". $cgi->query_string );