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' || $method eq 'suspend' ) {
36 % if ( $part_pkg->option('suspend_bill', 1) ) {
37 <& /elements/checkbox.html, name=>'no_suspend_bill', value=>'Y' &>
38 Disable recurring billing while suspended
40 <& /elements/checkbox.html, name=>'suspend_bill', value=>'Y' &>
41 Continue recurring billing while suspended
46 % if ( ( $method eq 'adjourn' || $method eq 'suspend' ) and
47 % $curuser->access_right('Unsuspend customer package') ) { #later?
48 % my $resume_date = $cgi->param('error')
49 % ? str2time($cgi->param('resume_date'))
50 % : $cust_pkg->get('resume');
52 <& /elements/tr-input-date-field.html, {
53 'name' => 'resume_date',
54 'value' => $resume_date,
55 'label' => mt('Unsuspend on'),
56 'format' => $date_format,
57 'noinit' => $date_init,
63 <INPUT TYPE="submit" NAME="submit" ID="confirm_cancel_pkg_button"
64 VALUE="<% mt($submit) |h %>"
65 <% $method ne 'resume' ? 'DISABLED' : '' %>>
73 my $conf = new FS::Conf;
74 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
78 my($pkgnum, $reasonnum);
79 if ( $cgi->param('error') ) {
80 $pkgnum = $cgi->param('pkgnum');
81 $reasonnum = $cgi->param('reasonnum');
82 $date = str2time($cgi->param('date'));
83 } elsif ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) {
87 die "illegal query ". $cgi->keywords;
90 $cgi->param('method') =~ /^(\w+)$/ or die 'illegal method';
93 my($class, $submit, $right);
94 if ($method eq 'cancel') {
96 $submit = 'Cancel Now';
97 $right = 'Cancel customer package immediately';
98 } elsif ($method eq 'expire') {
100 $submit = 'Cancel Later';
101 $right = 'Cancel customer package later';
102 } elsif ($method eq 'suspend') {
104 $submit = 'Suspend Now';
105 $right = 'Suspend customer package';
106 } elsif ($method eq 'adjourn') {
108 $submit = "Suspend Later";
109 $right = 'Suspend customer package later';
110 } elsif ( $method eq 'resume') {
112 $submit = 'Unsuspend Later';
113 $right = 'Unsuspend customer package'; #later?
115 die 'illegal query (unknown method param)';
118 my $curuser = $FS::CurrentUser::CurrentUser;
119 die "access denied" unless $curuser->access_right($right);
121 my $title = ucfirst($method) . ' Package';
123 my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum})
124 or die "Unknown pkgnum: $pkgnum";
126 my $part_pkg = $cust_pkg->part_pkg;
128 $date ||= $cust_pkg->get($method);