1 <& /elements/header-popup.html, mt($title) &>
3 <& /elements/error.html &>
5 <FORM NAME="sc_popup" ACTION="<% popurl(1) %>process/cancel_pkg.html" METHOD=POST>
6 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
7 <INPUT TYPE="hidden" NAME="method" VALUE="<% $method %>">
10 <% emt(ucfirst($method)." [_1]", $part_pkg->pkg_comment) %>
11 <% ntable("#cccccc", 2) %>
14 % if ($method eq 'expire' || $method eq 'adjourn' || $method eq 'resume') {
15 % $submit =~ /^(\w*)\s/;
16 <& /elements/tr-input-date-field.html, {
19 'label' => mt("$1 package on"),
20 'format' => $date_format,
25 % unless ( $method eq 'resume' ) { #the only one that doesn't need a reason
26 <& /elements/tr-select-reason.html,
27 'field' => 'reasonnum',
28 'reason_class' => $class,
29 'curr_value' => $reasonnum,
30 'control_button' => "document.getElementById('confirm_cancel_pkg_button')",
34 % if ( ( $method eq 'adjourn' or $method eq 'suspend' ) and
35 % $curuser->access_right('Unsuspend customer package') ) { #later?
36 % my $resume_date = $cgi->param('error')
37 % ? str2time($cgi->param('resume_date'))
38 % : $cust_pkg->get('resume');
40 <& /elements/tr-input-date-field.html, {
41 'name' => 'resume_date',
42 'value' => $resume_date,
43 'label' => mt('Unsuspend on'),
44 'format' => $date_format,
45 'noinit' => $date_init,
51 <INPUT TYPE="submit" NAME="submit" ID="confirm_cancel_pkg_button"
52 VALUE="<% mt($submit) |h %>"
53 <% $method ne 'resume' ? 'DISABLED' : '' %>>
61 my $conf = new FS::Conf;
62 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
66 my($pkgnum, $reasonnum);
67 if ( $cgi->param('error') ) {
68 $pkgnum = $cgi->param('pkgnum');
69 $reasonnum = $cgi->param('reasonnum');
70 $date = str2time($cgi->param('date'));
71 } elsif ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) {
75 die "illegal query ". $cgi->keywords;
78 $cgi->param('method') =~ /^(\w+)$/ or die 'illegal method';
81 my($class, $submit, $right);
82 if ($method eq 'cancel') {
84 $submit = 'Cancel Now';
85 $right = 'Cancel customer package immediately';
86 } elsif ($method eq 'expire') {
88 $submit = 'Cancel Later';
89 $right = 'Cancel customer package later';
90 } elsif ($method eq 'suspend') {
92 $submit = 'Suspend Now';
93 $right = 'Suspend customer package';
94 } elsif ($method eq 'adjourn') {
96 $submit = "Suspend Later";
97 $right = 'Suspend customer package later';
98 } elsif ( $method eq 'resume') {
100 $submit = 'Unsuspend Later';
101 $right = 'Unsuspend customer package'; #later?
103 die 'illegal query (unknown method param)';
106 my $curuser = $FS::CurrentUser::CurrentUser;
107 die "access denied" unless $curuser->access_right($right);
109 my $title = ucfirst($method) . ' Package';
111 my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum})
112 or die "Unknown pkgnum: $pkgnum";
114 my $part_pkg = $cust_pkg->part_pkg;
116 $date ||= $cust_pkg->get($method);