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(cust_pkg=>$cust_pkg) ) %>
11 <table style="background-color: #cccccc; border-spacing: 2; width: 100%">
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 % if ($method eq 'uncancel' ) {
27 % #XXX customer also requested setup
28 % # setup: what usefulness is changing or blanking this? re-charge setup fee?
29 % # an option that says that would be better if that's what we want to do
31 % # last_bill: isn't this informational? what good would editing it do?
32 % # something about invoice display?
33 <& /elements/tr-input-date-field.html, {
34 'name' => 'last_bill',
35 'value' => ( $cgi->param('last_bill') || $cust_pkg->get('last_bill') ),
36 'label' => mt("Last bill date"),
37 'format' => $date_format,
40 <& /elements/tr-input-date-field.html, {
42 'value' => ( $cgi->param('bill') || $cust_pkg->get('bill') ),
43 'label' => mt("Next bill date"),
44 'format' => $date_format,
47 <& /elements/tr-checkbox.html,
48 'label' => mt("Uncancel even if service reprovisioning fails"),
49 'field' => 'svc_not_fatal',
54 % my @uncancel_svcs = sort { $b->{'reprovisionable'} <=> $a->{'reprovisionable'} }
55 % sort { $a->{'svcpart'} <=> $b->{'svcpart'} }
56 % $cust_pkg->uncancel_svc_summary();
57 % if (@uncancel_svcs) {
58 <TR><TD COLSPAN="2"> </TD></TR>
59 <TR><TH ALIGN="right"><% emt("Re-provision the following services") %></TH><TD></TD>
60 % foreach my $uncancel_svc (@uncancel_svcs) {
61 % my $uncancel_curr_value = $uncancel_svc->{'uncancel_svcnum'};
62 % my $uncancel_disabled = '';
63 % my $uncancel_postfix = '';
64 % if ($cgi->param('error')) {
65 % $uncancel_curr_value = '' unless grep { $_ == $uncancel_svc->{'uncancel_svcnum'} } $cgi->param('only_svcnum');
67 % unless ($uncancel_svc->{'reprovisionable'}) {
68 % $uncancel_curr_value = '';
69 % $uncancel_disabled = 1;
70 % $uncancel_postfix = '<I>(' . emt('Cannot be reprovisioned') . ')</I>';
72 <& /elements/tr-checkbox.html,
73 'label' => $uncancel_svc->{'svc'} . ': ' . $uncancel_svc->{'label'},
74 'field' => 'only_svcnum',
75 'value' => $uncancel_svc->{'uncancel_svcnum'},
76 'curr_value' => $uncancel_curr_value,
77 'disabled' => $uncancel_disabled,
78 'cell_style' => 'font-weight: normal',
79 'postfix' => $uncancel_postfix,
85 % unless ( $method eq 'resume' || $method eq 'uncancel' ) {
86 <& /elements/tr-select-reason.html,
88 reason_class => $class,
89 curr_value => $reasonnum,
90 control_button => "confirm_cancel_pkg_button",
94 % if (( $method eq 'adjourn' || $method eq 'suspend' ) && $curuser->access_right('Customize billing during suspension')) {
96 % if ( $part_pkg->option('suspend_bill', 1) ) {
97 <& /elements/checkbox.html, name=>'no_suspend_bill', value=>'Y' &>
98 Disable recurring billing while suspended
100 <& /elements/checkbox.html, name=>'suspend_bill', value=>'Y' &>
101 Continue recurring billing while suspended
106 % if ( ( $method eq 'adjourn' || $method eq 'suspend' ) and
107 % $curuser->access_right('Unsuspend customer package') ) { #later?
108 % my $resume_date = $cgi->param('error')
109 % ? str2time($cgi->param('resume_date'))
110 % : $cust_pkg->get('resume');
112 <& /elements/tr-input-date-field.html, {
113 'name' => 'resume_date',
114 'value' => $resume_date,
115 'label' => mt('Unsuspend on'),
116 'format' => $date_format,
117 'noinit' => $date_init,
123 <INPUT TYPE="submit" NAME="submit" ID="confirm_cancel_pkg_button"
124 VALUE="<% mt($submit) |h %>"
125 <% $method !~ /^(resume|uncancel)$/ ? 'DISABLED' : '' %>>
132 use Date::Parse qw(str2time);
134 my $conf = new FS::Conf;
135 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
139 my($pkgnum, $reasonnum);
140 if ( $cgi->param('error') ) {
141 $pkgnum = $cgi->param('pkgnum');
142 $reasonnum = $cgi->param('reasonnum');
143 $date = str2time($cgi->param('date'));
144 } elsif ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) {
148 die "illegal query ". $cgi->keywords;
151 $cgi->param('method') =~ /^(\w+)$/ or die 'illegal method';
154 my($class, $submit, $right);
155 if ($method eq 'cancel') {
157 $submit = 'Cancel Now';
158 $right = 'Cancel customer package immediately';
159 } elsif ($method eq 'expire') {
161 $submit = 'Cancel Later';
162 $right = 'Cancel customer package later';
163 } elsif ($method eq 'suspend') {
165 $submit = 'Suspend Now';
166 $right = 'Suspend customer package';
167 } elsif ($method eq 'adjourn') {
169 $submit = "Suspend Later";
170 $right = 'Suspend customer package later';
171 } elsif ( $method eq 'resume') {
173 $submit = 'Unsuspend Later';
174 $right = 'Unsuspend customer package'; #later?
175 } elsif ( $method eq 'uncancel') {
177 $submit = 'Un-Cancel';
178 $right = 'Un-cancel customer package'; #later?
180 die 'illegal query (unknown method param)';
183 my $curuser = $FS::CurrentUser::CurrentUser;
184 die "access denied" unless $curuser->access_right($right);
186 my $title = ucfirst($method) . ' Package';
187 $title =~ s/Uncancel/Un-cancel/;
189 my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum})
190 or die "Unknown pkgnum: $pkgnum";
192 my $part_pkg = $cust_pkg->part_pkg;
194 $date ||= $cust_pkg->get($method);