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) ) %>
13 % for ( @unprovision_warning ) {
17 <table style="background-color: #cccccc; border-spacing: 2; width: 100%">
20 % if ($method eq 'expire' || $method eq 'adjourn' || $method eq 'resume') {
21 % $submit =~ /^(\w*)\s/;
22 <& /elements/tr-input-date-field.html, {
25 'label' => mt("$1 package on"),
26 'format' => $date_format,
31 % if ($method eq 'uncancel' ) {
33 % #XXX customer also requested setup
34 % # setup: what usefulness is changing or blanking this? re-charge setup fee?
35 % # an option that says that would be better if that's what we want to do
37 % # last_bill: isn't this informational? what good would editing it do?
38 % # something about invoice display?
39 <& /elements/tr-input-date-field.html, {
40 'name' => 'last_bill',
41 'value' => ( $cgi->param('last_bill') || $cust_pkg->get('last_bill') ),
42 'label' => mt("Last bill date"),
43 'format' => $date_format,
46 <& /elements/tr-input-date-field.html, {
48 'value' => ( $cgi->param('bill') || $cust_pkg->get('bill') ),
49 'label' => mt("Next bill date"),
50 'format' => $date_format,
53 <& /elements/tr-checkbox.html,
54 'label' => mt("Uncancel even if service reprovisioning fails"),
55 'field' => 'svc_not_fatal',
60 % my @uncancel_svcs = sort { $b->{'reprovisionable'} <=> $a->{'reprovisionable'} }
61 % sort { $a->{'svcpart'} <=> $b->{'svcpart'} }
62 % $cust_pkg->uncancel_svc_summary();
63 % if (@uncancel_svcs) {
64 <TR><TD COLSPAN="2"> </TD></TR>
65 <TR><TH ALIGN="right"><% emt("Re-provision the following services") %></TH><TD></TD>
66 % foreach my $uncancel_svc (@uncancel_svcs) {
67 % my $uncancel_curr_value = $uncancel_svc->{'uncancel_svcnum'};
68 % my $uncancel_disabled = '';
69 % my $uncancel_postfix = '';
70 % if ($cgi->param('error')) {
71 % $uncancel_curr_value = '' unless grep { $_ == $uncancel_svc->{'uncancel_svcnum'} } $cgi->param('only_svcnum');
73 % unless ($uncancel_svc->{'reprovisionable'}) {
74 % $uncancel_curr_value = '';
75 % $uncancel_disabled = 1;
76 % $uncancel_postfix = '<I>(' . emt('Cannot be reprovisioned') . ')</I>';
78 <& /elements/tr-checkbox.html,
79 'label' => $uncancel_svc->{'svc'} . ': ' . $uncancel_svc->{'label'},
80 'field' => 'only_svcnum',
81 'value' => $uncancel_svc->{'uncancel_svcnum'},
82 'curr_value' => $uncancel_curr_value,
83 'disabled' => $uncancel_disabled,
84 'cell_style' => 'font-weight: normal',
85 'postfix' => $uncancel_postfix,
91 % unless ( $method eq 'resume' || $method eq 'uncancel' ) {
92 <& /elements/tr-select-reason.html,
94 reason_class => $class,
95 curr_value => $reasonnum,
96 control_button => "confirm_cancel_pkg_button",
100 % if (( $method eq 'adjourn' || $method eq 'suspend' ) && $curuser->access_right('Customize billing during suspension')) {
102 % if ( $part_pkg->option('suspend_bill', 1) ) {
103 <& /elements/checkbox.html, name=>'no_suspend_bill', value=>'Y' &>
104 Disable recurring billing while suspended
106 <& /elements/checkbox.html, name=>'suspend_bill', value=>'Y' &>
107 Continue recurring billing while suspended
112 % if ( ( $method eq 'adjourn' || $method eq 'suspend' ) and
113 % $curuser->access_right('Unsuspend customer package') ) { #later?
114 % my $resume_date = $cgi->param('error')
115 % ? str2time($cgi->param('resume_date'))
116 % : $cust_pkg->get('resume');
118 <& /elements/tr-input-date-field.html, {
119 'name' => 'resume_date',
120 'value' => $resume_date,
121 'label' => mt('Unsuspend on'),
122 'format' => $date_format,
123 'noinit' => $date_init,
129 <INPUT TYPE="submit" NAME="submit" ID="confirm_cancel_pkg_button"
130 VALUE="<% mt($submit) |h %>"
131 <% $method !~ /^(resume|uncancel)$/ ? 'DISABLED' : '' %>>
138 use Date::Parse qw(str2time);
140 my $conf = new FS::Conf;
141 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
145 my($pkgnum, $reasonnum);
146 if ( $cgi->param('error') ) {
147 $pkgnum = $cgi->param('pkgnum');
148 $reasonnum = $cgi->param('reasonnum');
149 $date = str2time($cgi->param('date'));
150 } elsif ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) {
154 die "illegal query ". $cgi->keywords;
157 $cgi->param('method') =~ /^(\w+)$/ or die 'illegal method';
160 my($class, $submit, $right);
161 if ($method eq 'cancel') {
163 $submit = 'Cancel Now';
164 $right = 'Cancel customer package immediately';
165 } elsif ($method eq 'expire') {
167 $submit = 'Cancel Later';
168 $right = 'Cancel customer package later';
169 } elsif ($method eq 'suspend') {
171 $submit = 'Suspend Now';
172 $right = 'Suspend customer package';
173 } elsif ($method eq 'adjourn') {
175 $submit = "Suspend Later";
176 $right = 'Suspend customer package later';
177 } elsif ( $method eq 'resume') {
179 $submit = 'Unsuspend Later';
180 $right = 'Unsuspend customer package'; #later?
181 } elsif ( $method eq 'uncancel') {
183 $submit = 'Un-Cancel';
184 $right = 'Un-cancel customer package'; #later?
186 die 'illegal query (unknown method param)';
189 my $curuser = $FS::CurrentUser::CurrentUser;
190 die "access denied" unless $curuser->access_right($right);
192 my $title = ucfirst($method) . ' Package';
193 $title =~ s/Uncancel/Un-cancel/;
195 my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum})
196 or die "Unknown pkgnum: $pkgnum";
198 my $part_pkg = $cust_pkg->part_pkg;
200 my @unprovision_warning = ();
201 unless ( $method =~ /^(resume|uncancel)$/ ) {
202 my @services_w_export = map { my @l = $_->label; $l[0]. ': '. $l[1]; }
203 grep $_->part_svc->export_svc,
205 if ( @services_w_export ) {
207 my $actioned = ($method =~ /^(suspend|adjourn)$/) ? 'suspended'
209 push @unprovision_warning,
210 'NOTE: This package has '. @services_w_export. ' '.
211 PL( 'service', @services_w_export ). " that will be $actioned";
213 if ( @services_w_export < 10 ) {
214 $unprovision_warning[0] .= ':';
215 push @unprovision_warning, @services_w_export;
217 $unprovision_warning[0] .= '.';
223 $date ||= $cust_pkg->get($method);